X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=src%2Flogin%2Fpam_elogind.c;h=402885d7e9d6a3742319706052cc671a7486da17;hb=HEAD;hp=b1ffc3dd3446303f8c482469a0849c8902943f88;hpb=4075ef68ba5e6fc39e3616835a3ac4da66599bda;p=elogind.git diff --git a/src/login/pam_elogind.c b/src/login/pam_elogind.c index b1ffc3dd3..402885d7e 100644 --- a/src/login/pam_elogind.c +++ b/src/login/pam_elogind.c @@ -1,5 +1,3 @@ -/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/ - /*** This file is part of systemd. @@ -38,7 +36,7 @@ #include "def.h" #include "fd-util.h" #include "fileio.h" -#include "formats-util.h" +#include "format-util.h" #include "hostname-util.h" #include "login-util.h" #include "macro.h" @@ -152,7 +150,7 @@ static int get_seat_from_display(const char *display, const char **seat, uint32_ if (fd < 0) return -errno; - if (connect(fd, &sa.sa, offsetof(struct sockaddr_un, sun_path) + strlen(sa.un.sun_path)) < 0) + if (connect(fd, &sa.sa, SOCKADDR_UN_LEN(sa.un)) < 0) return -errno; r = getpeercred(fd, &ucred); @@ -184,25 +182,20 @@ static int export_legacy_dbus_address( _cleanup_free_ char *s = NULL; int r = PAM_BUF_ERR; - if (is_kdbus_available()) { - if (asprintf(&s, KERNEL_USER_BUS_ADDRESS_FMT ";" UNIX_USER_BUS_ADDRESS_FMT, uid, runtime) < 0) - goto error; - } else { - /* FIXME: We *really* should move the access() check into the - * daemons that spawn dbus-daemon, instead of forcing - * DBUS_SESSION_BUS_ADDRESS= here. */ + /* FIXME: We *really* should move the access() check into the + * daemons that spawn dbus-daemon, instead of forcing + * DBUS_SESSION_BUS_ADDRESS= here. */ - s = strjoin(runtime, "/bus", NULL); - if (!s) - goto error; + s = strjoin(runtime, "/bus"); + if (!s) + goto error; - if (access(s, F_OK) < 0) - return PAM_SUCCESS; + if (access(s, F_OK) < 0) + return PAM_SUCCESS; - s = mfree(s); - if (asprintf(&s, UNIX_USER_BUS_ADDRESS_FMT, runtime) < 0) - goto error; - } + s = mfree(s); + if (asprintf(&s, UNIX_USER_BUS_ADDRESS_FMT, runtime) < 0) + goto error; r = pam_misc_setenv(handle, "DBUS_SESSION_BUS_ADDRESS", s, 0); if (r != PAM_SUCCESS) @@ -239,9 +232,11 @@ _public_ PAM_EXTERN int pam_sm_open_session( assert(handle); +#if 0 /// with elogind, it is always a "logind system". /* Make this a NOP on non-logind systems */ if (!logind_running()) return PAM_SUCCESS; +#endif // 0 if (parse_argv(handle, argc, argv, @@ -251,7 +246,11 @@ _public_ PAM_EXTERN int pam_sm_open_session( return PAM_SESSION_ERR; if (debug) +#if 0 /// This is pam-elogind, not pam-systemd pam_syslog(handle, LOG_DEBUG, "pam-systemd initializing"); +#else + pam_syslog(handle, LOG_DEBUG, "pam-elogind initializing"); +#endif // 0 r = get_user_data(handle, &username, &pw); if (r != PAM_SUCCESS) { @@ -266,21 +265,25 @@ _public_ PAM_EXTERN int pam_sm_open_session( * leave. */ pam_get_item(handle, PAM_SERVICE, (const void**) &service); +#if 0 /// Actually it is elogind-user with elogind. if (streq_ptr(service, "systemd-user")) { +#else + if (streq_ptr(service, "elogind-user")) { +#endif // 0 _cleanup_free_ char *rt = NULL; if (asprintf(&rt, "/run/user/"UID_FMT, pw->pw_uid) < 0) return PAM_BUF_ERR; - r = pam_misc_setenv(handle, "XDG_RUNTIME_DIR", rt, 0); - if (r != PAM_SUCCESS) { - pam_syslog(handle, LOG_ERR, "Failed to set runtime dir."); - return r; - } + r = pam_misc_setenv(handle, "XDG_RUNTIME_DIR", rt, 0); + if (r != PAM_SUCCESS) { + pam_syslog(handle, LOG_ERR, "Failed to set runtime dir."); + return r; + } - r = export_legacy_dbus_address(handle, pw->pw_uid, rt); - if (r != PAM_SUCCESS) - return r; + r = export_legacy_dbus_address(handle, pw->pw_uid, rt); + if (r != PAM_SUCCESS) + return r; return PAM_SUCCESS; }