README 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227
  1. pam_namespace — PAM module for configuring namespace for a session
  2. ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
  3. DESCRIPTION
  4. The pam_namespace PAM module sets up a private namespace for a session with
  5. polyinstantiated directories. A polyinstantiated directory provides a different
  6. instance of itself based on user name, or when using SELinux, user name,
  7. security context or both. If an executable script /etc/security/namespace.init
  8. exists, it is used to initialize the instance directory after it is set up and
  9. mounted on the polyinstantiated directory. The script receives the
  10. polyinstantiated directory path, the instance directory path, flag whether the
  11. instance directory was newly created (0 for no, 1 for yes), and the user name
  12. as its arguments.
  13. The pam_namespace module disassociates the session namespace from the parent
  14. namespace. Any mounts/unmounts performed in the parent namespace, such as
  15. mounting of devices, are not reflected in the session namespace. To propagate
  16. selected mount/unmount events from the parent namespace into the disassociated
  17. session namespace, an administrator may use the special shared-subtree feature.
  18. For additional information on shared-subtree feature, please refer to the mount
  19. (8) man page and the shared-subtree description at http://lwn.net/Articles/
  20. 159077 and http://lwn.net/Articles/159092.
  21. OPTIONS
  22. debug
  23. A lot of debug information is logged using syslog
  24. unmnt_remnt
  25. For programs such as su and newrole, the login session has already setup a
  26. polyinstantiated namespace. For these programs, polyinstantiation is
  27. performed based on new user id or security context, however the command
  28. first needs to undo the polyinstantiation performed by login. This argument
  29. instructs the command to first undo previous polyinstantiation before
  30. proceeding with new polyinstantiation based on new id/context
  31. unmnt_only
  32. For trusted programs that want to undo any existing bind mounts and process
  33. instance directories on their own, this argument allows them to unmount
  34. currently mounted instance directories
  35. require_selinux
  36. If selinux is not enabled, return failure
  37. gen_hash
  38. Instead of using the security context string for the instance name,
  39. generate and use its md5 hash.
  40. ignore_config_error
  41. If a line in the configuration file corresponding to a polyinstantiated
  42. directory contains format error, skip that line process the next line.
  43. Without this option, pam will return an error to the calling program
  44. resulting in termination of the session.
  45. ignore_instance_parent_mode
  46. Instance parent directories by default are expected to have the restrictive
  47. mode of 000. Using this option, an administrator can choose to ignore the
  48. mode of the instance parent. This option should be used with caution as it
  49. will reduce security and isolation goals of the polyinstantiation
  50. mechanism.
  51. unmount_on_close
  52. Explicitly unmount the polyinstantiated directories instead of relying on
  53. automatic namespace destruction after the last process in a namespace
  54. exits. This option should be used only in case it is ensured by other means
  55. that there cannot be any processes running in the private namespace left
  56. after the session close. It is also useful only in case there are multiple
  57. pam session calls in sequence from the same process.
  58. use_current_context
  59. Useful for services which do not change the SELinux context with setexeccon
  60. call. The module will use the current SELinux context of the calling
  61. process for the level and context polyinstantiation.
  62. use_default_context
  63. Useful for services which do not use pam_selinux for changing the SELinux
  64. context with setexeccon call. The module will use the default SELinux
  65. context of the user for the level and context polyinstantiation.
  66. mount_private
  67. This option can be used on systems where the / mount point or its submounts
  68. are made shared (for example with a mount --make-rshared / command). The
  69. module will mark the whole directory tree so any mount and unmount
  70. operations in the polyinstantiation namespace are private. Normally the
  71. pam_namespace will try to detect the shared / mount point and make the
  72. polyinstantiated directories private automatically. This option has to be
  73. used just when only a subtree is shared and / is not.
  74. Note that mounts and unmounts done in the private namespace will not affect
  75. the parent namespace if this option is used or when the shared / mount
  76. point is autodetected.
  77. DESCRIPTION
  78. The pam_namespace.so module allows setup of private namespaces with
  79. polyinstantiated directories. Directories can be polyinstantiated based on user
  80. name or, in the case of SELinux, user name, sensitivity level or complete
  81. security context. If an executable script /etc/security/namespace.init exists,
  82. it is used to initialize the namespace every time an instance directory is set
  83. up and mounted. The script receives the polyinstantiated directory path and the
  84. instance directory path as its arguments.
  85. The /etc/security/namespace.conf file specifies which directories are
  86. polyinstantiated, how they are polyinstantiated, how instance directories would
  87. be named, and any users for whom polyinstantiation would not be performed.
  88. When someone logs in, the file namespace.conf is scanned. Comments are marked
  89. by # characters. Each non comment line represents one polyinstantiated
  90. directory. The fields are separated by spaces but can be quoted by " characters
  91. also escape sequences \b, \n, and \t are recognized. The fields are as follows:
  92. polydir instance_prefix method list_of_uids
  93. The first field, polydir, is the absolute pathname of the directory to
  94. polyinstantiate. The special string $HOME is replaced with the user's home
  95. directory, and $USER with the username. This field cannot be blank.
  96. The second field, instance_prefix is the string prefix used to build the
  97. pathname for the instantiation of <polydir>. Depending on the polyinstantiation
  98. method it is then appended with "instance differentiation string" to generate
  99. the final instance directory path. This directory is created if it did not
  100. exist already, and is then bind mounted on the <polydir> to provide an instance
  101. of <polydir> based on the <method> column. The special string $HOME is replaced
  102. with the user's home directory, and $USER with the username. This field cannot
  103. be blank.
  104. The third field, method, is the method used for polyinstantiation. It can take
  105. these values; "user" for polyinstantiation based on user name, "level" for
  106. polyinstantiation based on process MLS level and user name, "context" for
  107. polyinstantiation based on process security context and user name, "tmpfs" for
  108. mounting tmpfs filesystem as an instance dir, and "tmpdir" for creating
  109. temporary directory as an instance dir which is removed when the user's session
  110. is closed. Methods "context" and "level" are only available with SELinux. This
  111. field cannot be blank.
  112. The fourth field, list_of_uids, is a comma separated list of user names for
  113. whom the polyinstantiation is not performed. If left blank, polyinstantiation
  114. will be performed for all users. If the list is preceded with a single "~"
  115. character, polyinstantiation is performed only for users in the list.
  116. The method field can contain also following optional flags separated by :
  117. characters.
  118. create=mode,owner,group - create the polyinstantiated directory. The mode,
  119. owner and group parameters are optional. The default for mode is determined by
  120. umask, the default owner is the user whose session is opened, the default group
  121. is the primary group of the user.
  122. iscript=path - path to the instance directory init script. The base directory
  123. for relative paths is /etc/security/namespace.d.
  124. noinit - instance directory init script will not be executed.
  125. shared - the instance directories for "context" and "level" methods will not
  126. contain the user name and will be shared among all users.
  127. mntopts=value - value of this flag is passed to the mount call when the tmpfs
  128. mount is done. It allows for example the specification of the maximum size of
  129. the tmpfs instance that is created by the mount call. In addition to options
  130. specified in the tmpfs(5) manual the nosuid, noexec, and nodev flags can be
  131. used to respectively disable setuid bit effect, disable running executables,
  132. and disable devices to be interpreted on the mounted tmpfs filesystem.
  133. The directory where polyinstantiated instances are to be created, must exist
  134. and must have, by default, the mode of 0000. The requirement that the instance
  135. parent be of mode 0000 can be overridden with the command line option
  136. ignore_instance_parent_mode
  137. In case of context or level polyinstantiation the SELinux context which is used
  138. for polyinstantiation is the context used for executing a new process as
  139. obtained by getexeccon. This context must be set by the calling application or
  140. pam_selinux.so module. If this context is not set the polyinstatiation will be
  141. based just on user name.
  142. The "instance differentiation string" is <user name> for "user" method and
  143. <user name>_<raw directory context> for "context" and "level" methods. If the
  144. whole string is too long the end of it is replaced with md5sum of itself. Also
  145. when command line option gen_hash is used the whole string is replaced with
  146. md5sum of itself.
  147. EXAMPLES
  148. These are some example lines which might be specified in /etc/security/
  149. namespace.conf.
  150.       # The following three lines will polyinstantiate /tmp,
  151.       # /var/tmp and user's home directories. /tmp and /var/tmp
  152.       # will be polyinstantiated based on the security level
  153.       # as well as user name, whereas home directory will be
  154.       # polyinstantiated based on the full security context and user name.
  155.       # Polyinstantiation will not be performed for user root
  156.       # and adm for directories /tmp and /var/tmp, whereas home
  157.       # directories will be polyinstantiated for all users.
  158.       #
  159.       # Note that instance directories do not have to reside inside
  160.       # the polyinstantiated directory. In the examples below,
  161.       # instances of /tmp will be created in /tmp-inst directory,
  162.       # where as instances of /var/tmp and users home directories
  163.       # will reside within the directories that are being
  164.       # polyinstantiated.
  165.       #
  166.       /tmp     /tmp-inst/               level      root,adm
  167.       /var/tmp /var/tmp/tmp-inst/    level      root,adm
  168.       $HOME    $HOME/$USER.inst/inst- context
  169.     
  170. For the <service>s you need polyinstantiation (login for example) put the
  171. following line in /etc/pam.d/<service> as the last line for session group:
  172. session required pam_namespace.so [arguments]
  173. This module also depends on pam_selinux.so setting the context.