[or-cvs] Also print usernames, not just numeric UIDs when we tell th...
Peter Palfrader
weasel at seul.org
Mon Dec 5 01:28:12 UTC 2005
Update of /home/or/cvsroot/tor/src/common
In directory moria:/tmp/cvs-serv24428/src/common
Modified Files:
util.c
Log Message:
Also print usernames, not just numeric UIDs when we tell the user that his data directory has the wrong owner
Index: util.c
===================================================================
RCS file: /home/or/cvsroot/tor/src/common/util.c,v
retrieving revision 1.235
retrieving revision 1.236
diff -u -d -r1.235 -r1.236
--- util.c 5 Dec 2005 01:07:58 -0000 1.235
+++ util.c 5 Dec 2005 01:28:10 -0000 1.236
@@ -26,6 +26,7 @@
#include <direct.h>
#else
#include <dirent.h>
+#include <pwd.h>
#endif
#ifdef HAVE_CTYPE_H
@@ -912,7 +913,19 @@
}
#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) {
More information about the tor-commits
mailing list