X-Git-Url: http://git.iain.cx/?a=blobdiff_plain;f=settings.cpp;h=e72430fdeaead32a9fd6951a6eb0edf0ad2be9cb;hb=62f28c55d444d846579159133dbe091809a2c08b;hp=f7346cbdd036b8d6d4833ce435782824995a84b0;hpb=7bc41a82f696699aface2103f277e7ebf1808b2f;p=nssm.git diff --git a/settings.cpp b/settings.cpp index f7346cb..e72430f 100644 --- a/settings.cpp +++ b/settings.cpp @@ -1074,6 +1074,7 @@ int native_set_objectname(const TCHAR *service_name, void *param, const TCHAR *n That means the username is actually passed in the additional parameter. */ bool localsystem = false; + bool virtual_account = false; TCHAR *username = NSSM_LOCALSYSTEM_ACCOUNT; TCHAR *password = 0; if (additional) { @@ -1089,6 +1090,7 @@ int native_set_objectname(const TCHAR *service_name, void *param, const TCHAR *n username = (TCHAR *) well_known; password = _T(""); } + else if (is_virtual_account(service_name, username)) virtual_account = true; else if (! password) { /* We need a password if the account requires it. */ print_message(stderr, NSSM_MESSAGE_MISSING_PASSWORD, name); @@ -1112,7 +1114,7 @@ int native_set_objectname(const TCHAR *service_name, void *param, const TCHAR *n HeapFree(GetProcessHeap(), 0, qsc); } - if (! well_known) { + if (! well_known && ! virtual_account) { if (grant_logon_as_service(username)) { if (passwordsize) SecureZeroMemory(password, passwordsize); print_message(stderr, NSSM_MESSAGE_GRANT_LOGON_AS_SERVICE_FAILED, username); @@ -1150,12 +1152,21 @@ int native_dump_objectname(const TCHAR *service_name, void *param, const TCHAR * int ret = native_get_objectname(service_name, param, name, default_value, value, additional); if (ret != 1) return ret; - /* Do we need to dump a dummy password? */ - if (! well_known_username(value->string)) { - /* Parameters are the other way round. */ - value_t inverted; - inverted.string = _T("****"); - return setting_dump_string(service_name, (void *) REG_SZ, name, &inverted, value->string); + /* Properly checking for a virtual account requires the actual service name. */ + if (! _tcsnicmp(NSSM_VIRTUAL_SERVICE_ACCOUNT_DOMAIN, value->string, _tcslen(NSSM_VIRTUAL_SERVICE_ACCOUNT_DOMAIN))) { + TCHAR *name = virtual_account(service_name); + if (! name) return -1; + HeapFree(GetProcessHeap(), 0, value->string); + value->string = name; + } + else { + /* Do we need to dump a dummy password? */ + if (! well_known_username(value->string)) { + /* Parameters are the other way round. */ + value_t inverted; + inverted.string = _T("****"); + return setting_dump_string(service_name, (void *) REG_SZ, name, &inverted, value->string); + } } return setting_dump_string(service_name, (void *) REG_SZ, name, value, 0); } @@ -1424,6 +1435,7 @@ settings_t settings[] = { { NSSM_REG_ROTATE_BYTES_LOW, REG_DWORD, 0, false, 0, setting_set_number, setting_get_number, 0 }, { NSSM_REG_ROTATE_BYTES_HIGH, REG_DWORD, 0, false, 0, setting_set_number, setting_get_number, 0 }, { NSSM_REG_ROTATE_DELAY, REG_DWORD, (void *) NSSM_ROTATE_DELAY, false, 0, setting_set_number, setting_get_number, 0 }, + { NSSM_REG_TIMESTAMP_LOG, REG_DWORD, 0, false, 0, setting_set_number, setting_get_number, 0 }, { NSSM_NATIVE_DEPENDONGROUP, REG_MULTI_SZ, NULL, true, ADDITIONAL_CRLF, native_set_dependongroup, native_get_dependongroup, native_dump_dependongroup }, { NSSM_NATIVE_DEPENDONSERVICE, REG_MULTI_SZ, NULL, true, ADDITIONAL_CRLF, native_set_dependonservice, native_get_dependonservice, native_dump_dependonservice }, { NSSM_NATIVE_DESCRIPTION, REG_SZ, _T(""), true, 0, native_set_description, native_get_description, 0 },