Browse Source

Don't complain if the service has no ObjectName.

Not all service types run under an account.
Iain Patterson 8 years ago
parent
commit
28ff40d0bb
1 changed files with 11 additions and 9 deletions
  1. 11 9
      service.cpp

+ 11 - 9
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;
 }