mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-11-10 05:03:43 +01:00
Also print usernames, not just numeric UIDs when we tell the user that his data directory has the wrong owner
svn:r5502
This commit is contained in:
parent
c5bee116b6
commit
7a70a142f4
@ -307,7 +307,7 @@ dnl These headers are not essential
|
||||
|
||||
AC_CHECK_HEADERS(stdint.h sys/types.h inttypes.h sys/param.h sys/wait.h sys/limits.h netinet/in.h arpa/inet.h machine/limits.h syslog.h sys/time.h sys/resource.h stddef.h inttypes.h utime.h sys/utime.h)
|
||||
|
||||
AC_CHECK_FUNCS(gettimeofday ftime socketpair uname inet_aton strptime getrlimit setrlimit strlcat strlcpy strtoull getpwnam ftello getaddrinfo localtime_r gmtime_r event_get_version event_get_method event_set_log_callback memmem)
|
||||
AC_CHECK_FUNCS(gettimeofday ftime socketpair uname inet_aton strptime getrlimit setrlimit strlcat strlcpy strtoull getpwnam getpwuid ftello getaddrinfo localtime_r gmtime_r event_get_version event_get_method event_set_log_callback memmem)
|
||||
|
||||
if test $enable_threads = "yes"; then
|
||||
AC_CHECK_HEADERS(pthread.h)
|
||||
|
@ -26,6 +26,7 @@ const char util_c_id[] = "$Id$";
|
||||
#include <direct.h>
|
||||
#else
|
||||
#include <dirent.h>
|
||||
#include <pwd.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_CTYPE_H
|
||||
@ -912,7 +913,19 @@ check_private_dir(const char *dirname, cpd_check_t check)
|
||||
}
|
||||
#ifndef MS_WINDOWS
|
||||
if (st.st_uid != getuid()) {
|
||||
log(LOG_WARN, LD_FS, "%s is not owned by this UID (%d). Perhaps you are running Tor as the wrong user?", dirname, (int)getuid());
|
||||
struct passwd *pw = NULL;
|
||||
char *process_ownername = NULL;
|
||||
|
||||
pw = getpwuid(getuid());
|
||||
process_ownername = pw ? tor_strdup(pw->pw_name) : "<unknown>";
|
||||
|
||||
pw = getpwuid(st.st_uid);
|
||||
|
||||
log(LOG_WARN, LD_FS, "%s is not owned by this user (%s, %d) but by %s (%d). Perhaps you are running Tor as the wrong user?",
|
||||
dirname, process_ownername, (int)getuid(),
|
||||
pw ? tor_strdup(pw->pw_name) : "<unknown>", (int)st.st_uid);
|
||||
|
||||
tor_free(process_ownername);
|
||||
return -1;
|
||||
}
|
||||
if (st.st_mode & 0077) {
|
||||
|
Loading…
Reference in New Issue
Block a user