diff options
author | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2020-03-02 15:51:31 +0100 |
---|---|---|
committer | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2020-03-02 15:55:44 +0100 |
commit | f36a9d5909019845d131e0c6c61f22b1d1956ca1 (patch) | |
tree | 7023bf19207e1903da61bef6a87d3a4fa2317178 /src/login | |
parent | 0f1886872362135467d7219e08fa7120dd73bee5 (diff) | |
download | systemd-f36a9d5909019845d131e0c6c61f22b1d1956ca1.tar.gz |
tree-wide: use the return value from sockaddr_un_set_path()
It fully initializes the address structure, so no need for pre-initialization,
and also returns the length of the address, so no need to recalculate using
SOCKADDR_UN_LEN().
socklen_t is unsigned, so let's not use an int for it. (It doesn't matter, but
seems cleaner and more portable to not assume anything about the type.)
Diffstat (limited to 'src/login')
-rw-r--r-- | src/login/pam_systemd.c | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/src/login/pam_systemd.c b/src/login/pam_systemd.c index 8447e1c555..84bea21ab7 100644 --- a/src/login/pam_systemd.c +++ b/src/login/pam_systemd.c @@ -219,11 +219,12 @@ 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 = {}; + union sockaddr_union sa; + socklen_t sa_len; _cleanup_free_ char *p = NULL, *sys_path = NULL, *tty = NULL; _cleanup_close_ int fd = -1; struct ucred ucred; - int v, r, salen; + int v, r; dev_t display_ctty; assert(display); @@ -238,15 +239,16 @@ static int get_seat_from_display(const char *display, const char **seat, uint32_ r = socket_from_display(display, &p); if (r < 0) return r; - salen = sockaddr_un_set_path(&sa.un, p); - if (salen < 0) - return salen; + r = sockaddr_un_set_path(&sa.un, p); + if (r < 0) + return r; + sa_len = r; fd = socket(AF_UNIX, SOCK_STREAM|SOCK_CLOEXEC, 0); if (fd < 0) return -errno; - if (connect(fd, &sa.sa, salen) < 0) + if (connect(fd, &sa.sa, sa_len) < 0) return -errno; r = getpeercred(fd, &ucred); |