diff options
author | Peter Palfrader <peter@palfrader.org> | 2005-12-05 01:28:10 +0000 |
---|---|---|
committer | Peter Palfrader <peter@palfrader.org> | 2005-12-05 01:28:10 +0000 |
commit | 7a70a142f434c0778fda8a87917c545d4d081527 (patch) | |
tree | ba690c3ebf7457f01a858a146cbd037e1beeafda /src/common | |
parent | c5bee116b6f32b63370d2e1fda4bc75fb494b3c7 (diff) | |
download | tor-7a70a142f434c0778fda8a87917c545d4d081527.tar.gz tor-7a70a142f434c0778fda8a87917c545d4d081527.zip |
Also print usernames, not just numeric UIDs when we tell the user that his data directory has the wrong owner
svn:r5502
Diffstat (limited to 'src/common')
-rw-r--r-- | src/common/util.c | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/src/common/util.c b/src/common/util.c index a2a20c2ecd..f3931c8282 100644 --- a/src/common/util.c +++ b/src/common/util.c @@ -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) { |