chiark
/
gitweb
/
~ianmdlvl
/
elogind.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Verify validity of session name when received from outside
[elogind.git]
/
src
/
login
/
logind-inhibit.c
diff --git
a/src/login/logind-inhibit.c
b/src/login/logind-inhibit.c
index f1b9cca834c95eb1b40c68646e5fc45b990d8a5c..e77088364aa5cb352cea667610879782030543d4 100644
(file)
--- a/
src/login/logind-inhibit.c
+++ b/
src/login/logind-inhibit.c
@@
-30,6
+30,7
@@
#include "mkdir.h"
#include "path-util.h"
#include "logind-inhibit.h"
#include "mkdir.h"
#include "path-util.h"
#include "logind-inhibit.h"
+#include "fileio.h"
Inhibitor* inhibitor_new(Manager *m, const char* id) {
Inhibitor *i;
Inhibitor* inhibitor_new(Manager *m, const char* id) {
Inhibitor *i;
@@
-291,7
+292,7
@@
int inhibitor_create_fifo(Inhibitor *i) {
/* Open reading side */
if (i->fifo_fd < 0) {
/* Open reading side */
if (i->fifo_fd < 0) {
- struct epoll_event ev;
+ struct epoll_event ev
= {}
;
i->fifo_fd = open(i->fifo_path, O_RDONLY|O_CLOEXEC|O_NDELAY);
if (i->fifo_fd < 0)
i->fifo_fd = open(i->fifo_path, O_RDONLY|O_CLOEXEC|O_NDELAY);
if (i->fifo_fd < 0)
@@
-301,7
+302,6
@@
int inhibitor_create_fifo(Inhibitor *i) {
if (r < 0)
return r;
if (r < 0)
return r;
- zero(ev);
ev.events = 0;
ev.data.u32 = FD_OTHER_BASE + i->fifo_fd;
ev.events = 0;
ev.data.u32 = FD_OTHER_BASE + i->fifo_fd;
@@
-353,9
+353,14
@@
static int pid_is_active(Manager *m, pid_t pid) {
int r;
r = manager_get_session_by_pid(m, pid, &s);
int r;
r = manager_get_session_by_pid(m, pid, &s);
- if (r <
=
0)
+ if (r < 0)
return r;
return r;
+ /* If there's no session assigned to it, then it's globally
+ * active on all ttys */
+ if (r == 0)
+ return 1;
+
return session_is_active(s);
}
return session_is_active(s);
}
@@
-439,19
+444,19
@@
InhibitWhat inhibit_what_from_string(const char *s) {
size_t l;
FOREACH_WORD_SEPARATOR(w, l, s, ":", state) {
size_t l;
FOREACH_WORD_SEPARATOR(w, l, s, ":", state) {
- if (l == 8 && strn
cmp(w, "shutdown", l) == 0
)
+ if (l == 8 && strn
eq(w, "shutdown", l)
)
what |= INHIBIT_SHUTDOWN;
what |= INHIBIT_SHUTDOWN;
- else if (l == 5 && strn
cmp(w, "sleep", l) == 0
)
+ else if (l == 5 && strn
eq(w, "sleep", l)
)
what |= INHIBIT_SLEEP;
what |= INHIBIT_SLEEP;
- else if (l == 4 && strn
cmp(w, "idle", l) == 0
)
+ else if (l == 4 && strn
eq(w, "idle", l)
)
what |= INHIBIT_IDLE;
what |= INHIBIT_IDLE;
- else if (l == 16 && strn
cmp(w, "handle-power-key", l) == 0
)
+ else if (l == 16 && strn
eq(w, "handle-power-key", l)
)
what |= INHIBIT_HANDLE_POWER_KEY;
what |= INHIBIT_HANDLE_POWER_KEY;
- else if (l == 18 && strn
cmp(w, "handle-suspend-key", l) == 0
)
+ else if (l == 18 && strn
eq(w, "handle-suspend-key", l)
)
what |= INHIBIT_HANDLE_SUSPEND_KEY;
what |= INHIBIT_HANDLE_SUSPEND_KEY;
- else if (l == 20 && strn
cmp(w, "handle-hibernate-key", l) == 0
)
+ else if (l == 20 && strn
eq(w, "handle-hibernate-key", l)
)
what |= INHIBIT_HANDLE_HIBERNATE_KEY;
what |= INHIBIT_HANDLE_HIBERNATE_KEY;
- else if (l == 17 && strn
cmp(w, "handle-lid-switch", l) == 0
)
+ else if (l == 17 && strn
eq(w, "handle-lid-switch", l)
)
what |= INHIBIT_HANDLE_LID_SWITCH;
else
return _INHIBIT_WHAT_INVALID;
what |= INHIBIT_HANDLE_LID_SWITCH;
else
return _INHIBIT_WHAT_INVALID;