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

Lennart Poettering lennart at poettering.net
Mon Dec 24 10:19:09 PST 2012


On Mon, 24.12.12 06:25, Matthew Monaco (dgbaley27 at 0x01b.net) wrote:

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

Commited with a fix to make compilation clean. Thanks!
> 
> ---
>  man/pam_systemd.xml    |  9 +++++++++
>  src/login/pam-module.c | 12 ++++++++++--
>  2 files changed, 19 insertions(+), 2 deletions(-)
> 
> diff --git a/man/pam_systemd.xml b/man/pam_systemd.xml
> index 2d2f191..600bfd7 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.
> +                                The XDG_SESSION_CLASS environmental variable
> +                                takes precedence.</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 e6764a1..ad56551 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,11 @@ 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 +328,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 = NULL, *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 = NULL, *class = NULL, *class_pam = 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 +355,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_pam, &debug) < 0) {
>                  r = PAM_SESSION_ERR;
>                  goto finish;
>          }
> @@ -485,6 +491,8 @@ _public_ PAM_EXTERN int pam_sm_open_session(
>          if (isempty(class))
>                  class = getenv("XDG_SESSION_CLASS");
>          if (isempty(class))
> +                class = class_pam;
> +        if (isempty(class))
>                  class = "user";
>  
>          remote = !isempty(remote_host) &&


Lennart

-- 
Lennart Poettering - Red Hat, Inc.


More information about the systemd-devel mailing list