chiark / gitweb /
Merge pull request #7 from elogind/dev_v228-r1
[elogind.git] / src / libelogind / sd-login / sd-login.c
index 4f625ea335e9874ca322c9d96256398d5649b87e..ac22fa3454ce57a5fc757c5726c3309752d67acd 100644 (file)
   along with systemd; If not, see <http://www.gnu.org/licenses/>.
 ***/
 
-#include <unistd.h>
-#include <string.h>
 #include <errno.h>
-#include <sys/inotify.h>
 #include <poll.h>
+#include <string.h>
+#include <sys/inotify.h>
+#include <unistd.h>
 
-#include "util.h"
+#include "sd-login.h"
+
+#include "alloc-util.h"
 #include "cgroup-util.h"
-#include "macro.h"
-#include "strv.h"
+#include "dirent-util.h"
+#include "escape.h"
+#include "fd-util.h"
 #include "fileio.h"
-#include "login-util.h"
 #include "formats-util.h"
+#include "fs-util.h"
 #include "hostname-util.h"
-#include "sd-login.h"
+#include "io-util.h"
+#include "login-util.h"
+#include "macro.h"
+#include "parse-util.h"
+#include "path-util.h"
+#include "socket-util.h"
+#include "string-util.h"
+#include "strv.h"
+#include "user-util.h"
+#include "util.h"
 
 /* Error codes:
  *
@@ -58,8 +70,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;
@@ -71,8 +82,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;
@@ -84,8 +94,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;
@@ -97,8 +106,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;
@@ -110,8 +118,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;
@@ -123,8 +130,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;
@@ -138,7 +144,7 @@ _public_ int sd_pid_get_cgroup(pid_t pid, char **cgroup) {
         assert_return(pid >= 0, -EINVAL);
         assert_return(cgroup, -EINVAL);
 
-        r = cg_pid_get_path(ELOGIND_CGROUP_CONTROLLER, pid, &c);
+        r = cg_pid_get_path(SYSTEMD_CGROUP_CONTROLLER, pid, &c);
         if (r < 0)
                 return r;
 
@@ -168,8 +174,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;
@@ -187,8 +192,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;
@@ -206,8 +210,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;
@@ -225,8 +228,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;
@@ -244,8 +246,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;
@@ -263,8 +264,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;
@@ -282,8 +282,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;
@@ -381,7 +380,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;
 
@@ -445,10 +444,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;
 
@@ -985,9 +984,7 @@ _public_ int sd_machine_get_ifindices(const char *machine, int **ifindices) {
 
                 *(char*) (mempcpy(buf, word, l)) = 0;
 
-                if (safe_atoi(buf, &ifi) < 0)
-                        continue;
-                if (ifi <= 0)
+                if (parse_ifindex(buf, &ifi) < 0)
                         continue;
 
                 if (!GREEDY_REALLOC(ni, allocated, nr+1)) {