X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=elogind.git;a=blobdiff_plain;f=src%2Fudev%2Fudevadm-trigger.c;h=d10ca59cca82333d0142e20be4f565f101510e16;hp=4d96a786c3950b92517b12b8724274928dc06535;hb=3fa5dd6de798e17d93531bc900b8e2dc587c38f3;hpb=d5a89d7dc17a5ba5cf4fc71f82963c5c94a31c3d diff --git a/src/udev/udevadm-trigger.c b/src/udev/udevadm-trigger.c index 4d96a786c..d10ca59cc 100644 --- a/src/udev/udevadm-trigger.c +++ b/src/udev/udevadm-trigger.c @@ -32,6 +32,7 @@ #include #include "udev.h" +#include "util.h" static int verbose; static int dry_run; @@ -111,8 +112,14 @@ static int adm_trigger(struct udev *udev, int argc, char *argv[]) char buf[UTIL_PATH_SIZE]; option = getopt_long(argc, argv, "vng:o:t:hc:p:s:S:a:A:y:b:", options, NULL); - if (option == -1) + if (option == -1) { + if (optind < argc) { + fprintf(stderr, "Extraneous argument: '%s'\n", argv[optind]); + rc = 1; + goto exit; + } break; + } switch (option) { case 'v': @@ -122,9 +129,9 @@ static int adm_trigger(struct udev *udev, int argc, char *argv[]) dry_run = 1; break; case 't': - if (strcmp(optarg, "devices") == 0) { + if (streq(optarg, "devices")) { device_type = TYPE_DEVICES; - } else if (strcmp(optarg, "subsystems") == 0) { + } else if (streq(optarg, "subsystems")) { device_type = TYPE_SUBSYSTEMS; } else { log_error("unknown type --type=%s\n", optarg); @@ -133,7 +140,13 @@ static int adm_trigger(struct udev *udev, int argc, char *argv[]) } break; case 'c': - action = optarg; + if (!nulstr_contains("add\0" "remove\0" "change\0", optarg)) { + log_error("unknown action '%s'\n", optarg); + rc = 2; + goto exit; + } else { + action = optarg; + } break; case 's': udev_enumerate_add_match_subsystem(udev_enumerate, optarg); @@ -214,7 +227,7 @@ static int adm_trigger(struct udev *udev, int argc, char *argv[]) exec_list(udev_enumerate, action); goto exit; default: - goto exit; + assert_not_reached("device_type"); } exit: udev_enumerate_unref(udev_enumerate);