Mixing the `--unit` and `--user-unit` options will result in error messages.
During the parsing phase, only the `arg_show_unit` record of the last
occurrence of the option is used; all names are placed in the same `arg_names`,
thus mixing the two types of units in the query.
For example, `-u foo --user-unit bar` will also treat `foo` as a user unit and
query it in the user service.
(cherry picked from commit
2b8c7adbecb929f131dc05d8b88babd87cc0ab22)
break;
case 'u':
+ if (arg_show_unit == SHOW_UNIT_USER)
+ return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
+ "Cannot combine --unit with --user-unit.");
+
arg_show_unit = SHOW_UNIT_SYSTEM;
if (strv_push(&arg_names, optarg) < 0) /* push optarg if not empty */
return log_oom();
break;
case ARG_USER_UNIT:
+ if (arg_show_unit == SHOW_UNIT_SYSTEM)
+ return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
+ "Cannot combine --user-unit with --unit.");
+
arg_show_unit = SHOW_UNIT_USER;
if (strv_push(&arg_names, optarg) < 0) /* push optarg if not empty */
return log_oom();