[or-cvs] r9502: The --service install code can no longer default to adding a (in tor/trunk: . src/or)

nickm at seul.org nickm at seul.org
Tue Feb 6 18:36:41 UTC 2007


Author: nickm
Date: 2007-02-06 13:36:26 -0500 (Tue, 06 Feb 2007)
New Revision: 9502

Modified:
   tor/trunk/
   tor/trunk/ChangeLog
   tor/trunk/src/or/main.c
Log:
 r11667 at catbus:  nickm | 2007-02-06 13:36:18 -0500
 The --service install code can no longer default to adding an -f option for the appdata directory of the current user, since the target user probably will not be able to read it.  Instead, warn the user if no explicit torrc filename is given.



Property changes on: tor/trunk
___________________________________________________________________
 svk:merge ticket from /tor/trunk [r11667] on 8246c3cf-6607-4228-993b-4d95d33730f1

Modified: tor/trunk/ChangeLog
===================================================================
--- tor/trunk/ChangeLog	2007-02-06 18:36:21 UTC (rev 9501)
+++ tor/trunk/ChangeLog	2007-02-06 18:36:26 UTC (rev 9502)
@@ -19,7 +19,11 @@
     - Install as NT_AUTHORITY\LocalService rather than as SYSTEM; add a
       command-line flag so that admins can override the default by saying
       "tor --service install --user "SomeUser"".  This will not effect
-      existing installed services.
+      existing installed services.  Also, warn the user that the service
+      will look for its configuration file in the service user's
+      %appdata% directory.  (We can't do the 'hardwire the user's appdata
+      directory' trick any more, since we may not have read access to that
+      directory.)
 
   o Major bugfixes (other):
     - Previously, we would cache up to 16 old networkstatus documents

Modified: tor/trunk/src/or/main.c
===================================================================
--- tor/trunk/src/or/main.c	2007-02-06 18:36:21 UTC (rev 9501)
+++ tor/trunk/src/or/main.c	2007-02-06 18:36:26 UTC (rev 9502)
@@ -86,6 +86,8 @@
 
 SERVICE_STATUS service_status;
 SERVICE_STATUS_HANDLE hStatus;
+/* XXXX This 'backup argv' and 'backup argc' business is an ugly hack. This
+ * is a job for arguments, not globals. */
 static char **backup_argv;
 static int backup_argc;
 static int nt_service_is_stopped(void);
@@ -2086,16 +2088,19 @@
 }
 
 /** Build a formatted command line used for the NT service. Return a
- * pointer to the formatted string on success, or NULL on failure. */
-char *
-nt_service_command_line(void)
+ * pointer to the formatted string on success, or NULL on failure.  Set
+ * *<b>using_default_torrc</b> to true if we're going to use the default
+ * location to torrc, or 1 if an option was specified on the command line.
+ */
+static char *
+nt_service_command_line(int *using_default_torrc)
 {
   TCHAR tor_exe[MAX_PATH+1];
   char *command, *options;
   const char *torrc;
   smartlist_t *sl;
   int i, cmdlen;
-  int use_default_torrc = 1;
+  *using_default_torrc = 1;
 
   /* Get the location of tor.exe */
   if (0 == GetModuleFileName(NULL, tor_exe, MAX_PATH))
@@ -2109,15 +2114,11 @@
         !strcmp(backup_argv[i], "-options")) {
       while (++i < backup_argc) {
         if (!strcmp(backup_argv[i], "-f"))
-          use_default_torrc = 0;
+          *using_default_torrc = 0;
         smartlist_add(sl, backup_argv[i]);
       }
     }
   }
-  if (use_default_torrc) {
-    smartlist_add(sl, "-f");
-    smartlist_add(sl, (char*)torrc);
-  }
   tor_assert(smartlist_len(sl));
   options = smartlist_join_strings(sl,"\" \"",0,NULL);
   smartlist_free(sl);
@@ -2160,6 +2161,7 @@
   SID_NAME_USE sidUse;
   DWORD sidLen = 0, domainLen = 0;
   int is_win2k_or_worse = 0;
+  int using_default_torrc = 0;
 
   if (nt_service_loadlibrary()<0)
     return -1;
@@ -2168,7 +2170,7 @@
   if ((hSCManager = nt_service_open_scm()) == NULL)
     return -1;
   /* Build the command line used for the service */
-  if ((command = nt_service_command_line()) == NULL) {
+  if ((command = nt_service_command_line(&using_default_torrc)) == NULL) {
     printf("Unable to build service command line.\n");
     service_fns.CloseServiceHandle_fn(hSCManager);
     return -1;
@@ -2218,6 +2220,14 @@
   } else {
     printf("Will try to install service as user \"%s\".\n", user_acct);
   }
+  /* XXXX This warning could be better about explaining how to resolve the
+   * situation. */
+  if (using_default_torrc)
+    printf("IMPORTANT NOTE:\n"
+        "    The Tor service will run under the account \"%s\".  This means\n"
+        "    that Tor will look for its configuration file under that\n"
+        "    account's Application Data directory, which is probably not\n"
+        "    the same as yours.\n", user_acct?user_acct:"<local system>");
 
   /* Create the Tor service, set to auto-start on boot */
   if ((hService = service_fns.CreateServiceA_fn(hSCManager, GENSRV_SERVICENAME,



More information about the tor-commits mailing list