:index:`File <triple: sandboxing; type; File>`
##############################################
.. index::
    triple: sandboxing; type; path

The *File* sandbox type can be used for sandboxing users to filesystem paths. It has one required parameter, ``path``, which is the path in the filesystem where the users will be sandboxed to.

For convenience, *File* sandbox configuration can be simplified into just a path. See :ref:`sandboxing-file-simplified_form_example` example.


Configuration Options
=====================

.. glossary::

    :index:`type <triple: sandbox type; File; type>`
        Type of the sandbox. For File type, set to ``File``.

    :index:`path <triple: sandbox type; File; path>`
        Path where user should be sandboxed.

.. _sandboxing-file-placeholders:

Placeholders
============

When specifying ``path`` for :term:`system sandbox` or :term:`global sandbox`, placeholders can be used to represent dynamic values. The valid placeholders are:

=========== =============
Placeholder Replaced with
=========== =============
``%u``      Username
``%d``      Domain
``%f``      Full username [#]_
``%%``      ``%``
=========== =============

.. [#] Full username may include ``\`` or ``@``. Platform dependent.

.. tip::

    Path :ref:`placeholders <sandboxing-file-placeholders>` are also supported in the simplified form.


Examples
========

.. _sandboxing-file-simplified_form_example:

Simplified form
---------------

To sandbox all users into ``/data`` directory using the command line:

.. code-block:: shell-session

    admin@server# jetstream server --sandbox-dir /data

The equivalent of the above example using the API:

.. code-block:: python

    > api.server.setSandboxMapping("", {"": "/data"})

The equivalent of the above examples using the full *File* notation would be:

.. code-block:: python

    > api.server.setSandboxMapping("", {"": { "type": "File", "path": "/data"}})

Placeholders
------------

.. code-block:: python

    > api.server.setSandboxMapping("", {"": { "type": "File", "path": "/home/%u"}})
