summaryrefslogtreecommitdiff
path: root/src/login
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2013-12-24 15:53:04 +0100
committerLennart Poettering <lennart@poettering.net>2013-12-24 15:53:04 +0100
commiteff05270986a13e7de93ae16311f654d3f7c166f (patch)
treec5c7d7c456f8a8b9d3e75cb9e36b5974215003ed /src/login
parent96415cad2fdd8d280ae94b02651b5f826a2f7f3d (diff)
util: unify SO_PEERCRED/SO_PEERSEC invocations
Introduce new call getpeercred() which internally just uses SO_PEERCRED but checks if the returned data is actually useful due to namespace quirks.
Diffstat (limited to 'src/login')
-rw-r--r--src/login/pam-module.c6
1 files changed, 2 insertions, 4 deletions
diff --git a/src/login/pam-module.c b/src/login/pam-module.c
index 45428a090f..89623aa765 100644
--- a/src/login/pam-module.c
+++ b/src/login/pam-module.c
@@ -120,7 +120,6 @@ static int get_seat_from_display(const char *display, const char **seat, uint32_
_cleanup_free_ char *p = NULL, *tty = NULL;
_cleanup_close_ int fd = -1;
struct ucred ucred;
- socklen_t l;
int v, r;
assert(display);
@@ -144,10 +143,9 @@ static int get_seat_from_display(const char *display, const char **seat, uint32_
if (connect(fd, &sa.sa, offsetof(struct sockaddr_un, sun_path) + strlen(sa.un.sun_path)) < 0)
return -errno;
- l = sizeof(ucred);
- r = getsockopt(fd, SOL_SOCKET, SO_PEERCRED, &ucred, &l);
+ r = getpeercred(fd, &ucred);
if (r < 0)
- return -errno;
+ return r;
r = get_ctty(ucred.pid, NULL, &tty);
if (r < 0)