summaryrefslogtreecommitdiff
path: root/src/login
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2018-10-15 13:58:31 +0200
committerLennart Poettering <lennart@poettering.net>2018-10-15 19:40:51 +0200
commit15a3e96f9220c931507456764902ff05d7171318 (patch)
treecd669f3363875fe1ee98a4bbcd77f1c27ca30f5e /src/login
parent5cf91ea9c858fca03983c96932c886497953603e (diff)
downloadsystemd-15a3e96f9220c931507456764902ff05d7171318.tar.gz
tree-wide: port various users over to sockaddr_un_set_path()
CID 1396140 CID 1396141
Diffstat (limited to 'src/login')
-rw-r--r--src/login/pam_systemd.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/login/pam_systemd.c b/src/login/pam_systemd.c
index 90ccbd7a83..8fc436c9d9 100644
--- a/src/login/pam_systemd.c
+++ b/src/login/pam_systemd.c
@@ -140,13 +140,11 @@ static int socket_from_display(const char *display, char **path) {
}
static int get_seat_from_display(const char *display, const char **seat, uint32_t *vtnr) {
- union sockaddr_union sa = {
- .un.sun_family = AF_UNIX,
- };
+ union sockaddr_union sa = {};
_cleanup_free_ char *p = NULL, *tty = NULL;
_cleanup_close_ int fd = -1;
struct ucred ucred;
- int v, r;
+ int v, r, salen;
assert(display);
assert(vtnr);
@@ -160,13 +158,15 @@ static int get_seat_from_display(const char *display, const char **seat, uint32_
r = socket_from_display(display, &p);
if (r < 0)
return r;
- strncpy(sa.un.sun_path, p, sizeof(sa.un.sun_path));
+ salen = sockaddr_un_set_path(&sa.un, p);
+ if (salen < 0)
+ return salen;
fd = socket(AF_UNIX, SOCK_STREAM|SOCK_CLOEXEC, 0);
if (fd < 0)
return -errno;
- if (connect(fd, &sa.sa, SOCKADDR_UN_LEN(sa.un)) < 0)
+ if (connect(fd, &sa.sa, salen) < 0)
return -errno;
r = getpeercred(fd, &ucred);