]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
pam_systemd: move socket_from_display() from util.[ch] to pam_systemd.c
authorLennart Poettering <lennart@poettering.net>
Fri, 20 Jul 2018 09:36:10 +0000 (11:36 +0200)
committerLennart Poettering <lennart@poettering.net>
Wed, 25 Jul 2018 14:09:33 +0000 (16:09 +0200)
It's highly specific, kinda legacy (X11…) and only used at one place,
let's move this out of the common code, and into pam_systemd.c where it
is used.

src/basic/util.c
src/basic/util.h
src/login/pam_systemd.c

index 8f2d6061da0b2b62ad70821450ac9ca712a9afa0..2206c1b4ad124e9d891a2dee0c83878b9efff95b 100644 (file)
@@ -77,31 +77,6 @@ bool display_is_local(const char *display) {
                 display[1] <= '9';
 }
 
-int socket_from_display(const char *display, char **path) {
-        size_t k;
-        char *f, *c;
-
-        assert(display);
-        assert(path);
-
-        if (!display_is_local(display))
-                return -EINVAL;
-
-        k = strspn(display+1, "0123456789");
-
-        f = new(char, STRLEN("/tmp/.X11-unix/X") + k + 1);
-        if (!f)
-                return -ENOMEM;
-
-        c = stpcpy(f, "/tmp/.X11-unix/X");
-        memcpy(c, display+1, k);
-        c[k] = 0;
-
-        *path = f;
-
-        return 0;
-}
-
 bool kexec_loaded(void) {
        _cleanup_free_ char *s = NULL;
 
index 9699d228f9c8f1147bf551cd65cec607121a5f54..42c262f5983ecc3c32132dce9af3f26bbaf923a4 100644 (file)
@@ -50,7 +50,6 @@ static inline const char* enable_disable(bool b) {
 bool plymouth_running(void);
 
 bool display_is_local(const char *display) _pure_;
-int socket_from_display(const char *display, char **path);
 
 #define NULSTR_FOREACH(i, l)                                    \
         for ((i) = (l); (i) && *(i); (i) = strchr((i), 0)+1)
index 8c5afeb1f7398cc9470a21c63dab7c8e8cca78c1..91802439e998215eee6fd6e3fb0072d50c341e5a 100644 (file)
@@ -114,6 +114,31 @@ static int get_user_data(
         return PAM_SUCCESS;
 }
 
+static int socket_from_display(const char *display, char **path) {
+        size_t k;
+        char *f, *c;
+
+        assert(display);
+        assert(path);
+
+        if (!display_is_local(display))
+                return -EINVAL;
+
+        k = strspn(display+1, "0123456789");
+
+        f = new(char, STRLEN("/tmp/.X11-unix/X") + k + 1);
+        if (!f)
+                return -ENOMEM;
+
+        c = stpcpy(f, "/tmp/.X11-unix/X");
+        memcpy(c, display+1, k);
+        c[k] = 0;
+
+        *path = f;
+
+        return 0;
+}
+
 static int get_seat_from_display(const char *display, const char **seat, uint32_t *vtnr) {
         union sockaddr_union sa = {
                 .un.sun_family = AF_UNIX,