mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-11-14 07:03:44 +01:00
Merge branch 'bug1101_squashed'
This commit is contained in:
commit
8b4e7f9ac8
3
changes/bug1101
Normal file
3
changes/bug1101
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
o Minor features:
|
||||||
|
- Use absolute path names when reporting the torrc filename, so
|
||||||
|
that a controller can more easily find it. Resolves bug 1101.
|
@ -1634,6 +1634,42 @@ get_parent_directory(char *fname)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Expand possibly relative path <b>fname</b> to an absolute path.
|
||||||
|
* Return a newly allocated string, possibly equal to <b>fname</b>. */
|
||||||
|
char *
|
||||||
|
make_path_absolute(char *fname)
|
||||||
|
{
|
||||||
|
#ifdef WINDOWS
|
||||||
|
char *absfname_malloced = _fullpath(NULL, fname, 1);
|
||||||
|
|
||||||
|
/* We don't want to assume that tor_free can free a string allocated
|
||||||
|
* with malloc. On failure, return fname (it's better than nothing). */
|
||||||
|
char *absfname = tor_strdup(absfname_malloced ? absfname_malloced : fname);
|
||||||
|
if (absfname_malloced) free(absfname_malloced);
|
||||||
|
|
||||||
|
return absfname;
|
||||||
|
#else
|
||||||
|
char path[PATH_MAX+1];
|
||||||
|
char *absfname = NULL;
|
||||||
|
|
||||||
|
tor_assert(fname);
|
||||||
|
|
||||||
|
if(fname[0] == '/') {
|
||||||
|
absfname = tor_strdup(fname);
|
||||||
|
} else {
|
||||||
|
if (getcwd(path, PATH_MAX) != NULL) {
|
||||||
|
tor_asprintf(&absfname, "%s/%s", path, fname);
|
||||||
|
} else {
|
||||||
|
/* If getcwd failed, the best we can do here is keep using the
|
||||||
|
* relative path. (Perhaps / isn't readable by this UID/GID.) */
|
||||||
|
absfname = tor_strdup(fname);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return absfname;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
/** Set *addr to the IP address (in dotted-quad notation) stored in c.
|
/** Set *addr to the IP address (in dotted-quad notation) stored in c.
|
||||||
* Return 1 on success, 0 if c is badly formatted. (Like inet_aton(c,addr),
|
* Return 1 on success, 0 if c is badly formatted. (Like inet_aton(c,addr),
|
||||||
* but works on Windows and Solaris.)
|
* but works on Windows and Solaris.)
|
||||||
|
@ -571,6 +571,7 @@ char *get_user_homedir(const char *username);
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
int get_parent_directory(char *fname);
|
int get_parent_directory(char *fname);
|
||||||
|
char *make_path_absolute(char *fname);
|
||||||
|
|
||||||
int spawn_func(void (*func)(void *), void *data);
|
int spawn_func(void (*func)(void *), void *data);
|
||||||
void spawn_exit(void) ATTR_NORETURN;
|
void spawn_exit(void) ATTR_NORETURN;
|
||||||
|
@ -4356,6 +4356,14 @@ find_torrc_filename(int argc, char **argv,
|
|||||||
tor_free(fname);
|
tor_free(fname);
|
||||||
}
|
}
|
||||||
fname = expand_filename(argv[i+1]);
|
fname = expand_filename(argv[i+1]);
|
||||||
|
|
||||||
|
{
|
||||||
|
char *absfname;
|
||||||
|
absfname = make_path_absolute(fname);
|
||||||
|
tor_free(fname);
|
||||||
|
fname = absfname;
|
||||||
|
}
|
||||||
|
|
||||||
*using_default_torrc = 0;
|
*using_default_torrc = 0;
|
||||||
++i;
|
++i;
|
||||||
} else if (ignore_opt && !strcmp(argv[i],ignore_opt)) {
|
} else if (ignore_opt && !strcmp(argv[i],ignore_opt)) {
|
||||||
|
Loading…
Reference in New Issue
Block a user