[systemd-devel] [PATCH] pam_systemd: new option for the session class

Matthew Monaco dgbaley27 at 0x01b.net
Tue Nov 27 22:16:48 PST 2012


From: Matthew Monaco <matthew.monaco at 0x01b.net>

---

I don't see any reason why every DM (LightDM for me) needs code to support this.

It looks to me like its safe to just point to the data in argv, let me know if it isn't.

 man/pam_systemd.xml    |  9 +++++++++
 src/login/pam-module.c | 14 +++++++++++---
 2 files changed, 20 insertions(+), 3 deletions(-)

diff --git a/man/pam_systemd.xml b/man/pam_systemd.xml
index 2d2f191..07f0da9 100644
--- a/man/pam_systemd.xml
+++ b/man/pam_systemd.xml
@@ -194,6 +194,15 @@
                         </varlistentry>
 
                         <varlistentry>
+                                <term><option>class=</option></term>
+
+                                <listitem><para>Takes a string
+                                argument which sets the session class.
+                                This takes precedent over the XDG_SESSION_CLASS
+                                environmental variable.</para></listitem>
+                        </varlistentry>
+
+                        <varlistentry>
                                 <term><option>debug=</option></term>
 
                                 <listitem><para>Takes a boolean
diff --git a/src/login/pam-module.c b/src/login/pam-module.c
index 08a9328..9294d47 100644
--- a/src/login/pam-module.c
+++ b/src/login/pam-module.c
@@ -49,6 +49,7 @@ static int parse_argv(pam_handle_t *handle,
                       bool *kill_processes,
                       char ***kill_only_users,
                       char ***kill_exclude_users,
+                      char **class,
                       bool *debug) {
 
         unsigned i;
@@ -135,6 +136,12 @@ static int parse_argv(pam_handle_t *handle,
                                 *kill_exclude_users = l;
                         }
 
+                } else if (startswith(argv[i], "class=")) {
+
+                        if (class) {
+				*class = argv[i] + 6;
+                        }
+
                 } else if (startswith(argv[i], "debug=")) {
                         if ((k = parse_boolean(argv[i] + 6)) < 0) {
                                 pam_syslog(handle, LOG_ERR, "Failed to parse debug= argument.");
@@ -322,7 +329,7 @@ _public_ PAM_EXTERN int pam_sm_open_session(
 
         struct passwd *pw;
         bool kill_processes = false, debug = false;
-        const char *username, *id, *object_path, *runtime_path, *service = NULL, *tty = NULL, *display = NULL, *remote_user = NULL, *remote_host = NULL, *seat = NULL, *type, *class, *cvtnr = NULL;
+        const char *username, *id, *object_path, *runtime_path, *service = NULL, *tty = NULL, *display = NULL, *remote_user = NULL, *remote_host = NULL, *seat = NULL, *type, *class = NULL, *cvtnr = NULL;
         char **controllers = NULL, **reset_controllers = NULL, **kill_only_users = NULL, **kill_exclude_users = NULL;
         DBusError error;
         uint32_t uid, pid;
@@ -349,7 +356,7 @@ _public_ PAM_EXTERN int pam_sm_open_session(
                        argc, argv,
                        &controllers, &reset_controllers,
                        &kill_processes, &kill_only_users, &kill_exclude_users,
-                       &debug) < 0) {
+                       &class, &debug) < 0) {
                 r = PAM_SESSION_ERR;
                 goto finish;
         }
@@ -472,7 +479,8 @@ _public_ PAM_EXTERN int pam_sm_open_session(
         type = !isempty(display) ? "x11" :
                    !isempty(tty) ? "tty" : "unspecified";
 
-        class = pam_getenv(handle, "XDG_SESSION_CLASS");
+        if (isempty(class))
+                class = pam_getenv(handle, "XDG_SESSION_CLASS");
         if (isempty(class))
                 class = getenv("XDG_SESSION_CLASS");
         if (isempty(class))
-- 
1.8.0.1



More information about the systemd-devel mailing list