X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;ds=sidebyside;f=src%2Flogin%2Fpam-module.c;h=3b6b163a47fdd026e2c0140397dc7c4dde389106;hb=05a049cc44d1c7eadfab104eea15b13f0207ab40;hp=8c5b3a10f3fc867a3d8f3600f81c4ff018079dd1;hpb=fb6becb4436ae4078337011b2017ce294e7361cf;p=elogind.git diff --git a/src/login/pam-module.c b/src/login/pam-module.c index 8c5b3a10f..3b6b163a4 100644 --- a/src/login/pam-module.c +++ b/src/login/pam-module.c @@ -51,30 +51,26 @@ static int parse_argv(pam_handle_t *handle, assert(argc >= 0); assert(argc == 0 || argv); - for (i = 0; i < (unsigned) argc; i++) { - int k; - + for (i = 0; i < (unsigned) argc; i++) if (startswith(argv[i], "class=")) { - if (class) *class = argv[i] + 6; - } else if (startswith(argv[i], "debug=")) { - k = parse_boolean(argv[i] + 6); + } else if (streq(argv[i], "debug")) { + if (debug) + *debug = true; - if (k < 0) { - pam_syslog(handle, LOG_ERR, "Failed to parse debug= argument."); - return k; - } + } else if (startswith(argv[i], "debug=")) { + int k; - if (debug) + k = parse_boolean(argv[i] + 6); + if (k < 0) + pam_syslog(handle, LOG_WARNING, "Failed to parse debug= argument, ignoring."); + else if (debug) *debug = k; - } else { + } else pam_syslog(handle, LOG_WARNING, "Unknown parameter '%s', ignoring", argv[i]); - return 0; - } - } return 0; } @@ -187,7 +183,7 @@ _public_ PAM_EXTERN int pam_sm_open_session( const char *username, *id, *object_path, *runtime_path, *service = NULL, *tty = NULL, *display = NULL, *remote_user = NULL, *remote_host = NULL, *seat = NULL, *type = NULL, *class = NULL, *class_pam = NULL, *cvtnr = NULL; DBusError error; uint32_t uid, pid; - DBusMessageIter iter; + DBusMessageIter iter, sub; int session_fd = -1; DBusConnection *bus = NULL; DBusMessage *m = NULL, *reply = NULL; @@ -199,7 +195,8 @@ _public_ PAM_EXTERN int pam_sm_open_session( dbus_error_init(&error); - /* pam_syslog(handle, LOG_INFO, "pam-systemd initializing"); */ + if (debug) + pam_syslog(handle, LOG_INFO, "pam-systemd initializing"); /* Make this a NOP on non-logind systems */ if (!logind_running()) @@ -220,12 +217,12 @@ _public_ PAM_EXTERN int pam_sm_open_session( /* Make sure we don't enter a loop by talking to * systemd-logind when it is actually waiting for the * background to finish start-up. If the service is - * "systemd-shared" we simply set XDG_RUNTIME_DIR and + * "systemd-user" we simply set XDG_RUNTIME_DIR and * leave. */ pam_get_item(handle, PAM_SERVICE, (const void**) &service); - if (streq_ptr(service, "systemd-shared")) { - char *p, *rt = NULL; + if (streq_ptr(service, "systemd-user")) { + _cleanup_free_ char *p = NULL, *rt = NULL; if (asprintf(&p, "/run/systemd/users/%lu", (unsigned long) pw->pw_uid) < 0) { r = PAM_BUF_ERR; @@ -235,18 +232,13 @@ _public_ PAM_EXTERN int pam_sm_open_session( r = parse_env_file(p, NEWLINE, "RUNTIME", &rt, NULL); - free(p); - if (r < 0 && r != -ENOENT) { r = PAM_SESSION_ERR; - free(rt); goto finish; } if (rt) { r = pam_misc_setenv(handle, "XDG_RUNTIME_DIR", rt, 0); - free(rt); - if (r != PAM_SUCCESS) { pam_syslog(handle, LOG_ERR, "Failed to set runtime dir."); goto finish; @@ -371,6 +363,13 @@ _public_ PAM_EXTERN int pam_sm_open_session( dbus_message_iter_init_append(m, &iter); + if (!dbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY, "(sv)", &sub) || + !dbus_message_iter_close_container(&iter, &sub)) { + pam_syslog(handle, LOG_ERR, "Could not attach parameters to message."); + r = PAM_BUF_ERR; + goto finish; + } + if (debug) pam_syslog(handle, LOG_DEBUG, "Asking logind to create session: " "uid=%u pid=%u service=%s type=%s class=%s seat=%s vtnr=%u tty=%s display=%s remote=%s remote_user=%s remote_host=%s",