summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2007-02-06 16:55:42 +0000
committerNick Mathewson <nickm@torproject.org>2007-02-06 16:55:42 +0000
commit0c4ab00658cc33e893c4b402ddc81d083338bbd4 (patch)
tree22025409371df56ec7293699316b70e78b2197b0
parentda5cd33ab860921cb04b5b117e7910d8995cd27d (diff)
downloadtor-0c4ab00658cc33e893c4b402ddc81d083338bbd4.tar.gz
tor-0c4ab00658cc33e893c4b402ddc81d083338bbd4.zip
r11664@catbus: nickm | 2007-02-06 11:55:37 -0500
More win32 account flumdummery: when LocalService exists, you can't detect it via LookupAccountName. The only good test is to see whether we're on win2k or earlier. Apparently, somebody wouldn't know where to draw the line between implementation and interface if you gave them tracing paper and a copy of Stevens. svn:r9499
-rw-r--r--src/or/main.c53
1 files changed, 39 insertions, 14 deletions
diff --git a/src/or/main.c b/src/or/main.c
index c3fcde18a6..f5573445e9 100644
--- a/src/or/main.c
+++ b/src/or/main.c
@@ -2156,8 +2156,10 @@ nt_service_install(int argc, char **argv)
char *errmsg;
const char *user_acct = GENSRV_USERACCT;
int i;
+ OSVERSIONINFOEX info;
SID_NAME_USE sidUse;
- DWORD zero = 0;
+ DWORD sidLen = 0, domainLen = 0;
+ int is_win2k_or_worse = 0;
if (nt_service_loadlibrary()<0)
return -1;
@@ -2178,20 +2180,43 @@ nt_service_install(int argc, char **argv)
}
}
- if (service_fns.LookupAccountNameA_fn(NULL, // On this system
- user_acct,
- NULL,
- &zero, // Don't care about the SID
- NULL,
- &zero, // Don't care about the domain
- &sidUse) == 0) {
+ /* Compute our version and see whether we're running win2k or earlier. */
+ memset(&info, 0, sizeof(info));
+ info.dwOSVersionInfoSize = sizeof(info);
+ if (! GetVersionEx((LPOSVERSIONINFO)&info)) {
+ printf("Call to GetVersionEx failed.\n");
+ is_win2k_or_worse = 1;
+ } else {
+ if (info.dwMajorVersion < 5 ||
+ (info.dwMajorVersion == 5 && info.dwMinorVersion == 0))
+ is_win2k_or_worse = 1;
+ }
+
+ if (user_acct == GENSRV_USERACCT) {
+ if (is_win2k_or_worse) {
+ /* On Win2k, there is no LocalService account, so we actually need to
+ * fall back on NULL (the system account). */
+ printf("Running on Win2K or earlier, so the LocalService account "
+ "doesn't exist. Falling back to SYSTEM account.\n");
+ user_acct = NULL;
+ } else {
+ /* Genericity is apparently _so_ last year in Redmond, where some
+ * accounts are accounts that you can look up, and some accounts
+ * are magic and undetectable via the security subsystem. See
+ * http://msdn2.microsoft.com/en-us/library/ms684188.aspx
+ */
+ printf("Running on a Post-Win2K OS, so we'll assume that the "
+ "LocalService account exists.\n");
+ }
+ } else if (service_fns.LookupAccountNameA_fn(NULL, // On this system
+ user_acct,
+ NULL, &sidLen, // Don't care about the SID
+ NULL, &domainLen, // Don't care about the domain
+ &sidUse) == 0) {
printf("User \"%s\" doesn't seem to exist.\n", user_acct);
- if (user_acct != GENSRV_USERACCT)
- return -1;
- /* On Win2k, there is no LocalService account, so we actually need to
- * check for it. Yay win2k. */
- printf("Falling back to SYSTEM account.\n");
- user_acct = NULL;
+ return -1;
+ } else {
+ printf("Will try to install service as user \"%s\".\n", user_acct);
}
/* Create the Tor service, set to auto-start on boot */