From 2de6b06b272b2b89035c67d879f330e3c70ba6b3 Mon Sep 17 00:00:00 2001 From: Douglas Christman Date: Tue, 27 Feb 2018 20:16:26 -0500 Subject: [PATCH 1/5] journalctl: make journalctl -g work as documented Add "g" to optstring so both "--grep" and "-g" work with journalctl --- src/journal/journalctl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/journal/journalctl.c b/src/journal/journalctl.c index 02715142e9..e0ad0e1d11 100644 --- a/src/journal/journalctl.c +++ b/src/journal/journalctl.c @@ -494,7 +494,7 @@ static int parse_argv(int argc, char *argv[]) { assert(argc >= 0); assert(argv); - while ((c = getopt_long(argc, argv, "hefo:aln::qmb::kD:p:c:S:U:t:u:NF:xrM:", options, NULL)) >= 0) + while ((c = getopt_long(argc, argv, "hefo:aln::qmb::kD:p:g:c:S:U:t:u:NF:xrM:", options, NULL)) >= 0) switch (c) { From 68da321f6687235fc11ba963d0a19701d47f1261 Mon Sep 17 00:00:00 2001 From: Douglas Christman Date: Tue, 27 Feb 2018 20:19:55 -0500 Subject: [PATCH 2/5] systemctl: remove redundant option parsing code "-f" used to be overloaded to mean both "--force" and "--follow"; aae9a96d removed "--follow", leaving behind some duplicate code. --- src/systemctl/systemctl.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/src/systemctl/systemctl.c b/src/systemctl/systemctl.c index 3e5c785660..e8b77d2b0b 100644 --- a/src/systemctl/systemctl.c +++ b/src/systemctl/systemctl.c @@ -7488,7 +7488,6 @@ static int systemctl_parse_argv(int argc, char *argv[]) { ARG_NO_ASK_PASSWORD, ARG_FAILED, ARG_RUNTIME, - ARG_FORCE, ARG_PLAIN, ARG_STATE, ARG_JOB_MODE, @@ -7528,7 +7527,7 @@ static int systemctl_parse_argv(int argc, char *argv[]) { { "dry-run", no_argument, NULL, ARG_DRY_RUN }, { "quiet", no_argument, NULL, 'q' }, { "root", required_argument, NULL, ARG_ROOT }, - { "force", no_argument, NULL, ARG_FORCE }, + { "force", no_argument, NULL, 'f' }, { "no-reload", no_argument, NULL, ARG_NO_RELOAD }, { "kill-who", required_argument, NULL, ARG_KILL_WHO }, { "signal", required_argument, NULL, 's' }, @@ -7743,10 +7742,6 @@ static int systemctl_parse_argv(int argc, char *argv[]) { arg_quiet = true; break; - case ARG_FORCE: - arg_force++; - break; - case 'f': arg_force++; break; From 63547675a4bd5872b07cb6149dd93627fa21932d Mon Sep 17 00:00:00 2001 From: Douglas Christman Date: Tue, 27 Feb 2018 20:28:50 -0500 Subject: [PATCH 3/5] test-libudev: make "-m" equivalent to "--monitor" "-m" is specified as a short form of "--monitor" in the option struct, but not included in getopt_long's optstring. Update the optstring to be consistent with the option struct. --- src/test/test-libudev.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/test-libudev.c b/src/test/test-libudev.c index 408d14133b..f748fbc878 100644 --- a/src/test/test-libudev.c +++ b/src/test/test-libudev.c @@ -372,7 +372,7 @@ int main(int argc, char *argv[]) { return 1; } - while ((c = getopt_long(argc, argv, "p:s:dhV", options, NULL)) >= 0) + while ((c = getopt_long(argc, argv, "p:s:dhVm", options, NULL)) >= 0) switch (c) { case 'p': From 3a6a6889e1b2cc1495a5969e98d1b4d629730f13 Mon Sep 17 00:00:00 2001 From: Douglas Christman Date: Thu, 1 Mar 2018 08:31:32 +0800 Subject: [PATCH 4/5] analyze: fix typo in error message --- src/analyze/analyze.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/analyze/analyze.c b/src/analyze/analyze.c index 1aa8c00512..092ff763ba 100644 --- a/src/analyze/analyze.c +++ b/src/analyze/analyze.c @@ -1515,7 +1515,7 @@ static int test_calendar(int argc, char *argv[], void *userdata) { r = calendar_spec_to_string(spec, &t); if (r < 0) { - ret = log_error_errno(r, "Failed to fomat calendar specification '%s': %m", *p); + ret = log_error_errno(r, "Failed to format calendar specification '%s': %m", *p); continue; } From 6c1a6df3752f9df0780dee29b829dd91c0802f34 Mon Sep 17 00:00:00 2001 From: Douglas Christman Date: Tue, 27 Feb 2018 20:35:58 -0500 Subject: [PATCH 5/5] udevadm: prevent segfault in blkid builtin when offset not specified "--offset" takes an optional argument; if none is specified, stroull() will attempt to parse a NULL pointer. For example: $ udevadm test-builtin 'blkid --offset' /sys/dev/block/8:1 Update "--offset" to require an argument; also verify that the offset is not negative. --- src/udev/udev-builtin-blkid.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/udev/udev-builtin-blkid.c b/src/udev/udev-builtin-blkid.c index 6ff244e96c..eeed803f57 100644 --- a/src/udev/udev-builtin-blkid.c +++ b/src/udev/udev-builtin-blkid.c @@ -35,6 +35,7 @@ #include "efivars.h" #include "fd-util.h" #include "gpt.h" +#include "parse-util.h" #include "string-util.h" #include "udev.h" @@ -236,7 +237,7 @@ static int builtin_blkid(struct udev_device *dev, int argc, char *argv[], bool t bool is_gpt = false; static const struct option options[] = { - { "offset", optional_argument, NULL, 'o' }, + { "offset", required_argument, NULL, 'o' }, { "noraid", no_argument, NULL, 'R' }, {} }; @@ -244,13 +245,19 @@ static int builtin_blkid(struct udev_device *dev, int argc, char *argv[], bool t for (;;) { int option; - option = getopt_long(argc, argv, "oR", options, NULL); + option = getopt_long(argc, argv, "o:R", options, NULL); if (option == -1) break; switch (option) { case 'o': - offset = strtoull(optarg, NULL, 0); + err = safe_atoi64(optarg, &offset); + if (err < 0) + goto out; + if (offset < 0) { + err = -ERANGE; + goto out; + } break; case 'R': noraid = true;