Fixed argument parsing for setting ObjectName.
authorIain Patterson <me@iain.cx>
Tue, 28 Jan 2014 22:42:37 +0000 (22:42 +0000)
committerIain Patterson <me@iain.cx>
Wed, 29 Jan 2014 20:37:33 +0000 (20:37 +0000)
Setting ObjectName needs a username and password, except when it
doesn't.  We can't make the extra argument mandatory because it isn't.

service.cpp
settings.cpp

index 5a732b0..91e726f 100644 (file)
@@ -791,6 +791,10 @@ int pre_edit_service(int argc, TCHAR **argv) {
       additional = argv[3];\r
       remainder = 4;\r
     }\r
+    else if (str_equiv(setting->name, NSSM_NATIVE_OBJECTNAME) && mode == MODE_SETTING) {\r
+      additional = argv[3];\r
+      remainder = 4;\r
+    }\r
     else {\r
       additional = argv[remainder];\r
       if (argc < mandatory) return usage(1);\r
@@ -933,6 +937,9 @@ int pre_edit_service(int argc, TCHAR **argv) {
     /* Unset the parameter. */\r
     value.string = 0;\r
   }\r
+  else if (remainder == argc) {\r
+    value.string = 0;\r
+  }\r
   else {\r
     /* Set the parameter. */\r
     size_t len = 0;\r
index 73b8d0d..e7ec830 100644 (file)
@@ -838,7 +838,7 @@ settings_t settings[] = {
   { NSSM_NATIVE_DESCRIPTION, REG_SZ, _T(""), true, 0, native_set_description, native_get_description },
   { NSSM_NATIVE_DISPLAYNAME, REG_SZ, NULL, true, 0, native_set_displayname, native_get_displayname },
   { NSSM_NATIVE_IMAGEPATH, REG_EXPAND_SZ, NULL, true, 0, native_set_imagepath, native_get_imagepath },
-  { NSSM_NATIVE_OBJECTNAME, REG_SZ, NSSM_LOCALSYSTEM_ACCOUNT, true, ADDITIONAL_SETTING, native_set_objectname, native_get_objectname },
+  { NSSM_NATIVE_OBJECTNAME, REG_SZ, NSSM_LOCALSYSTEM_ACCOUNT, true, 0, native_set_objectname, native_get_objectname },
   { NSSM_NATIVE_NAME, REG_SZ, NULL, true, 0, native_set_name, native_get_name },
   { NSSM_NATIVE_STARTUP, REG_SZ, NULL, true, 0, native_set_startup, native_get_startup },
   { NSSM_NATIVE_TYPE, REG_SZ, NULL, true, 0, native_set_type, native_get_type },