chiark
/
gitweb
/
~ianmdlvl
/
elogind.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
login: check return of parse_pid and parse_uid
[elogind.git]
/
src
/
login
/
logind-inhibit.c
diff --git
a/src/login/logind-inhibit.c
b/src/login/logind-inhibit.c
index e4eefd0def4af912054a0fce8cd35fd972c6e1a0..60b6237ce5e71b3604bbee4b528a74cfa2956992 100644
(file)
--- a/
src/login/logind-inhibit.c
+++ b/
src/login/logind-inhibit.c
@@
-28,7
+28,7
@@
#include "util.h"
#include "mkdir.h"
#include "util.h"
#include "mkdir.h"
-
+#include "path-util.h"
#include "logind-inhibit.h"
Inhibitor* inhibitor_new(Manager *m, const char* id) {
#include "logind-inhibit.h"
Inhibitor* inhibitor_new(Manager *m, const char* id) {
@@
-46,7
+46,7
@@
Inhibitor* inhibitor_new(Manager *m, const char* id) {
return NULL;
}
return NULL;
}
- i->id =
file_name_from_path
(i->state_file);
+ i->id =
path_get_file_name
(i->state_file);
if (hashmap_put(m->inhibitors, i->id, i) < 0) {
free(i->state_file);
if (hashmap_put(m->inhibitors, i->id, i) < 0) {
free(i->state_file);
@@
-84,7
+84,7
@@
int inhibitor_save(Inhibitor *i) {
assert(i);
assert(i);
- r =
safe_mkdir
("/run/systemd/inhibit", 0755, 0, 0);
+ r =
mkdir_safe_label
("/run/systemd/inhibit", 0755, 0, 0);
if (r < 0)
goto finish;
if (r < 0)
goto finish;
@@
-163,7
+163,7
@@
int inhibitor_start(Inhibitor *i) {
i->started = true;
i->started = true;
- manager_send_changed(i->manager,
"
Inhibited\0");
+ manager_send_changed(i->manager,
i->mode == INHIBIT_BLOCK ? "BlockInhibited\0" : "Delay
Inhibited\0");
return 0;
}
return 0;
}
@@
-182,7
+182,7
@@
int inhibitor_stop(Inhibitor *i) {
i->started = false;
i->started = false;
- manager_send_changed(i->manager,
"
Inhibited\0");
+ manager_send_changed(i->manager,
i->mode == INHIBIT_BLOCK ? "BlockInhibited\0" : "Delay
Inhibited\0");
return 0;
}
return 0;
}
@@
-219,11
+219,17
@@
int inhibitor_load(Inhibitor *i) {
if (mm >= 0)
i->mode = mm;
if (mm >= 0)
i->mode = mm;
- if (uid)
- parse_uid(uid, &i->uid);
+ if (uid) {
+ r = parse_uid(uid, &i->uid);
+ if (r < 0)
+ goto finish;
+ }
- if (pid)
- parse_pid(pid, &i->pid);
+ if (pid) {
+ r = parse_pid(pid, &i->pid);
+ if (r < 0)
+ goto finish;
+ }
if (who) {
cc = cunescape(who);
if (who) {
cc = cunescape(who);
@@
-272,7
+278,7
@@
int inhibitor_create_fifo(Inhibitor *i) {
/* Create FIFO */
if (!i->fifo_path) {
/* Create FIFO */
if (!i->fifo_path) {
- r =
safe_mkdir
("/run/systemd/inhibit", 0755, 0, 0);
+ r =
mkdir_safe_label
("/run/systemd/inhibit", 0755, 0, 0);
if (r < 0)
return r;
if (r < 0)
return r;
@@
-297,7
+303,7
@@
int inhibitor_create_fifo(Inhibitor *i) {
zero(ev);
ev.events = 0;
zero(ev);
ev.events = 0;
- ev.data.u32 = FD_
FIFO
_BASE + i->fifo_fd;
+ ev.data.u32 = FD_
OTHER
_BASE + i->fifo_fd;
if (epoll_ctl(i->manager->epoll_fd, EPOLL_CTL_ADD, i->fifo_fd, &ev) < 0)
return -errno;
if (epoll_ctl(i->manager->epoll_fd, EPOLL_CTL_ADD, i->fifo_fd, &ev) < 0)
return -errno;
@@
-376,12
+382,12
@@
const char *inhibit_what_to_string(InhibitWhat w) {
static const char* const table[_INHIBIT_WHAT_MAX] = {
[0] = "",
[INHIBIT_SHUTDOWN] = "shutdown",
static const char* const table[_INHIBIT_WHAT_MAX] = {
[0] = "",
[INHIBIT_SHUTDOWN] = "shutdown",
- [INHIBIT_S
USPEND] = "suspend
",
+ [INHIBIT_S
LEEP] = "sleep
",
[INHIBIT_IDLE] = "idle",
[INHIBIT_IDLE] = "idle",
- [INHIBIT_SHUTDOWN|INHIBIT_S
USPEND] = "shutdown:suspend
",
+ [INHIBIT_SHUTDOWN|INHIBIT_S
LEEP] = "shutdown:sleep
",
[INHIBIT_SHUTDOWN|INHIBIT_IDLE] = "shutdown:idle",
[INHIBIT_SHUTDOWN|INHIBIT_IDLE] = "shutdown:idle",
- [INHIBIT_SHUTDOWN|INHIBIT_S
USPEND|INHIBIT_IDLE] = "shutdown:suspend
:idle",
- [INHIBIT_S
USPEND|INHIBIT_IDLE] = "suspend
:idle"
+ [INHIBIT_SHUTDOWN|INHIBIT_S
LEEP|INHIBIT_IDLE] = "shutdown:sleep
:idle",
+ [INHIBIT_S
LEEP|INHIBIT_IDLE] = "sleep
:idle"
};
if (w < 0 || w >= _INHIBIT_WHAT_MAX)
};
if (w < 0 || w >= _INHIBIT_WHAT_MAX)
@@
-398,8
+404,8
@@
InhibitWhat inhibit_what_from_string(const char *s) {
FOREACH_WORD_SEPARATOR(w, l, s, ":", state) {
if (l == 8 && strncmp(w, "shutdown", l) == 0)
what |= INHIBIT_SHUTDOWN;
FOREACH_WORD_SEPARATOR(w, l, s, ":", state) {
if (l == 8 && strncmp(w, "shutdown", l) == 0)
what |= INHIBIT_SHUTDOWN;
- else if (l ==
7 && strncmp(w, "suspend
", l) == 0)
- what |= INHIBIT_S
USPEND
;
+ else if (l ==
5 && strncmp(w, "sleep
", l) == 0)
+ what |= INHIBIT_S
LEEP
;
else if (l == 4 && strncmp(w, "idle", l) == 0)
what |= INHIBIT_IDLE;
else
else if (l == 4 && strncmp(w, "idle", l) == 0)
what |= INHIBIT_IDLE;
else