diff options
Diffstat (limited to 'src/sleep/sleep.c')
-rw-r--r-- | src/sleep/sleep.c | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/src/sleep/sleep.c b/src/sleep/sleep.c index f104e5dac..890dae7ab 100644 --- a/src/sleep/sleep.c +++ b/src/sleep/sleep.c @@ -149,7 +149,6 @@ static int execute(Manager *m, const char *verb) { streq(arg_verb, "hibernate") ? m->hibernate_state : m->hybrid_sleep_state; #endif // 0 - char *arguments[] = { NULL, (char*) "pre", @@ -242,13 +241,11 @@ static int execute_s2h(Manager *m) { int r; #if 0 /// Already parsed by elogind config - r = parse_sleep_config("suspend", &suspend_modes, &suspend_states, - NULL); + r = parse_sleep_config("suspend", NULL, &suspend_modes, &suspend_states, NULL); if (r < 0) return r; - r = parse_sleep_config("hibernate", &hibernate_modes, - &hibernate_states, NULL); + r = parse_sleep_config("hibernate", NULL, &hibernate_modes, &hibernate_states, NULL); if (r < 0) return r; #endif // 0 @@ -363,6 +360,7 @@ static int parse_argv(int argc, char *argv[]) { } int main(int argc, char *argv[]) { + bool allow; _cleanup_strv_free_ char **modes = NULL, **states = NULL; usec_t delay = 0; int r; @@ -375,10 +373,15 @@ int main(int argc, char *argv[]) { if (r <= 0) goto finish; - r = parse_sleep_config(arg_verb, &modes, &states, &delay); + r = parse_sleep_config(arg_verb, &allow, &modes, &states, &delay); if (r < 0) goto finish; + if (!allow) { + log_error("Sleep mode \"%s\" is disabled by configuration, refusing.", arg_verb); + return EXIT_FAILURE; + } + if (streq(arg_verb, "suspend-then-hibernate")) r = execute_s2h(delay); else |