X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=src%2Flibelogind%2Fsd-login%2Fsd-login.c;h=9d096841430be92e5af2ba785e47fd504a1d2c6e;hb=036174b578f4c18fd2fefb9f5d87791ea2e01b5d;hp=671700b5e8e051843b5c6cc48762ca6c0dd76d2a;hpb=da4b83e77bc603745cf4a365d7f013301ef7fa89;p=elogind.git diff --git a/src/libelogind/sd-login/sd-login.c b/src/libelogind/sd-login/sd-login.c index 671700b5e..9d0968414 100644 --- a/src/libelogind/sd-login/sd-login.c +++ b/src/libelogind/sd-login/sd-login.c @@ -1,5 +1,3 @@ -/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/ - /*** This file is part of systemd. @@ -33,7 +31,7 @@ #include "escape.h" #include "fd-util.h" #include "fileio.h" -#include "formats-util.h" +#include "format-util.h" #include "fs-util.h" #include "hostname-util.h" #include "io-util.h" @@ -70,8 +68,7 @@ _public_ int sd_pid_get_unit(pid_t pid, char **unit) { assert_return(pid >= 0, -EINVAL); assert_return(unit, -EINVAL); -/// elogind does not support systemd units -#if 0 +#if 0 /// elogind does not support systemd units return cg_pid_get_unit(pid, unit); #else return -ESRCH; @@ -83,8 +80,7 @@ _public_ int sd_pid_get_user_unit(pid_t pid, char **unit) { assert_return(pid >= 0, -EINVAL); assert_return(unit, -EINVAL); -/// elogind does not support systemd units -#if 0 +#if 0 /// elogind does not support systemd units return cg_pid_get_user_unit(pid, unit); #else return -ESRCH; @@ -96,8 +92,7 @@ _public_ int sd_pid_get_machine_name(pid_t pid, char **name) { assert_return(pid >= 0, -EINVAL); assert_return(name, -EINVAL); -/// elogind does not support systemd units -#if 0 +#if 0 /// elogind does not support systemd units return cg_pid_get_machine_name(pid, name); #else return -ESRCH; @@ -109,8 +104,7 @@ _public_ int sd_pid_get_slice(pid_t pid, char **slice) { assert_return(pid >= 0, -EINVAL); assert_return(slice, -EINVAL); -/// elogind does not support systemd slices -#if 0 +#if 0 /// elogind does not support systemd slices return cg_pid_get_slice(pid, slice); #else return -ESRCH; @@ -122,8 +116,7 @@ _public_ int sd_pid_get_user_slice(pid_t pid, char **slice) { assert_return(pid >= 0, -EINVAL); assert_return(slice, -EINVAL); -/// elogind does not support systemd slices -#if 0 +#if 0 /// elogind does not support systemd slices return cg_pid_get_user_slice(pid, slice); #else return -ESRCH; @@ -135,8 +128,7 @@ _public_ int sd_pid_get_owner_uid(pid_t pid, uid_t *uid) { assert_return(pid >= 0, -EINVAL); assert_return(uid, -EINVAL); -/// elogind does not support systemd slices -#if 0 +#if 0 /// elogind does not support systemd slices return cg_pid_get_owner_uid(pid, uid); #else return -ESRCH; @@ -156,7 +148,7 @@ _public_ int sd_pid_get_cgroup(pid_t pid, char **cgroup) { /* The internal APIs return the empty string for the root * cgroup, let's return the "/" in the public APIs instead, as - * that's easier and less ambigious for people to grok. */ + * that's easier and less ambiguous for people to grok. */ if (isempty(c)) { free(c); c = strdup("/"); @@ -180,8 +172,7 @@ _public_ int sd_peer_get_session(int fd, char **session) { if (r < 0) return r; -/// elogind does not support systemd scopes -#if 0 +#if 0 /// elogind does not support systemd scopes return cg_pid_get_session(ucred.pid, session); #else return -ESRCH; @@ -199,8 +190,7 @@ _public_ int sd_peer_get_owner_uid(int fd, uid_t *uid) { if (r < 0) return r; -/// elogind does not support systemd units -#if 0 +#if 0 /// elogind does not support systemd units return cg_pid_get_owner_uid(ucred.pid, uid); #else return -ESRCH; @@ -218,8 +208,7 @@ _public_ int sd_peer_get_unit(int fd, char **unit) { if (r < 0) return r; -/// elogind does not support systemd units -#if 0 +#if 0 /// elogind does not support systemd units return cg_pid_get_unit(ucred.pid, unit); #else return -ESRCH; @@ -237,8 +226,7 @@ _public_ int sd_peer_get_user_unit(int fd, char **unit) { if (r < 0) return r; -/// elogind does not support systemd units -#if 0 +#if 0 /// elogind does not support systemd units return cg_pid_get_user_unit(ucred.pid, unit); #else return -ESRCH; @@ -256,8 +244,7 @@ _public_ int sd_peer_get_machine_name(int fd, char **machine) { if (r < 0) return r; -/// elogind does not support systemd units -#if 0 +#if 0 /// elogind does not support systemd units return cg_pid_get_machine_name(ucred.pid, machine); #else return -ESRCH; @@ -275,8 +262,7 @@ _public_ int sd_peer_get_slice(int fd, char **slice) { if (r < 0) return r; -/// elogind does not support systemd slices -#if 0 +#if 0 /// elogind does not support systemd slices return cg_pid_get_slice(ucred.pid, slice); #else return -ESRCH; @@ -294,8 +280,7 @@ _public_ int sd_peer_get_user_slice(int fd, char **slice) { if (r < 0) return r; -/// elogind does not support systemd slices -#if 0 +#if 0 /// elogind does not support systemd slices return cg_pid_get_user_slice(ucred.pid, slice); #else return -ESRCH; @@ -393,7 +378,7 @@ static int file_of_seat(const char *seat, char **_p) { if (!filename_is_valid(seat)) return -EINVAL; - p = strappend("/run/systemd/seats/", seat); + p = strappend("/run/systemd/seats/", seat); } else { _cleanup_free_ char *buf = NULL; @@ -457,10 +442,10 @@ static int uid_get_array(uid_t uid, const char *variable, char ***array) { r = parse_env_file(p, NEWLINE, variable, &s, NULL); if (r == -ENOENT || (r >= 0 && isempty(s))) { - if (array) - *array = NULL; - return 0; - } + if (array) + *array = NULL; + return 0; + } if (r < 0) return r; @@ -875,7 +860,7 @@ _public_ int sd_get_uids(uid_t **users) { errno = 0; de = readdir(d); - if (!de && errno != 0) + if (!de && errno > 0) return -errno; if (!de) @@ -1082,7 +1067,8 @@ _public_ int sd_login_monitor_new(const char *category, sd_login_monitor **m) { _public_ sd_login_monitor* sd_login_monitor_unref(sd_login_monitor *m) { int fd; - assert_return(m, NULL); + if (!m) + return NULL; fd = MONITOR_TO_FD(m); close_nointr(fd);