[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[or-cvs] r17543: {tor} Better error message when told to setuid to ourself. (in tor/trunk: . src/common)



Author: nickm
Date: 2008-12-09 18:26:12 -0500 (Tue, 09 Dec 2008)
New Revision: 17543

Modified:
   tor/trunk/ChangeLog
   tor/trunk/src/common/compat.c
Log:
Better error message when told to setuid to ourself.

Modified: tor/trunk/ChangeLog
===================================================================
--- tor/trunk/ChangeLog	2008-12-09 23:10:38 UTC (rev 17542)
+++ tor/trunk/ChangeLog	2008-12-09 23:26:12 UTC (rev 17543)
@@ -1,5 +1,10 @@
 Changes in version 0.2.1.9-alpha - 200?-??-??
 
+  o Minor features:
+    - Give a better error message when an overzealous init script says,
+      "sudo -u username tor --user username".  Makes Bug 882 easier
+      for users to diagnose.
+
   o Minor features (controller):
     - New CONSENSUS_ARRIVED event to note when a new consensus has
       been fetched and validated.

Modified: tor/trunk/src/common/compat.c
===================================================================
--- tor/trunk/src/common/compat.c	2008-12-09 23:10:38 UTC (rev 17542)
+++ tor/trunk/src/common/compat.c	2008-12-09 23:26:12 UTC (rev 17543)
@@ -1103,9 +1103,18 @@
 
   /* Properly switch egid,gid,euid,uid here or bail out */
   if (setgroups(1, &pw->pw_gid)) {
-    log_warn(LD_GENERAL, "Error setting groups to gid %d: \"%s\". "
-             "If you set the \"User\" option, you must start Tor as root.",
+    log_warn(LD_GENERAL, "Error setting groups to gid %d: \"%s\".",
              (int)pw->pw_gid, strerror(errno));
+    if (old_uid == pw->pw_uid) {
+      log_warn(LD_GENERAL, "Tor is already running as %s.  You do not need "
+               "the \"User\" option if you are already running as the user "
+               "you want to be.  (If you did not set the User option in your "
+               "torrc, check whether it was specified on the command line "
+               "by a startup script.)", user);
+    } else {
+      log_warn(LD_GENERAL, "If you set the \"User\" option, you must start Tor"
+               " as root.");
+    }
     return -1;
   }