PAM_ELOGIND(8)

πŸ“¦
version 255.24 Β· 3 versions
, in alpine 3.24

πŸ’– PAM_ELOGIND(8) β€” the pam_elogind page, bestie edition πŸ’–

okay so this is section 8 of the manual, all about pam_elogind β€” the PAM module that gets your user sessions registered with the elogind login manager. yes we're doing this. buckle up πŸŽ€


✨ NAME ✨

pam_elogind β€” registers user sessions in the elogind login manager 🫢


✨ SYNOPSIS ✨

pam_elogind.so

that's it. that's the whole synopsis. iconic minimalist behavior πŸ’…


🌸 DESCRIPTION 🌸

so pam_elogind registers user sessions with the elogind(8) login manager β€” and by extension, with the elogind control group hierarchy. main character module honestly πŸ‘‘

the module also applies all the resource management and runtime parameters to the brand-new session, exactly as configured in the user's JSON User Records[1] β€” but only when one is actually defined for that user. no record, no fancy params, that's the vibe.

On login, this module makes sure of the following, no cap:

  1. if it doesn't exist yet, the user runtime directory /run/user/$UID is either created or mounted as a new "tmpfs" file system with quota applied β€” and its ownership is changed over to the user who's logging in 🧚
  2. the $XDG_SESSION_ID environment variable gets initialized. if auditing is available and pam_loginuid.so was run before this module (which is highly recommended, fr fr), then the variable is initialized from the auditing session id (/proc/self/sessionid). otherwise, an independent session counter is used.
  3. the "$TZ", "$EMAIL" and "$LANG" environment variables are configured for the user, based on the respective data from the user's JSON record (if it's defined). on top of that, any environment variables explicitly configured in the user record get imported, and the umask, nice level, and resource limits are initialized too ✨

On logout, this module ensures:

  1. if it's enabled in logind.conf(5) (KillUserProcesses=), all processes of the session are terminated πŸ’€. and if the last concurrent session of a user ends, the user's elogind instance gets terminated too β€” and so does the user's slice unit. whole thing wraps up, periodt.
  2. if the last concurrent session of a user ends, the user runtime directory /run/user/$UID and every single thing inside it gets removed too 🫧
heads up bestie: if the system was not booted up with elogind as init system, this module does absolutely nothing and immediately returns PAM_SUCCESS. like, it's just gonna vibe there. πŸ™ˆ

πŸ¦‹ OPTIONS πŸ¦‹

here's everything the module understands:

  • class= β€” takes a string argument which sets the session class. the XDG_SESSION_CLASS environment variable (peep below) takes precedence. one of "user", "greeter", "lock-screen" or "background". see sd_session_get_class(3) for the deets about the session class.

Added in version 197.

  • type= β€” takes a string argument which sets the session type. the XDG_SESSION_TYPE environment variable (below, keep scrolling) takes precedence. one of "unspecified", "tty", "x11", "wayland" or "mir". see sd_session_get_type(3) for details about the session type.

Added in version 209.

  • desktop= β€” takes a single, short identifier string for the desktop environment. the XDG_SESSION_DESKTOP environment variable (yep, below) takes precedence. this may be used to indicate the session desktop used, where this applies and if this information is available. for example: "GNOME", or "KDE". it's recommended to use the same identifiers and capitalization as for $XDG_CURRENT_DESKTOP, as defined by the Desktop Entry Specification[2]. (but like, note that the option only takes a single item, and not a colon-separated list like $XDG_CURRENT_DESKTOP does. so don't try it πŸ’…) see sd_session_get_desktop(3) for further details.

Added in version 240.

  • default-capability-bounding-set=, default-capability-ambient-set= β€” takes a comma-separated list of process capabilities (e.g. CAP_WAKE_ALARM, CAP_BLOCK_SUSPEND, ...) to set for the invoked session's processes, if the user record doesn't encode appropriate sets of capabilities directly. see capabilities(7) for the whole capabilities concept. if not specified, the default bounding set is left as is (i.e. usually contains the full set of capabilities). the default ambient set is set to CAP_WAKE_ALARM for regular users if the PAM session is associated with a local seat. otherwise, it defaults to the empty set.

Added in version 254.

  • debug[=] β€” takes an optional boolean argument. if yes, or with no argument at all, the module will log debugging information as it operates πŸ”

🧚 MODULE TYPES PROVIDED 🧚

only session is provided. one module type, one job, no multitasking 😌


🌈 ENVIRONMENT 🌈

the following environment variables are initialized by the module and are available to the processes of the user's session:

  • $XDG_SESSION_ID β€” a short session identifier, suitable to be used in filenames. the string itself should be considered opaque, although often it's just the audit session ID as reported by /proc/self/sessionid. each ID will be assigned only once during machine uptime. it may hence be used to uniquely label files or other resources of this session. combine this ID with the boot identifier, as returned by sd_id128_get_boot(3), for a globally unique identifier ✨
  • $XDG_RUNTIME_DIR β€” path to a user-private, user-writable directory that is bound to the user login time on the machine. it's automatically created the first time a user logs in and removed on the user's final logout. if a user logs in twice at the same time, both sessions will see the same $XDG_RUNTIME_DIR and the same contents. if a user logs in once, then logs out again, and logs in again, the directory contents will have been lost in between β€” but applications should not rely on this behavior and must be able to deal with stale files. to store session-private data in this directory, the user should include the value of $XDG_SESSION_ID in the filename. this directory shall be used for runtime file system objects such as AF_UNIX sockets, FIFOs, PID files and similar. it's guaranteed that this directory is local and offers the greatest possible file system feature set the operating system provides. for further details, see the XDG Base Directory Specification[3]. $XDG_RUNTIME_DIR is not set if the current user is not the original user of the session. 🫢
  • $TZ, $EMAIL, $LANG β€” if a JSON user record is known for the user logging in, these variables are initialized from the respective data in the record.

Added in version 245.

the following environment variables are read by the module and may be used by the PAM service to pass metadata to the module. if these variables aren't set when the PAM module is invoked but can be determined otherwise, they're set by the module β€” so that these variables are initialized for the session and applications if known at all:

  • $XDG_SESSION_TYPE β€” the session type. this may be used instead of type= on the module parameter line, and is usually preferred. ⭐

Added in version 209.

  • $XDG_SESSION_CLASS β€” the session class. this may be used instead of class= on the module parameter line, and is usually preferred.

Added in version 209.

  • $XDG_SESSION_DESKTOP β€” the desktop identifier. this may be used instead of desktop= on the module parameter line, and is usually preferred.

Added in version 209.

  • $XDG_SEAT β€” the seat name the session shall be registered for, if any.

Added in version 209.

  • $XDG_VTNR β€” the VT number the session shall be registered for, if any. (only applies to seats with a VT available, such as "seat0")

Added in version 209.

and if they're not set, pam_elogind will initialize $XDG_SEAT and $XDG_VTNR based on the $DISPLAY variable (if the latter is set). πŸŽ€


πŸ”₯ EXAMPLE πŸ”₯

here's an example PAM configuration fragment that lets user sessions be managed by elogind:

#%PAM-1.0
auth            required        pam_shells.so
auth            required        pam_nologin.so
auth            include         system-auth
account         required        pam_access.so
account         required        pam_nologin.so
account         required        pam_time.so
account         include         system-auth
password        include         system-auth
session         optional        pam_loginuid.so
session         required        pam_env.so envfile=/etc/profile.env
session         optional        pam_lastlog.so silent
session         include         system-auth
session         optional        pam_motd.so motd=/etc/motd
session         optional        pam_mail.so
-session  optional   pam_elogind.so

look at that last line. that's the one doing the work. obsessed. 😌


⭐ SEE ALSO ⭐

logind.conf(5), loginctl(1),

pam.conf(5), pam.d(5), pam(8), pam_loginuid(8),


πŸ’œ NOTES πŸ’œ

  1. JSON User Records https://systemd.io/USER_RECORD
  2. Desktop Entry Specification https://standards.freedesktop.org/desktop-entry-spec/latest/
  3. XDG Base Directory Specification https://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html

and that's the whole page babes πŸ’– this was elogind 255.24, dated PAM_ELOGIND(8) β€” same manual section, same version, no cap. go forth and register your sessions responsibly 🧚✨🌸
πŸ“¦ where this page comes from