summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2017-09-15 14:27:58 -0400
committerNick Mathewson <nickm@torproject.org>2017-09-15 14:27:58 -0400
commit9201e4c74b10c28b551e6ac4d4e1830f5386b481 (patch)
tree74fd6fd0935443362de4d9b6247762a108b04165
parent03e102c1bb04c29392192187f031d45357a9815f (diff)
parent75659fd548cbb6d597c9cf3fc6748f9771a746e9 (diff)
downloadtor-9201e4c74b10c28b551e6ac4d4e1830f5386b481.tar.gz
tor-9201e4c74b10c28b551e6ac4d4e1830f5386b481.zip
Merge branch 'bug23487_029'
-rw-r--r--changes/bug234875
-rw-r--r--src/common/util.c22
2 files changed, 19 insertions, 8 deletions
diff --git a/changes/bug23487 b/changes/bug23487
new file mode 100644
index 0000000000..89b55c243a
--- /dev/null
+++ b/changes/bug23487
@@ -0,0 +1,5 @@
+ o Minor bugfixes (logging):
+ - When warning about a directory owned by the wrong user, log the actual
+ name of the user owning the directory. Previously, we'd log the name
+ of the process owner twice. Fixes bug 23487; bugfix on 0.2.9.1-alpha.
+
diff --git a/src/common/util.c b/src/common/util.c
index ac2fd6700f..788d2501b1 100644
--- a/src/common/util.c
+++ b/src/common/util.c
@@ -2342,21 +2342,27 @@ check_private_dir,(const char *dirname, cpd_check_t check,
running_gid = getgid();
}
if (st.st_uid != running_uid) {
- const struct passwd *pw_uid = NULL;
- char *process_ownername = NULL;
+ char *process_ownername = NULL, *file_ownername = NULL;
- pw_uid = tor_getpwuid(running_uid);
- process_ownername = pw_uid ? tor_strdup(pw_uid->pw_name) :
- tor_strdup("<unknown>");
+ {
+ const struct passwd *pw_running = tor_getpwuid(running_uid);
+ process_ownername = pw_running ? tor_strdup(pw_running->pw_name) :
+ tor_strdup("<unknown>");
+ }
- pw_uid = tor_getpwuid(st.st_uid);
+ {
+ const struct passwd *pw_stat = tor_getpwuid(st.st_uid);
+ file_ownername = pw_stat ? tor_strdup(pw_stat->pw_name) :
+ tor_strdup("<unknown>");
+ }
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)running_uid,
- pw ? pw->pw_name : "<unknown>", (int)st.st_uid);
+ dirname, process_ownername, (int)running_uid,
+ file_ownername, (int)st.st_uid);
tor_free(process_ownername);
+ tor_free(file_ownername);
close(fd);
return -1;
}