Index of Section 2 Manual Pages
| Interix / SUA | chroot.2 | Interix / SUA |
chroot(2) chroot(2)
chroot()
NAME
chroot(), wcs_chroot() - change root directory
SYNOPSIS
#include
int chroot(const char *directory)
int wcs_chroot(const wchar_t *directory)
DESCRIPTION
The chroot(2) and wcs_chroot(2) functions are identical, except that
wcs_chroot(2) accepts wide characters in the directory argument.
The chroot(2) and wcs_chroot(2) calls make the directory named by
directory the root for the calling process and its children. That is,
pathnames beginning with "/" are taken as relative to directory.
Note that calling chroot(2) or wcs_chroot(2) with the argument / has no
effect; a single-character-long directory argument is ignored, and the
function returns.
Note that if the current working directory is not in the subtree depending
from directory, the calling process can still get access to directories
outside of the chroot(2) limits by using relative pathnames.
Once the current working directory is in the subtree depending from
directory, relative pathnames will no longer refer to directories outside
the chroot(2) limits. Inside the chroot(2) limits, the pathname .. is
taken to mean root.
Symbolic links will be interpreted in the context of the current root.
The traditional way to escape from the chroot(2) limits is to store the
file descriptor for the directory / and use the fchroot() call to escape.
The Interix subsystem does not support fchroot().
RETURN VALUES
The chroot(2) and wcs_chroot(2) calls return 0 for success, and -1 if an
error occurred. They set errno to indicate the cause of the error.
ERRORS
The chroot(2) or wcs_chroot(2) call can fail for the following reasons:
[EACCES]
The process does not have search permission on some component of
directory.
[ELOOP]
Too many symbolic links were encountered.
[ENAMETOOLONG]
The directory is longer than {PATH_MAX} or a component is longer than
{NAME_MAX}, or when resolving symbolic links, an intermediate version
of the name was longer than {PATH_MAX}.
[ENOENT]
Either directory is an empty string, or some component of it doesn't
exist.
[ENOTDIR]
Some component of directory isn't a directory.
[EPERM]
The effective user ID of the process does not have the privileges to
change the root directory.
NOTES
Once a process has used chroot(2) or wcs_chroot(2), it is no longer
allowed to exec(2) Win32 processes. This is done because the Win32
programs will not respect the new value for the root directory.
USAGE NOTES
None of these functions are thread safe.
None of these functions are async-signal safe.