mirror of
https://github.com/systemd/systemd.git
synced 2026-08-03 14:40:31 +00:00
pam_systemd: move socket_from_display() from util.[ch] to pam_systemd.c
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.
This commit is contained in:
@@ -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;
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user