***/
#define VERB_ANY ((unsigned) -1)
-#define VERB_DEFAULT 1U
-#define VERB_NOCHROOT 2U
+
+typedef enum VerbFlags {
+ VERB_DEFAULT = 1 << 0,
+ VERB_NOCHROOT = 1 << 1,
+ VERB_MUSTBEROOT = 1 << 2,
+} VerbFlags;
typedef struct {
const char *verb;
unsigned min_args, max_args;
- unsigned flags;
+ VerbFlags flags;
int (* const dispatch)(int argc, char *argv[], void *userdata);
} Verb;
bool install;
int r;
- r = must_be_root();
- if (r < 0)
- return r;
-
r = acquire_esp(false, &part, &pstart, &psize, &uuid);
if (r < 0)
return r;
sd_id128_t uuid = SD_ID128_NULL;
int r;
- r = must_be_root();
- if (r < 0)
- return r;
-
r = acquire_esp(false, NULL, NULL, NULL, &uuid);
if (r < 0)
return r;
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 },
- { "list", VERB_ANY, 1, 0, verb_list },
- { "install", VERB_ANY, 1, 0, verb_install },
- { "update", VERB_ANY, 1, 0, verb_install },
- { "remove", VERB_ANY, 1, 0, verb_remove },
+ { "help", VERB_ANY, VERB_ANY, 0, help },
+ { "status", VERB_ANY, 1, VERB_DEFAULT, verb_status },
+ { "list", VERB_ANY, 1, 0, verb_list },
+ { "install", VERB_ANY, 1, VERB_MUSTBEROOT, verb_install },
+ { "update", VERB_ANY, 1, VERB_MUSTBEROOT, verb_install },
+ { "remove", VERB_ANY, 1, VERB_MUSTBEROOT, verb_remove },
{}
};
sd_bus *bus;
int r;
- r = must_be_root();
- if (r < 0)
- return r;
-
r = acquire_bus(BUS_MANAGER, &bus);
if (r < 0)
return r;
{ "list-sockets", VERB_ANY, VERB_ANY, VERB_NOCHROOT, list_sockets },
{ "list-timers", VERB_ANY, VERB_ANY, VERB_NOCHROOT, list_timers },
{ "list-jobs", VERB_ANY, VERB_ANY, VERB_NOCHROOT, list_jobs },
- { "list-machines", VERB_ANY, VERB_ANY, VERB_NOCHROOT, list_machines },
+ { "list-machines", VERB_ANY, VERB_ANY, VERB_NOCHROOT|VERB_MUSTBEROOT, list_machines },
{ "clear-jobs", VERB_ANY, 1, VERB_NOCHROOT, trivial_method },
{ "cancel", VERB_ANY, VERB_ANY, VERB_NOCHROOT, cancel_job },
{ "start", 2, VERB_ANY, VERB_NOCHROOT, start_unit },