From 7a9737bc7d8b9879099459dfb96358281b4b3d60 Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Mon, 22 Feb 2021 23:00:46 +0900 Subject: [PATCH] backlight: exit earlier when unknown verb is specified --- src/backlight/backlight.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/backlight/backlight.c b/src/backlight/backlight.c index f3d53d64625..f9e4f83ab96 100644 --- a/src/backlight/backlight.c +++ b/src/backlight/backlight.c @@ -388,6 +388,9 @@ static int run(int argc, char *argv[]) { if (argc != 3) return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "This program requires two arguments."); + if (!STR_IN_SET(argv[1], "load", "save")) + return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "Unknown verb %s.", argv[1]); + umask(0022); r = mkdir_p("/var/lib/systemd/backlight", 0755); @@ -503,7 +506,7 @@ static int run(int argc, char *argv[]) { return log_device_error_errno(device, r, "Failed to write %s: %m", saved); } else - return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "Unknown verb %s.", argv[1]); + assert_not_reached("Unknown verb."); return 0; }