1PAM_NAMESPACE(8) Linux-PAM Manual PAM_NAMESPACE(8)
2
3
4
6 pam_namespace - PAM module for configuring namespace for a session
7
9 pam_namespace.so [debug] [unmnt_remnt] [unmnt_only] [require_selinux]
10 [gen_hash] [ignore_config_error]
11 [ignore_instance_parent_mode] [unmount_on_close]
12 [use_current_context] [use_default_context]
13 [mount_private]
14
16 The pam_namespace PAM module sets up a private namespace for a session
17 with polyinstantiated directories. A polyinstantiated directory
18 provides a different instance of itself based on user name, or when
19 using SELinux, user name, security context or both. If an executable
20 script /etc/security/namespace.init exists, it is used to initialize
21 the instance directory after it is set up and mounted on the
22 polyinstantiated directory. The script receives the polyinstantiated
23 directory path, the instance directory path, flag whether the instance
24 directory was newly created (0 for no, 1 for yes), and the user name as
25 its arguments.
26
27 The pam_namespace module disassociates the session namespace from the
28 parent namespace. Any mounts/unmounts performed in the parent
29 namespace, such as mounting of devices, are not reflected in the
30 session namespace. To propagate selected mount/unmount events from the
31 parent namespace into the disassociated session namespace, an
32 administrator may use the special shared-subtree feature. For
33 additional information on shared-subtree feature, please refer to the
34 mount(8) man page and the shared-subtree description at
35 http://lwn.net/Articles/159077 and http://lwn.net/Articles/159092.
36
38 debug
39 A lot of debug information is logged using syslog
40
41 unmnt_remnt
42 For programs such as su and newrole, the login session has already
43 setup a polyinstantiated namespace. For these programs,
44 polyinstantiation is performed based on new user id or security
45 context, however the command first needs to undo the
46 polyinstantiation performed by login. This argument instructs the
47 command to first undo previous polyinstantiation before proceeding
48 with new polyinstantiation based on new id/context
49
50 unmnt_only
51 For trusted programs that want to undo any existing bind mounts and
52 process instance directories on their own, this argument allows
53 them to unmount currently mounted instance directories
54
55 require_selinux
56 If selinux is not enabled, return failure
57
58 gen_hash
59 Instead of using the security context string for the instance name,
60 generate and use its md5 hash.
61
62 ignore_config_error
63 If a line in the configuration file corresponding to a
64 polyinstantiated directory contains format error, skip that line
65 process the next line. Without this option, pam will return an
66 error to the calling program resulting in termination of the
67 session.
68
69 ignore_instance_parent_mode
70 Instance parent directories by default are expected to have the
71 restrictive mode of 000. Using this option, an administrator can
72 choose to ignore the mode of the instance parent. This option
73 should be used with caution as it will reduce security and
74 isolation goals of the polyinstantiation mechanism.
75
76 unmount_on_close
77 Explicitly unmount the polyinstantiated directories instead of
78 relying on automatic namespace destruction after the last process
79 in a namespace exits. This option should be used only in case it is
80 ensured by other means that there cannot be any processes running
81 in the private namespace left after the session close. It is also
82 useful only in case there are multiple pam session calls in
83 sequence from the same process.
84
85 use_current_context
86 Useful for services which do not change the SELinux context with
87 setexeccon call. The module will use the current SELinux context of
88 the calling process for the level and context polyinstantiation.
89
90 use_default_context
91 Useful for services which do not use pam_selinux for changing the
92 SELinux context with setexeccon call. The module will use the
93 default SELinux context of the user for the level and context
94 polyinstantiation.
95
96 mount_private
97 This option can be used on systems where the / mount point or its
98 submounts are made shared (for example with a mount --make-rshared
99 / command). The module will mark the whole directory tree so any
100 mount and unmount operations in the polyinstantiation namespace are
101 private. Normally the pam_namespace will try to detect the shared /
102 mount point and make the polyinstantiated directories private
103 automatically. This option has to be used just when only a subtree
104 is shared and / is not.
105
106 Note that mounts and unmounts done in the private namespace will
107 not affect the parent namespace if this option is used or when the
108 shared / mount point is autodetected.
109
111 Only the session module type is provided. The module must not be called
112 from multithreaded processes.
113
115 PAM_SUCCESS
116 Namespace setup was successful.
117
118 PAM_SERVICE_ERR
119 Unexpected system error occurred while setting up namespace.
120
121 PAM_SESSION_ERR
122 Unexpected namespace configuration error occurred.
123
125 /etc/security/namespace.conf
126 Main configuration file
127
128 /etc/security/namespace.d
129 Directory for additional configuration files
130
131 /etc/security/namespace.init
132 Init script for instance directories
133
135 For the <service>s you need polyinstantiation (login for example) put
136 the following line in /etc/pam.d/<service> as the last line for session
137 group:
138
139 session required pam_namespace.so [arguments]
140
141 To use polyinstantiation with graphical display manager gdm, insert the
142 following line, before exit 0, in /etc/gdm/PostSession/Default:
143
144 /usr/sbin/gdm-safe-restart
145
146 This allows gdm to restart after each session and appropriately adjust
147 namespaces of display manager and the X server. If polyinstantiation of
148 /tmp is desired along with the graphical environment, then additional
149 configuration changes are needed to address the interaction of X server
150 and font server namespaces with their use of /tmp to create
151 communication sockets. Please use the initialization script
152 /etc/security/namespace.init to ensure that the X server and its
153 clients can appropriately access the communication socket X0. Please
154 refer to the sample instructions provided in the comment section of the
155 instance initialization script /etc/security/namespace.init. In
156 addition, perform the following changes to use graphical environment
157 with polyinstantiation of /tmp:
158
159 1. Disable the use of font server by commenting out "FontPath"
160 line in /etc/X11/xorg.conf. If you do want to use the font server
161 then you will have to augment the instance initialization
162 script to appropriately provide /tmp/.font-unix from the
163 polyinstantiated /tmp.
164 2. Ensure that the gdm service is setup to use pam_namespace,
165 as described above, by modifying /etc/pam.d/gdm.
166 3. Ensure that the display manager is configured to restart X server
167 with each new session. This default setup can be verified by
168 making sure that /usr/share/gdm/defaults.conf contains
169 "AlwaysRestartServer=true", and it is not overridden by
170 /etc/gdm/custom.conf.
171
172
173
175 namespace.conf(5), pam.d(5), mount(8), pam(8).
176
178 The namespace setup scheme was designed by Stephen Smalley, Janak Desai
179 and Chad Sellers. The pam_namespace PAM module was developed by Janak
180 Desai <janak@us.ibm.com>, Chad Sellers <csellers@tresys.com> and Steve
181 Grubb <sgrubb@redhat.com>. Additional improvements by Xavier Toth
182 <txtoth@gmail.com> and Tomas Mraz <tmraz@redhat.com>.
183
184
185
186Linux-PAM Manual 06/08/2020 PAM_NAMESPACE(8)