mirror of
https://github.com/systemd/systemd.git
synced 2025-03-10 16:58:28 +03:00
udevadm-control: check if control command really specified
Previously, 'udevadm control' only checked the number of the arguments. So, if only `--timeout` is specified, it spuriously did nothing and succeeded. This makes the command request at least one control command.
This commit is contained in:
parent
6c15a28454
commit
b2800ec597
@ -29,6 +29,17 @@ static int arg_start_exec_queue = -1;
|
||||
|
||||
STATIC_DESTRUCTOR_REGISTER(arg_env, strv_freep);
|
||||
|
||||
static bool arg_has_control_commands(void) {
|
||||
return
|
||||
arg_exit ||
|
||||
arg_log_level >= 0 ||
|
||||
arg_start_exec_queue >= 0 ||
|
||||
arg_reload ||
|
||||
!strv_isempty(arg_env) ||
|
||||
arg_max_children >= 0 ||
|
||||
arg_ping;
|
||||
}
|
||||
|
||||
static int help(void) {
|
||||
printf("%s control OPTION\n\n"
|
||||
"Control the udev daemon.\n\n"
|
||||
@ -76,10 +87,6 @@ static int parse_argv(int argc, char *argv[]) {
|
||||
assert(argc >= 0);
|
||||
assert(argv);
|
||||
|
||||
if (argc <= 1)
|
||||
return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
|
||||
"This command expects one or more options.");
|
||||
|
||||
while ((c = getopt_long(argc, argv, "el:sSRp:m:t:Vh", options, NULL)) >= 0)
|
||||
switch (c) {
|
||||
|
||||
@ -147,6 +154,10 @@ static int parse_argv(int argc, char *argv[]) {
|
||||
assert_not_reached();
|
||||
}
|
||||
|
||||
if (!arg_has_control_commands())
|
||||
return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
|
||||
"No control command option is specified.");
|
||||
|
||||
if (optind < argc)
|
||||
return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
|
||||
"Extraneous argument: %s", argv[optind]);
|
||||
|
@ -45,8 +45,7 @@ udevadm control -S
|
||||
udevadm control -R
|
||||
udevadm control -p HELLO=world
|
||||
udevadm control -m 42
|
||||
udevadm control --ping
|
||||
udevadm control -t 5
|
||||
udevadm control --ping -t 5
|
||||
udevadm control -h
|
||||
|
||||
udevadm info /dev/null
|
||||
|
Loading…
x
Reference in New Issue
Block a user