Browse Source

r11676@catbus: nickm | 2007-02-07 00:10:00 -0500
(Hopefully) final changes for 0.1.2.7-alpha: disable checking for whether the user account in question exists on --service install, since that seems to make windows go boom. We can figure out why later. Also, let the admin specify a password for the target user.


svn:r9506

Nick Mathewson 17 years ago
parent
commit
295f6d4e0f
2 changed files with 13 additions and 5 deletions
  1. 1 1
      ChangeLog
  2. 12 4
      src/or/main.c

+ 1 - 1
ChangeLog

@@ -18,7 +18,7 @@ Changes in version 0.1.2.7-alpha - 2007-02-06
   o Major bugfixes (NT services):
   o Major bugfixes (NT services):
     - Install as NT_AUTHORITY\LocalService rather than as SYSTEM; add a
     - Install as NT_AUTHORITY\LocalService rather than as SYSTEM; add a
       command-line flag so that admins can override the default by saying
       command-line flag so that admins can override the default by saying
-      "tor --service install --user "SomeUser"".  This will not effect
+      "tor --service install --user "SomeUser"".  This will not affect
       existing installed services.  Also, warn the user that the service
       existing installed services.  Also, warn the user that the service
       will look for its configuration file in the service user's
       will look for its configuration file in the service user's
       %appdata% directory.  (We can't do the 'hardwire the user's appdata
       %appdata% directory.  (We can't do the 'hardwire the user's appdata

+ 12 - 4
src/or/main.c

@@ -2122,7 +2122,7 @@ nt_service_command_line(int *using_default_torrc)
   smartlist_free(sl);
   smartlist_free(sl);
 
 
   /* Allocate a string for the NT service command line */
   /* Allocate a string for the NT service command line */
-  cmdlen = strlen(tor_exe) + strlen(options) + 32;
+  cmdlen = strlen(tor_exe) + (options?strlen(options):0) + 32;
   command = tor_malloc(cmdlen);
   command = tor_malloc(cmdlen);
 
 
   /* Format the service command */
   /* Format the service command */
@@ -2161,6 +2161,7 @@ nt_service_install(int argc, char **argv)
   char *command;
   char *command;
   char *errmsg;
   char *errmsg;
   const char *user_acct = GENSRV_USERACCT;
   const char *user_acct = GENSRV_USERACCT;
+  const char *password = "";
   int i;
   int i;
   OSVERSIONINFOEX info;
   OSVERSIONINFOEX info;
   SID_NAME_USE sidUse;
   SID_NAME_USE sidUse;
@@ -2180,11 +2181,16 @@ nt_service_install(int argc, char **argv)
     service_fns.CloseServiceHandle_fn(hSCManager);
     service_fns.CloseServiceHandle_fn(hSCManager);
     return -1;
     return -1;
   }
   }
+
   for (i=1; i < argc; ++i) {
   for (i=1; i < argc; ++i) {
     if (!strcmp(argv[i], "--user") && i+1<argc) {
     if (!strcmp(argv[i], "--user") && i+1<argc) {
       user_acct = argv[i+1];
       user_acct = argv[i+1];
       ++i;
       ++i;
     }
     }
+    if (!strcmp(argv[i], "--password") && i+1<argc) {
+      password = argv[i+1];
+      ++i;
+    }
   }
   }
 
 
   /* Compute our version and see whether we're running win2k or earlier. */
   /* Compute our version and see whether we're running win2k or earlier. */
@@ -2215,11 +2221,12 @@ nt_service_install(int argc, char **argv)
       printf("Running on a Post-Win2K OS, so we'll assume that the "
       printf("Running on a Post-Win2K OS, so we'll assume that the "
              "LocalService account exists.\n");
              "LocalService account exists.\n");
     }
     }
-  } else if (service_fns.LookupAccountNameA_fn(NULL, // On this system
+  } else if (0 && service_fns.LookupAccountNameA_fn(NULL, // On this system
                             user_acct,
                             user_acct,
                             NULL, &sidLen, // Don't care about the SID
                             NULL, &sidLen, // Don't care about the SID
                             NULL, &domainLen, // Don't care about the domain
                             NULL, &domainLen, // Don't care about the domain
                             &sidUse) == 0) {
                             &sidUse) == 0) {
+    /* XXXX012 For some reason, the above test segfaults. Fix that. */
     printf("User \"%s\" doesn't seem to exist.\n", user_acct);
     printf("User \"%s\" doesn't seem to exist.\n", user_acct);
     return -1;
     return -1;
   } else {
   } else {
@@ -2239,8 +2246,8 @@ nt_service_install(int argc, char **argv)
                                 GENSRV_DISPLAYNAME,
                                 GENSRV_DISPLAYNAME,
                                 SERVICE_ALL_ACCESS, SERVICE_WIN32_OWN_PROCESS,
                                 SERVICE_ALL_ACCESS, SERVICE_WIN32_OWN_PROCESS,
                                 SERVICE_AUTO_START, SERVICE_ERROR_IGNORE,
                                 SERVICE_AUTO_START, SERVICE_ERROR_IGNORE,
-                                command,
-                                NULL, NULL, NULL, user_acct, "")) == NULL) {
+                                command, NULL, NULL, NULL,
+                                user_acct, password)) == NULL) {
     errmsg = nt_strerror(GetLastError());
     errmsg = nt_strerror(GetLastError());
     printf("CreateService() failed : %s\n", errmsg);
     printf("CreateService() failed : %s\n", errmsg);
     service_fns.CloseServiceHandle_fn(hSCManager);
     service_fns.CloseServiceHandle_fn(hSCManager);
@@ -2248,6 +2255,7 @@ nt_service_install(int argc, char **argv)
     tor_free(command);
     tor_free(command);
     return -1;
     return -1;
   }
   }
+  printf("Done with CreateService.\n");
 
 
   /* Set the service's description */
   /* Set the service's description */
   sdBuff.lpDescription = GENSRV_DESCRIPTION;
   sdBuff.lpDescription = GENSRV_DESCRIPTION;