X-Git-Url: http://git.iain.cx/?a=blobdiff_plain;f=gui.cpp;h=9f6f9bab947daa86f5ec875bc41300e2cabe3c97;hb=cca8d28295ce27b7c996b47badc6a1e3a6a34e65;hp=888ef025c737772c9821f154db4c60684c9a841e;hpb=3097c59e0683e3ff5c4fe27cbf1cf1f901909da7;p=nssm.git diff --git a/gui.cpp b/gui.cpp index 888ef02..9f6f9ba 100644 --- a/gui.cpp +++ b/gui.cpp @@ -367,13 +367,33 @@ int configure(HWND window, nssm_service_t *service, nssm_service_t *orig_service } /* - Special case LOCALSYSTEM. + Special case for well-known accounts. Ignore the password if we're editing and the username hasn't changed. */ - if (str_equiv(service->username, NSSM_LOCALSYSTEM_ACCOUNT)) { - HeapFree(GetProcessHeap(), 0, service->username); - service->username = 0; - service->usernamelen = 0; + if (! requires_password(service->username)) { + if (is_localsystem(service->username)) { + HeapFree(GetProcessHeap(), 0, service->username); + service->username = 0; + service->usernamelen = 0; + } + else { + TCHAR *canon = canonical_username(service->username); + HeapFree(GetProcessHeap(), 0, service->username); + service->username = 0; + service->usernamelen = 0; + if (canon) { + service->usernamelen = _tcslen(canon) + 1; + service->username = (TCHAR *) HeapAlloc(GetProcessHeap(), 0, service->usernamelen * sizeof(TCHAR)); + if (! service->username) { + LocalFree(canon); + print_message(stderr, NSSM_MESSAGE_OUT_OF_MEMORY, _T("canon"), _T("install()")); + return 6; + } + memmove(service->username, canon, service->usernamelen * sizeof(TCHAR)); + LocalFree(canon); + } + else return 6; + } } else { /* Password. */