- if (! str_equiv(additional, NSSM_LOCALSYSTEM_ACCOUNT)) {
- localsystem = false;
- username = (TCHAR *) additional;
- if (value && value->string) password = value->string;
- else {
- /* We need a password if the account is not LOCALSYSTEM. */
- print_message(stderr, NSSM_MESSAGE_MISSING_PASSWORD, name);
- return -1;
- }
+ username = (TCHAR *) additional;
+ if (value && value->string) password = value->string;
+ }
+ else if (value && value->string) username = value->string;
+
+ if (requires_password(username)) {
+ if (! password) {
+ /* We need a password if the account requires it. */
+ print_message(stderr, NSSM_MESSAGE_MISSING_PASSWORD, name);
+ return -1;
+ }
+ }
+ else {
+ password = 0;
+ if (is_localsystem(username)) {
+ localsystem = true;
+ username = NSSM_LOCALSYSTEM_ACCOUNT;
+ }
+ else {
+ canon = canonical_username(username);
+ if (canon) username = canon;