mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-11-30 15:43:32 +01:00
r11667@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. svn:r9502
This commit is contained in:
parent
f4a1c17e5a
commit
c4faebfa6d
@ -19,7 +19,11 @@ Changes in version 0.1.2.7-alpha - 2007-02-06
|
|||||||
- 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 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):
|
o Major bugfixes (other):
|
||||||
- Previously, we would cache up to 16 old networkstatus documents
|
- Previously, we would cache up to 16 old networkstatus documents
|
||||||
|
@ -86,6 +86,8 @@ int has_completed_circuit=0;
|
|||||||
|
|
||||||
SERVICE_STATUS service_status;
|
SERVICE_STATUS service_status;
|
||||||
SERVICE_STATUS_HANDLE hStatus;
|
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 char **backup_argv;
|
||||||
static int backup_argc;
|
static int backup_argc;
|
||||||
static int nt_service_is_stopped(void);
|
static int nt_service_is_stopped(void);
|
||||||
@ -2086,16 +2088,19 @@ nt_service_stop(SC_HANDLE hService)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** Build a formatted command line used for the NT service. Return a
|
/** Build a formatted command line used for the NT service. Return a
|
||||||
* pointer to the formatted string on success, or NULL on failure. */
|
* pointer to the formatted string on success, or NULL on failure. Set
|
||||||
char *
|
* *<b>using_default_torrc</b> to true if we're going to use the default
|
||||||
nt_service_command_line(void)
|
* 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];
|
TCHAR tor_exe[MAX_PATH+1];
|
||||||
char *command, *options;
|
char *command, *options;
|
||||||
const char *torrc;
|
const char *torrc;
|
||||||
smartlist_t *sl;
|
smartlist_t *sl;
|
||||||
int i, cmdlen;
|
int i, cmdlen;
|
||||||
int use_default_torrc = 1;
|
*using_default_torrc = 1;
|
||||||
|
|
||||||
/* Get the location of tor.exe */
|
/* Get the location of tor.exe */
|
||||||
if (0 == GetModuleFileName(NULL, tor_exe, MAX_PATH))
|
if (0 == GetModuleFileName(NULL, tor_exe, MAX_PATH))
|
||||||
@ -2109,15 +2114,11 @@ nt_service_command_line(void)
|
|||||||
!strcmp(backup_argv[i], "-options")) {
|
!strcmp(backup_argv[i], "-options")) {
|
||||||
while (++i < backup_argc) {
|
while (++i < backup_argc) {
|
||||||
if (!strcmp(backup_argv[i], "-f"))
|
if (!strcmp(backup_argv[i], "-f"))
|
||||||
use_default_torrc = 0;
|
*using_default_torrc = 0;
|
||||||
smartlist_add(sl, backup_argv[i]);
|
smartlist_add(sl, backup_argv[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (use_default_torrc) {
|
|
||||||
smartlist_add(sl, "-f");
|
|
||||||
smartlist_add(sl, (char*)torrc);
|
|
||||||
}
|
|
||||||
tor_assert(smartlist_len(sl));
|
tor_assert(smartlist_len(sl));
|
||||||
options = smartlist_join_strings(sl,"\" \"",0,NULL);
|
options = smartlist_join_strings(sl,"\" \"",0,NULL);
|
||||||
smartlist_free(sl);
|
smartlist_free(sl);
|
||||||
@ -2160,6 +2161,7 @@ nt_service_install(int argc, char **argv)
|
|||||||
SID_NAME_USE sidUse;
|
SID_NAME_USE sidUse;
|
||||||
DWORD sidLen = 0, domainLen = 0;
|
DWORD sidLen = 0, domainLen = 0;
|
||||||
int is_win2k_or_worse = 0;
|
int is_win2k_or_worse = 0;
|
||||||
|
int using_default_torrc = 0;
|
||||||
|
|
||||||
if (nt_service_loadlibrary()<0)
|
if (nt_service_loadlibrary()<0)
|
||||||
return -1;
|
return -1;
|
||||||
@ -2168,7 +2170,7 @@ nt_service_install(int argc, char **argv)
|
|||||||
if ((hSCManager = nt_service_open_scm()) == NULL)
|
if ((hSCManager = nt_service_open_scm()) == NULL)
|
||||||
return -1;
|
return -1;
|
||||||
/* Build the command line used for the service */
|
/* 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");
|
printf("Unable to build service command line.\n");
|
||||||
service_fns.CloseServiceHandle_fn(hSCManager);
|
service_fns.CloseServiceHandle_fn(hSCManager);
|
||||||
return -1;
|
return -1;
|
||||||
@ -2218,6 +2220,14 @@ nt_service_install(int argc, char **argv)
|
|||||||
} else {
|
} else {
|
||||||
printf("Will try to install service as user \"%s\".\n", user_acct);
|
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 */
|
/* Create the Tor service, set to auto-start on boot */
|
||||||
if ((hService = service_fns.CreateServiceA_fn(hSCManager, GENSRV_SERVICENAME,
|
if ((hService = service_fns.CreateServiceA_fn(hSCManager, GENSRV_SERVICENAME,
|
||||||
|
Loading…
Reference in New Issue
Block a user