From ded3a403016494a3e01b6de2f4ed14dde78a62b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Fri, 18 Jan 2019 16:46:37 +0100 Subject: bless-boot: drop must_be_root() checks If we lack permissions, we will fail anyway. But by not doing the artifial check, we get more information. For example, on my machine, I see $ build/systemd-bless-boot good Not booted with boot counting in effect. while "Need to be root" is actually untrue, because being root doesn't change the outcome in any way. Letting the operation fail on the actual error makes it easier to do test runs: we *know* the command will fail, but we want to see what the first step would be. Not doing the articial check makes it also easier to do create alternative security arrangements, for example where the directories are mounted with special ownership mode and an otherwise unprivileged user can perform certain operations. --- src/boot/bless-boot.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'src/boot') diff --git a/src/boot/bless-boot.c b/src/boot/bless-boot.c index b5d110f422..f2d033fc40 100644 --- a/src/boot/bless-boot.c +++ b/src/boot/bless-boot.c @@ -480,13 +480,12 @@ exists: } static int run(int argc, char *argv[]) { - static const Verb verbs[] = { - { "help", VERB_ANY, VERB_ANY, 0, help }, - { "status", VERB_ANY, 1, VERB_DEFAULT, verb_status }, - { "good", VERB_ANY, 1, VERB_MUST_BE_ROOT, verb_set }, - { "bad", VERB_ANY, 1, VERB_MUST_BE_ROOT, verb_set }, - { "indeterminate", VERB_ANY, 1, VERB_MUST_BE_ROOT, verb_set }, + { "help", VERB_ANY, VERB_ANY, 0, help }, + { "status", VERB_ANY, 1, VERB_DEFAULT, verb_status }, + { "good", VERB_ANY, 1, 0, verb_set }, + { "bad", VERB_ANY, 1, 0, verb_set }, + { "indeterminate", VERB_ANY, 1, 0, verb_set }, {} }; -- cgit v1.2.3 From 7c3ce8b5a96ef7d377fe3a3b38b547b17f0c7e88 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Fri, 18 Jan 2019 16:53:03 +0100 Subject: bootctl: drop must_be_root() checks The reasoning is the same as in previous cases. We get an error like "Failed to update EFI variable: Operation not permitted" anyway, so the check is not very useful. --- src/boot/bootctl.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) (limited to 'src/boot') diff --git a/src/boot/bootctl.c b/src/boot/bootctl.c index 9df181a10c..9ccf0104c1 100644 --- a/src/boot/bootctl.c +++ b/src/boot/bootctl.c @@ -1430,16 +1430,15 @@ static int verb_set_default(int argc, char *argv[], void *userdata) { } static int bootctl_main(int argc, char *argv[]) { - static const Verb verbs[] = { - { "help", VERB_ANY, VERB_ANY, 0, help }, - { "status", VERB_ANY, 1, VERB_DEFAULT, verb_status }, - { "install", VERB_ANY, 1, VERB_MUST_BE_ROOT, verb_install }, - { "update", VERB_ANY, 1, VERB_MUST_BE_ROOT, verb_install }, - { "remove", VERB_ANY, 1, VERB_MUST_BE_ROOT, verb_remove }, - { "list", VERB_ANY, 1, 0, verb_list }, - { "set-default", 2, 2, VERB_MUST_BE_ROOT, verb_set_default }, - { "set-oneshot", 2, 2, VERB_MUST_BE_ROOT, verb_set_default }, + { "help", VERB_ANY, VERB_ANY, 0, help }, + { "status", VERB_ANY, 1, VERB_DEFAULT, verb_status }, + { "install", VERB_ANY, 1, 0, verb_install }, + { "update", VERB_ANY, 1, 0, verb_install }, + { "remove", VERB_ANY, 1, 0, verb_remove }, + { "list", VERB_ANY, 1, 0, verb_list }, + { "set-default", 2, 2, 0, verb_set_default }, + { "set-oneshot", 2, 2, 0, verb_set_default }, {} }; -- cgit v1.2.3