{
    "content": [
        {
            "type": "text",
            "text": "# PAM_NAMESPACE(8) (man)\n\n**Summary:** pamnamespace - PAM module for configuring namespace for a session\n\n**Synopsis:** pamnamespace.so [debug] [unmntremnt] [unmntonly] [requireselinux] [genhash]\n[ignoreconfigerror] [ignoreinstanceparentmode] [unmountonclose]\n[usecurrentcontext] [usedefaultcontext] [mountprivate]\n\n## Examples\n\n- `For the <service>s you need polyinstantiation (login for example) put the following line in`\n- `/etc/pam.d/<service> as the last line for session group:`\n- `session required pamnamespace.so [arguments]`\n- `To use polyinstantiation with graphical display manager gdm, insert the following line,`\n- `before exit 0, in /etc/gdm/PostSession/Default:`\n- `/usr/sbin/gdm-safe-restart`\n- `This allows gdm to restart after each session and appropriately adjust namespaces of display`\n- `manager and the X server. If polyinstantiation of /tmp is desired along with the graphical`\n- `environment, then additional configuration changes are needed to address the interaction of X`\n- `server and font server namespaces with their use of /tmp to create communication sockets.`\n- `Please use the initialization script /etc/security/namespace.init to ensure that the X server`\n- `and its clients can appropriately access the communication socket X0. Please refer to the`\n- `sample instructions provided in the comment section of the instance initialization script`\n- `/etc/security/namespace.init. In addition, perform the following changes to use graphical`\n- `environment with polyinstantiation of /tmp:`\n- `1. Disable the use of font server by commenting out \"FontPath\"`\n- `line in /etc/X11/xorg.conf. If you do want to use the font server`\n- `then you will have to augment the instance initialization`\n- `script to appropriately provide /tmp/.font-unix from the`\n- `polyinstantiated /tmp.`\n- `2. Ensure that the gdm service is setup to use pamnamespace,`\n- `as described above, by modifying /etc/pam.d/gdm.`\n- `3. Ensure that the display manager is configured to restart X server`\n- `with each new session. This default setup can be verified by`\n- `making sure that /usr/share/gdm/defaults.conf contains`\n- `\"AlwaysRestartServer=true\", and it is not overridden by`\n- `/etc/gdm/custom.conf.`\n\n## See Also\n\n- namespace.conf(5)\n- pam.d(5)\n- mount(8)\n- pam(7)\n\n## Section Outline\n\n- **NAME** (2 lines)\n- **SYNOPSIS** (4 lines)\n- **DESCRIPTION** (16 lines)\n- **OPTIONS** (1 lines) — 1 subsections\n  - debug (61 lines)\n- **MODULE TYPES PROVIDED** (3 lines)\n- **RETURN VALUES** (9 lines)\n- **FILES** (9 lines)\n- **EXAMPLES** (35 lines)\n- **SEE ALSO** (2 lines)\n- **AUTHORS** (8 lines)\n\n## Full Content\n\n### NAME\n\npamnamespace - PAM module for configuring namespace for a session\n\n### SYNOPSIS\n\npamnamespace.so [debug] [unmntremnt] [unmntonly] [requireselinux] [genhash]\n[ignoreconfigerror] [ignoreinstanceparentmode] [unmountonclose]\n[usecurrentcontext] [usedefaultcontext] [mountprivate]\n\n### DESCRIPTION\n\nThe pamnamespace PAM module sets up a private namespace for a session with polyinstantiated\ndirectories. A polyinstantiated directory provides a different instance of itself based on\nuser name, or when using SELinux, user name, security context or both. If an executable\nscript /etc/security/namespace.init exists, it is used to initialize the instance directory\nafter it is set up and mounted on the polyinstantiated directory. The script receives the\npolyinstantiated directory path, the instance directory path, flag whether the instance\ndirectory was newly created (0 for no, 1 for yes), and the user name as its arguments.\n\nThe pamnamespace module disassociates the session namespace from the parent namespace. Any\nmounts/unmounts performed in the parent namespace, such as mounting of devices, are not\nreflected in the session namespace. To propagate selected mount/unmount events from the\nparent namespace into the disassociated session namespace, an administrator may use the\nspecial shared-subtree feature. For additional information on shared-subtree feature, please\nrefer to the mount(8) man page and the shared-subtree description at\nhttp://lwn.net/Articles/159077 and http://lwn.net/Articles/159092.\n\n### OPTIONS\n\n#### debug\n\nA lot of debug information is logged using syslog\n\nunmntremnt\nFor programs such as su and newrole, the login session has already setup a\npolyinstantiated namespace. For these programs, polyinstantiation is performed based on\nnew user id or security context, however the command first needs to undo the\npolyinstantiation performed by login. This argument instructs the command to first undo\nprevious polyinstantiation before proceeding with new polyinstantiation based on new\nid/context\n\nunmntonly\nFor trusted programs that want to undo any existing bind mounts and process instance\ndirectories on their own, this argument allows them to unmount currently mounted instance\ndirectories\n\nrequireselinux\nIf selinux is not enabled, return failure\n\ngenhash\nInstead of using the security context string for the instance name, generate and use its\nmd5 hash.\n\nignoreconfigerror\nIf a line in the configuration file corresponding to a polyinstantiated directory\ncontains format error, skip that line process the next line. Without this option, pam\nwill return an error to the calling program resulting in termination of the session.\n\nignoreinstanceparentmode\nInstance parent directories by default are expected to have the restrictive mode of 000.\nUsing this option, an administrator can choose to ignore the mode of the instance parent.\nThis option should be used with caution as it will reduce security and isolation goals of\nthe polyinstantiation mechanism.\n\nunmountonclose\nExplicitly unmount the polyinstantiated directories instead of relying on automatic\nnamespace destruction after the last process in a namespace exits. This option should be\nused only in case it is ensured by other means that there cannot be any processes running\nin the private namespace left after the session close. It is also useful only in case\nthere are multiple pam session calls in sequence from the same process.\n\nusecurrentcontext\nUseful for services which do not change the SELinux context with setexeccon call. The\nmodule will use the current SELinux context of the calling process for the level and\ncontext polyinstantiation.\n\nusedefaultcontext\nUseful for services which do not use pamselinux for changing the SELinux context with\nsetexeccon call. The module will use the default SELinux context of the user for the\nlevel and context polyinstantiation.\n\nmountprivate\nThis option can be used on systems where the / mount point or its submounts are made\nshared (for example with a mount --make-rshared / command). The module will mark the\nwhole directory tree so any mount and unmount operations in the polyinstantiation\nnamespace are private. Normally the pamnamespace will try to detect the shared / mount\npoint and make the polyinstantiated directories private automatically. This option has to\nbe used just when only a subtree is shared and / is not.\n\nNote that mounts and unmounts done in the private namespace will not affect the parent\nnamespace if this option is used or when the shared / mount point is autodetected.\n\n### MODULE TYPES PROVIDED\n\nOnly the session module type is provided. The module must not be called from multithreaded\nprocesses.\n\n### RETURN VALUES\n\nPAMSUCCESS\nNamespace setup was successful.\n\nPAMSERVICEERR\nUnexpected system error occurred while setting up namespace.\n\nPAMSESSIONERR\nUnexpected namespace configuration error occurred.\n\n### FILES\n\n/etc/security/namespace.conf\nMain configuration file\n\n/etc/security/namespace.d\nDirectory for additional configuration files\n\n/etc/security/namespace.init\nInit script for instance directories\n\n### EXAMPLES\n\nFor the <service>s you need polyinstantiation (login for example) put the following line in\n/etc/pam.d/<service> as the last line for session group:\n\nsession required pamnamespace.so [arguments]\n\nTo use polyinstantiation with graphical display manager gdm, insert the following line,\nbefore exit 0, in /etc/gdm/PostSession/Default:\n\n/usr/sbin/gdm-safe-restart\n\nThis allows gdm to restart after each session and appropriately adjust namespaces of display\nmanager and the X server. If polyinstantiation of /tmp is desired along with the graphical\nenvironment, then additional configuration changes are needed to address the interaction of X\nserver and font server namespaces with their use of /tmp to create communication sockets.\nPlease use the initialization script /etc/security/namespace.init to ensure that the X server\nand its clients can appropriately access the communication socket X0. Please refer to the\nsample instructions provided in the comment section of the instance initialization script\n/etc/security/namespace.init. In addition, perform the following changes to use graphical\nenvironment with polyinstantiation of /tmp:\n\n1. Disable the use of font server by commenting out \"FontPath\"\nline in /etc/X11/xorg.conf. If you do want to use the font server\nthen you will have to augment the instance initialization\nscript to appropriately provide /tmp/.font-unix from the\npolyinstantiated /tmp.\n2. Ensure that the gdm service is setup to use pamnamespace,\nas described above, by modifying /etc/pam.d/gdm.\n3. Ensure that the display manager is configured to restart X server\nwith each new session. This default setup can be verified by\nmaking sure that /usr/share/gdm/defaults.conf contains\n\"AlwaysRestartServer=true\", and it is not overridden by\n/etc/gdm/custom.conf.\n\n### SEE ALSO\n\nnamespace.conf(5), pam.d(5), mount(8), pam(7).\n\n### AUTHORS\n\nThe namespace setup scheme was designed by Stephen Smalley, Janak Desai and Chad Sellers. The\npamnamespace PAM module was developed by Janak Desai <janak@us.ibm.com>, Chad Sellers\n<csellers@tresys.com> and Steve Grubb <sgrubb@redhat.com>. Additional improvements by Xavier\nToth <txtoth@gmail.com> and Tomas Mraz <tmraz@redhat.com>.\n\n\n\nLinux-PAM Manual                             06/08/2020                             PAMNAMESPACE(8)\n\n"
        }
    ],
    "structuredContent": {
        "command": "PAM_NAMESPACE",
        "section": "8",
        "mode": "man",
        "summary": "pamnamespace - PAM module for configuring namespace for a session",
        "synopsis": "pamnamespace.so [debug] [unmntremnt] [unmntonly] [requireselinux] [genhash]\n[ignoreconfigerror] [ignoreinstanceparentmode] [unmountonclose]\n[usecurrentcontext] [usedefaultcontext] [mountprivate]",
        "flags": [],
        "examples": [
            "For the <service>s you need polyinstantiation (login for example) put the following line in",
            "/etc/pam.d/<service> as the last line for session group:",
            "session required pamnamespace.so [arguments]",
            "To use polyinstantiation with graphical display manager gdm, insert the following line,",
            "before exit 0, in /etc/gdm/PostSession/Default:",
            "/usr/sbin/gdm-safe-restart",
            "This allows gdm to restart after each session and appropriately adjust namespaces of display",
            "manager and the X server. If polyinstantiation of /tmp is desired along with the graphical",
            "environment, then additional configuration changes are needed to address the interaction of X",
            "server and font server namespaces with their use of /tmp to create communication sockets.",
            "Please use the initialization script /etc/security/namespace.init to ensure that the X server",
            "and its clients can appropriately access the communication socket X0. Please refer to the",
            "sample instructions provided in the comment section of the instance initialization script",
            "/etc/security/namespace.init. In addition, perform the following changes to use graphical",
            "environment with polyinstantiation of /tmp:",
            "1. Disable the use of font server by commenting out \"FontPath\"",
            "line in /etc/X11/xorg.conf. If you do want to use the font server",
            "then you will have to augment the instance initialization",
            "script to appropriately provide /tmp/.font-unix from the",
            "polyinstantiated /tmp.",
            "2. Ensure that the gdm service is setup to use pamnamespace,",
            "as described above, by modifying /etc/pam.d/gdm.",
            "3. Ensure that the display manager is configured to restart X server",
            "with each new session. This default setup can be verified by",
            "making sure that /usr/share/gdm/defaults.conf contains",
            "\"AlwaysRestartServer=true\", and it is not overridden by",
            "/etc/gdm/custom.conf."
        ],
        "see_also": [
            {
                "name": "namespace.conf",
                "section": "5",
                "url": "https://www.chedong.com/phpMan.php/man/namespace.conf/5/json"
            },
            {
                "name": "pam.d",
                "section": "5",
                "url": "https://www.chedong.com/phpMan.php/man/pam.d/5/json"
            },
            {
                "name": "mount",
                "section": "8",
                "url": "https://www.chedong.com/phpMan.php/man/mount/8/json"
            },
            {
                "name": "pam",
                "section": "7",
                "url": "https://www.chedong.com/phpMan.php/man/pam/7/json"
            }
        ],
        "section_outline": [
            {
                "name": "NAME",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "SYNOPSIS",
                "lines": 4,
                "subsections": []
            },
            {
                "name": "DESCRIPTION",
                "lines": 16,
                "subsections": []
            },
            {
                "name": "OPTIONS",
                "lines": 1,
                "subsections": [
                    {
                        "name": "debug",
                        "lines": 61
                    }
                ]
            },
            {
                "name": "MODULE TYPES PROVIDED",
                "lines": 3,
                "subsections": []
            },
            {
                "name": "RETURN VALUES",
                "lines": 9,
                "subsections": []
            },
            {
                "name": "FILES",
                "lines": 9,
                "subsections": []
            },
            {
                "name": "EXAMPLES",
                "lines": 35,
                "subsections": []
            },
            {
                "name": "SEE ALSO",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "AUTHORS",
                "lines": 8,
                "subsections": []
            }
        ]
    }
}