From: Nick Mathewson Date: Sun, 15 May 2011 17:11:48 +0000 (-0400) Subject: Make check_private_dir check for group ownership as appropriate X-Git-Tag: tor-0.2.2.26-beta~11^2~1^2 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=f72e792be5437c9ee11d3f498ed3bb469b46d1bb;p=thirdparty%2Ftor.git Make check_private_dir check for group ownership as appropriate --- diff --git a/src/common/util.c b/src/common/util.c index 0e739f2127..1bb116b212 100644 --- a/src/common/util.c +++ b/src/common/util.c @@ -30,6 +30,7 @@ #else #include #include +#include #endif /* math.h needs this on Linux */ @@ -1736,6 +1737,21 @@ check_private_dir(const char *dirname, cpd_check_t check) tor_free(process_ownername); return -1; } + if ((check & CPD_GROUP_OK) && st.st_gid != getgid()) { + struct group *gr; + char *process_groupname = NULL; + gr = getgrgid(getgid()); + process_groupname = gr ? tor_strdup(gr->gr_name) : tor_strdup(""); + gr = getgrgid(st.st_gid); + + log_warn(LD_FS, "%s is not owned by this group (%s, %d) but by group " + "%s (%d). Are you running Tor as the wrong user?", + dirname, process_groupname, (int)getgid(), + gr ? gr->gr_name : "", (int)st.st_gid); + + tor_free(process_groupname); + return -1; + } if (check & CPD_GROUP_OK) { mask = 0027; } else {