From: Iain Patterson Date: Mon, 3 Feb 2014 18:40:27 +0000 (+0000) Subject: Don't complain if the service has no ObjectName. X-Git-Tag: v2.22~16 X-Git-Url: http://git.iain.cx/?a=commitdiff_plain;h=28ff40d0bbd3b9ee7b0b5f3235d7972cfa884f2e;p=nssm.git Don't complain if the service has no ObjectName. Not all service types run under an account. --- diff --git a/service.cpp b/service.cpp index ecd1419..fe67262 100644 --- a/service.cpp +++ b/service.cpp @@ -472,17 +472,19 @@ int get_service_username(const TCHAR *service_name, const QUERY_SERVICE_CONFIG * if (! qsc) return 1; - if (is_localsystem(qsc->lpServiceStartName)) return 0; + if (qsc->lpServiceStartName[0]) { + if (is_localsystem(qsc->lpServiceStartName)) return 0; - size_t len = _tcslen(qsc->lpServiceStartName); - *username = (TCHAR *) HeapAlloc(GetProcessHeap(), 0, (len + 1) * sizeof(TCHAR)); - if (! *username) { - print_message(stderr, NSSM_MESSAGE_OUT_OF_MEMORY, _T("username"), _T("get_service_username()")); - return 2; - } + size_t len = _tcslen(qsc->lpServiceStartName); + *username = (TCHAR *) HeapAlloc(GetProcessHeap(), 0, (len + 1) * sizeof(TCHAR)); + if (! *username) { + print_message(stderr, NSSM_MESSAGE_OUT_OF_MEMORY, _T("username"), _T("get_service_username()")); + return 2; + } - memmove(*username, qsc->lpServiceStartName, (len + 1) * sizeof(TCHAR)); - *usernamelen = len; + memmove(*username, qsc->lpServiceStartName, (len + 1) * sizeof(TCHAR)); + *usernamelen = len; + } return 0; }