[or-cvs] r9486: Fix bug 254, sort of: make the default NT service user Netwo (in tor/trunk: . src/or)
nickm at seul.org
nickm at seul.org
Mon Feb 5 20:45:07 UTC 2007
Author: nickm
Date: 2007-02-05 15:45:02 -0500 (Mon, 05 Feb 2007)
New Revision: 9486
Modified:
tor/trunk/
tor/trunk/ChangeLog
tor/trunk/src/or/main.c
Log:
r11643 at catbus: nickm | 2007-02-05 15:44:59 -0500
Fix bug 254, sort of: make the default NT service user NetworkService rather than NULL (system). Also, add a --user argument to --service install so that admins can override this default: this latter point should take care of most of my objections to NetworkService. I have no idea whether this even compiles.
Property changes on: tor/trunk
___________________________________________________________________
svk:merge ticket from /tor/trunk [r11643] on 8246c3cf-6607-4228-993b-4d95d33730f1
Modified: tor/trunk/ChangeLog
===================================================================
--- tor/trunk/ChangeLog 2007-02-05 19:51:19 UTC (rev 9485)
+++ tor/trunk/ChangeLog 2007-02-05 20:45:02 UTC (rev 9486)
@@ -13,6 +13,12 @@
writing to them, so we avoid queueing 4+ megabytes of data before
trying to flush.
+ o Major bugfixes (NT services):
+ - Install as NT_AUTHORITY\NetworkService 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.
+
o Major bugfixes (other):
- Fix a crash bug in the presence of DNS hijacking (reported by Andrew
Del Vecchio).
Modified: tor/trunk/src/or/main.c
===================================================================
--- tor/trunk/src/or/main.c 2007-02-05 19:51:19 UTC (rev 9485)
+++ tor/trunk/src/or/main.c 2007-02-05 20:45:02 UTC (rev 9486)
@@ -77,6 +77,7 @@
#define GENSRV_DISPLAYNAME TEXT("Tor Win32 Service")
#define GENSRV_DESCRIPTION \
TEXT("Provides an anonymous Internet communication system")
+#define GENSRV_USERACCT TEXT("NT AUTHORITY\\NetworkService")
// Cheating: using the pre-defined error codes, tricks Windows into displaying
// a semi-related human-readable error message if startup fails as
@@ -2128,7 +2129,7 @@
* started if installation succeeds. Returns 0 on success, or -1 on
* failure. */
int
-nt_service_install(void)
+nt_service_install(int argc, char **argv)
{
/* Notes about developing NT services:
*
@@ -2143,7 +2144,8 @@
SERVICE_DESCRIPTION sdBuff;
char *command;
char *errmsg;
- int len = 0;
+ const char *user_acct = GENSRV_USERACCT;
+ int i;
if (nt_service_loadlibrary()<0)
return -1;
@@ -2157,6 +2159,12 @@
service_fns.CloseServiceHandle_fn(hSCManager);
return -1;
}
+ for (i=1; i < argc, ++i) {
+ if (!strcmp(i, "--user") && i+1<argc) {
+ user_acct = argv[i+1];
+ ++i;
+ }
+ }
/* Create the Tor service, set to auto-start on boot */
if ((hService = service_fns.CreateServiceA_fn(hSCManager, GENSRV_SERVICENAME,
@@ -2164,7 +2172,7 @@
SERVICE_ALL_ACCESS, SERVICE_WIN32_OWN_PROCESS,
SERVICE_AUTO_START, SERVICE_ERROR_IGNORE,
command,
- NULL, NULL, NULL, NULL, "")) == NULL) {
+ NULL, NULL, NULL, user_acct, "")) == NULL) {
errmsg = nt_strerror(GetLastError());
printf("CreateService() failed : %s\n", errmsg);
service_fns.CloseServiceHandle_fn(hSCManager);
@@ -2314,7 +2322,7 @@
return -1;
}
if (!strcmp(argv[2], "install"))
- return nt_service_install();
+ return nt_service_install(argc, argv);
if (!strcmp(argv[2], "remove"))
return nt_service_remove();
if (!strcmp(argv[2], "start"))
@@ -2324,20 +2332,29 @@
printf("Unrecognized service command '%s'\n", argv[2]);
return -1;
}
- // These are left so as not to confuse people who are used to these options
if (argc >= 2) {
if (nt_service_loadlibrary() < 0) {
printf("Unable to load library support for NT services.\n");
return -1;
}
- if (!strcmp(argv[1], "-install") || !strcmp(argv[1], "--install"))
- return nt_service_install();
- if (!strcmp(argv[1], "-remove") || !strcmp(argv[1], "--remove"))
- return nt_service_remove();
if (!strcmp(argv[1], "-nt-service") || !strcmp(argv[1], "--nt-service")) {
nt_service_main();
return 0;
}
+ // These values have been deprecated since 0.1.1.2-alpha; we've warned
+ // about them since 0.1.2.7-alpha.
+ if (!strcmp(argv[1], "-install") || !strcmp(argv[1], "--install")) {
+ fprintf(stderr,
+ "The %s option is deprecated; use \"--service install\" instead.",
+ argv[1]);
+ return nt_service_install();
+ }
+ if (!strcmp(argv[1], "-remove") || !strcmp(argv[1], "--remove")) {
+ fprintf(stderr,
+ "The %s option is deprecated; use \"--service remove\" instead.",
+ argv[1]);
+ return nt_service_remove();
+ }
}
#endif
if (tor_init(argc, argv)<0)
More information about the tor-commits
mailing list