]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
pam_systemd: also make $XDG_SESSION_DESKTOP configurable via PAM module command line
authorLennart Poettering <lennart@poettering.net>
Fri, 20 Jul 2018 09:01:18 +0000 (11:01 +0200)
committerLennart Poettering <lennart@poettering.net>
Wed, 25 Jul 2018 14:09:33 +0000 (16:09 +0200)
Let's make this symmetric with XDG_SESSION_CLASS and XDG_SESSION_TYPE,
so that PAM stacks can configure this easily without involving env vars,
in case there are PAM session managers which only support a single
desktop anyway.

src/login/pam_systemd.c

index 89535de1aefa4511c17b92c9394084dc7b314b8a..ab2cddebac5f15cb1013afdb85a18e4d6afc4825 100644 (file)
@@ -37,6 +37,7 @@ static int parse_argv(
                 int argc, const char **argv,
                 const char **class,
                 const char **type,
+                const char **desktop,
                 bool *debug) {
 
         unsigned i;
@@ -53,6 +54,10 @@ static int parse_argv(
                         if (type)
                                 *type = argv[i] + 5;
 
+                } else if (startswith(argv[i], "desktop=")) {
+                        if (desktop)
+                                *desktop = argv[i] + 8;
+
                 } else if (streq(argv[i], "debug")) {
                         if (debug)
                                 *debug = true;
@@ -274,7 +279,7 @@ _public_ PAM_EXTERN int pam_sm_open_session(
                 *remote_user = NULL, *remote_host = NULL,
                 *seat = NULL,
                 *type = NULL, *class = NULL,
-                *class_pam = NULL, *type_pam = NULL, *cvtnr = NULL, *desktop = NULL,
+                *class_pam = NULL, *type_pam = NULL, *cvtnr = NULL, *desktop = NULL, *desktop_pam = NULL,
                 *memory_max = NULL, *tasks_max = NULL, *cpu_weight = NULL, *io_weight = NULL;
         _cleanup_(sd_bus_flush_close_unrefp) sd_bus *bus = NULL;
         int session_fd = -1, existing, r;
@@ -293,6 +298,7 @@ _public_ PAM_EXTERN int pam_sm_open_session(
                        argc, argv,
                        &class_pam,
                        &type_pam,
+                       &desktop_pam,
                        &debug) < 0)
                 return PAM_SESSION_ERR;
 
@@ -338,7 +344,7 @@ _public_ PAM_EXTERN int pam_sm_open_session(
         cvtnr = getenv_harder(handle, "XDG_VTNR", NULL);
         type = getenv_harder(handle, "XDG_SESSION_TYPE", type_pam);
         class = getenv_harder(handle, "XDG_SESSION_CLASS", class_pam);
-        desktop = getenv_harder(handle, "XDG_SESSION_DESKTOP", NULL);
+        desktop = getenv_harder(handle, "XDG_SESSION_DESKTOP", desktop_pam);
 
         tty = strempty(tty);