X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=src%2Flogin%2Flogind-inhibit.c;h=f1b9cca834c95eb1b40c68646e5fc45b990d8a5c;hb=90527fbb2c48ffda5c6d8f232f8993a90b2632a4;hp=fce2f4dd907a99725ae8b14afaef7d9eeb4fde01;hpb=f981b9c5be32a199bce6335196d986f5b7e45ba6;p=elogind.git diff --git a/src/login/logind-inhibit.c b/src/login/logind-inhibit.c index fce2f4dd9..f1b9cca83 100644 --- a/src/login/logind-inhibit.c +++ b/src/login/logind-inhibit.c @@ -364,7 +364,9 @@ bool manager_is_inhibited( InhibitWhat w, InhibitMode mm, dual_timestamp *since, - bool only_active) { + bool ignore_inactive, + bool ignore_uid, + uid_t uid) { Inhibitor *i; Iterator j; @@ -381,7 +383,10 @@ bool manager_is_inhibited( if (i->mode != mm) continue; - if (only_active && pid_is_active(m, i->pid) <= 0) + if (ignore_inactive && pid_is_active(m, i->pid) <= 0) + continue; + + if (ignore_uid && i->uid == uid) continue; if (!inhibited || @@ -398,7 +403,7 @@ bool manager_is_inhibited( } const char *inhibit_what_to_string(InhibitWhat w) { - static __thread char buffer[73]; + static __thread char buffer[97]; char *p; if (w < 0 || w >= _INHIBIT_WHAT_MAX) @@ -413,8 +418,10 @@ const char *inhibit_what_to_string(InhibitWhat w) { p = stpcpy(p, "idle:"); if (w & INHIBIT_HANDLE_POWER_KEY) p = stpcpy(p, "handle-power-key:"); - if (w & INHIBIT_HANDLE_SLEEP_KEY) - p = stpcpy(p, "handle-sleep-key:"); + if (w & INHIBIT_HANDLE_SUSPEND_KEY) + p = stpcpy(p, "handle-suspend-key:"); + if (w & INHIBIT_HANDLE_HIBERNATE_KEY) + p = stpcpy(p, "handle-hibernate-key:"); if (w & INHIBIT_HANDLE_LID_SWITCH) p = stpcpy(p, "handle-lid-switch:"); @@ -440,8 +447,10 @@ InhibitWhat inhibit_what_from_string(const char *s) { what |= INHIBIT_IDLE; else if (l == 16 && strncmp(w, "handle-power-key", l) == 0) what |= INHIBIT_HANDLE_POWER_KEY; - else if (l == 16 && strncmp(w, "handle-sleep-key", l) == 0) - what |= INHIBIT_HANDLE_SLEEP_KEY; + else if (l == 18 && strncmp(w, "handle-suspend-key", l) == 0) + what |= INHIBIT_HANDLE_SUSPEND_KEY; + else if (l == 20 && strncmp(w, "handle-hibernate-key", l) == 0) + what |= INHIBIT_HANDLE_HIBERNATE_KEY; else if (l == 17 && strncmp(w, "handle-lid-switch", l) == 0) what |= INHIBIT_HANDLE_LID_SWITCH; else