6.29. pam_selinux - set the default security context
Prev | Chapter 6. A reference guide for available modules | Next

## 6.29. pam_selinux - set the default security context

`pam_selinux.so` [ close ] [ debug ] [ open ] [ nottys ] [ verbose ] [ select_context ] [ env_params ] [ use_current_range ]

### 6.29.1. DESCRIPTION

In a nutshell, pam_selinux sets up the default security context for the next execed shell.

When an application opens a session using pam_selinux, the shell that gets executed will be run in the default security context, or if the user chooses and the pam file allows the selected security context. Also the controlling tty will have it's security context modified to match the users.

Adding pam_selinux into a pam file could cause other pam modules to change their behavior if the exec another application. The close and open option help mitigate this problem. close option will only cause the close portion of the pam_selinux to execute, and open will only cause the open portion to run. You can add pam_selinux to the config file twice. Add the pam_selinux close as the executes the open pass through the modules, pam_selinux open_session will happen last. When PAM executes the close pass through the modules pam_selinux close_session will happen first.

### 6.29.2. OPTIONS

`close`

  Only execute the close_session portion of the module.

`debug`

  Turns on debugging via syslog(3).

`open`

  Only execute the open_session portion of the module.

`nottys`

  Do not try to setup the ttys security context.

`verbose`

  attempt to inform the user when security context is set.

`select_context`

  Attempt to ask the user for a custom security context role. If MLS is on ask also for sensitivity level.

`env_params`

  Attempt to obtain a custom security context role from PAM environment. If MLS is on obtain also sensitivity level. This option and the select_context option are mutually exclusive. The respective PAM environment variables are SELINUX_ROLE_REQUESTED, SELINUX_LEVEL_REQUESTED, and SELINUX_USE_CURRENT_RANGE. The first two variables are self describing and the last one if set to 1 makes the PAM module behave as if the use_current_range was specified on the command line of the module.

`use_current_range`

  Use the sensitivity level of the current process for the user context instead of the default level. Also suppresses asking of the sensitivity level from the user or obtaining it from PAM environment.

### 6.29.3. MODULE TYPES PROVIDED

Only the `session` module type is provided.

### 6.29.4. RETURN VALUES

PAM_AUTH_ERR

  Unable to get or set a valid context.

PAM_SUCCESS

  The security context was set successfully.

PAM_USER_UNKNOWN

  The user is not known to the system.

### 6.29.5. EXAMPLES

    auth     required  pam_unix.so
    session  required  pam_permit.so
    session  optional  pam_selinux.so

### 6.29.6. AUTHOR

pam_selinux was written by Dan Walsh <dwalsh@redhat.com>.

Prev | Up | Next
6.28. pam_securetty - limit root login to special devices | Home | 6.30. pam_shells - check for valid login shell