PAM_NAMESPACE(8)
๐ NAME ๐
okay bestie, meet pam_namespace โ the PAM module that sets up a private namespace for a session. it's pam_namespace(8), from the Linux-PAM Manual, and it's lowkey one of the most iconic ones in the whole family. ๐ซถ
โจ SYNOPSIS โจ
pam_namespace.so [debug] [unmnt_remnt] [unmnt_only] [require_selinux]
[gen_hash] [ignore_config_error]
[ignore_instance_parent_mode] [unmount_on_close]
[use_current_context] [use_default_context]
[mount_private]
๐ธ DESCRIPTION ๐ธ
so basically, the pam_namespace PAM module sets up a private namespace for a session, with polyinstantiated directories. and a polyinstantiated directory is literally a directory that gives you a different instance of itself depending on user name โ or, when you're using SELinux, based on user name, security context, or both. it's giving โจone directory, many livesโจ.
if an executable script at /etc/security/namespace.init exists, it gets used to initialize the instance directory after it's been set up and mounted on the polyinstantiated directory. that script receives these as its arguments:
- the polyinstantiated directory path
- the instance directory path
- a flag for whether the instance directory was newly created (
0for no,1for yes) - the user name
โ ๏ธ bestie, listen. that script is invoked with full root privileges, and accessing the instance directory in this context needs to be done with caution, because it is controlled by the unprivileged user for which it has been created. root powers + user-controlled stuff = be careful, fr fr.
the pam_namespace module disassociates the session namespace from the parent namespace. meaning: any mounts/unmounts performed in the parent namespace โ like mounting of devices โ are not reflected in the session namespace. no bleed-through, periodt.
but if you do want some of those events to travel, an administrator may use the special shared-subtree feature to propagate selected mount/unmount events from the parent namespace into the disassociated session namespace. for the tea on shared-subtree, go read the mount(8) man page and the shared-subtree description at http://lwn.net/Articles/159077 and http://lwn.net/Articles/159092. ๐
๐ OPTIONS ๐
debugโ logs a lot of debug information usingsyslog. noise? yes. useful? also yes. ๐unmnt_remntโ for programs likesuandnewrole, the login session has already set up a polyinstantiated namespace. for these programs, polyinstantiation is performed based on the new user id or security context, but the command first needs to undo the polyinstantiation that login did. this argument tells it to undo the previous polyinstantiation first, before proceeding with new polyinstantiation based on the new id/context. out with the old, in with the new ๐unmnt_onlyโ for trusted programs that want to undo any existing bind mounts and process instance directories on their own, this argument lets them unmount currently mounted instance directories. do-it-yourself energy ๐ซกrequire_selinuxโ if selinux is not enabled, return failure. no selinux, no service. ๐gen_hashโ instead of using the security context string for the instance name, generate and use its md5 hash. shorter name, same vibe.ignore_config_errorโ if a line in the configuration file corresponding to a polyinstantiated directory contains a format error, skip that line and process the next line. without this option, pam will return an error to the calling program, which results in termination of the session. so likeโฆ forgiving mode, but the default is not forgiving. ๐ญignore_instance_parent_modeโ instance parent directories are by default expected to have the restrictive mode of000. with this option, an administrator can choose to ignore the mode of the instance parent.
๐จ this option should be used with caution, because it will reduce the security and isolation goals of the polyinstantiation mechanism. it's a tradeoff, bestie, and not a cute one.
unmount_on_closeโ explicitly unmount the polyinstantiated directories instead of relying on automatic namespace destruction after the last process in a namespace exits.
โ ๏ธ use this one only in case it is ensured by other means that there cannot be any processes running in the private namespace left after the session close. it's also useful only in case there are multiple pam session calls in sequence from the same process.
use_current_contextโ useful for services which do not change the SELinux context withsetexecconcall. the module will use the current SELinux context of the calling process for the level and context polyinstantiation. ๐use_default_contextโ useful for services which do not usepam_selinuxfor changing the SELinux context withsetexecconcall. the module will use the default SELinux context of the user for the level and context polyinstantiation. the fallback queen ๐mount_privateโ this option can be used on systems where the/mount point or its submounts are made shared (for example with amount --make-rshared /command). the module will mark the whole directory tree so any mount and unmount operations in the polyinstantiation namespace are private. normallypam_namespacewill try to detect the shared/mount point and make the polyinstantiated directories private automatically. this option has to be used just when only a subtree is shared and/is not.
note that mounts and unmounts done in the private namespace will not affect the parent namespace if this option is used, or when the shared / mount point is autodetected. isolation slay ๐ฆ
๐ง MODULE TYPES PROVIDED ๐ง
only the session module type is provided. and listen โ the module must not be called from multithreaded processes. like, don't. not the vibe. ๐ซ
๐ RETURN VALUES ๐
PAM_SUCCESSโ namespace setup was successful. we ate. ๐PAM_SERVICE_ERRโ an unexpected system error occurred while setting up the namespace. ๐PAM_SESSION_ERRโ an unexpected namespace configuration error occurred. ๐ญ
๐ FILES ๐
/etc/security/namespace.confโ the main configuration file ๐/etc/security/namespace.dโ directory for additional configuration files ๐/etc/security/namespace.initโ init script for instance directories โจ
๐ EXAMPLES ๐
for the <service>s you need polyinstantiation on (login, for example), put the following line in /etc/pam.d/<service> as the last line for the session group:
session required pam_namespace.so [arguments]
and to use polyinstantiation with the graphical display manager gdm, please refer to gdm's documentation. iykyk ๐
๐ SEE ALSO ๐
namespace.conf(5), pam.d(5), mount(8), pam(8).
๐ AUTHORS ๐
the namespace setup scheme was designed by Stephen Smalley, Janak Desai and Chad Sellers. the pam_namespace PAM module was developed by Janak Desai <janak@us.ibm.com>, Chad Sellers <csellers@tresys.com> and Steve Grubb <sgrubb@redhat.com>. additional improvements by Xavier Toth <txtoth@gmail.com> and Tomas Mraz <tmraz@redhat.com>. absolute legends, every single one ๐ซถ
and that's the whole page, bestie โ brought to you by Linux-PAM, dated 09/27/2026, filed under PAM_NAMESPACE(8). go forth and polyinstantiate responsibly ๐
โจ
๐ฆ where this page comes from
- arch rolling: pam 1.7.3-1 ยท GPL-2.0-only
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms