man(1) Manual page archive


     CHDIR(2)                                                 CHDIR(2)

     NAME
          chdir, chroot - change working or root directory

     SYNOPSIS
          int chdir(dirname)
          char *dirname;

          int chroot(dirname)
          char *dirname;

     DESCRIPTION
          Chdir changes the working directory of the invoking process
          to dirname; chroot changes its root directory.

          The root directory is the starting point when searching for
          pathnames beginning with `/'.  The working directory is the
          starting point for pathnames that don't.  The root directory
          normally points to the system root.  Login(8) initially sets
          the working directory as specified in the password file.

          After chroot, it is impossible to name a file outside the
          subtree rooted at the current root, provided that the cur-
          rent directory is located within the subtree and there are
          no links pointing outside the subtree (except for the entry
          `..'  in the root directory).

          Chroot may only be used by the super-user.

     SEE ALSO
          sh(1), passwd(5)

     DIAGNOSTICS
          EACCES, EFAULT, EIO, ELOOP, ENOENT, ENOTDIR, EPERM (chroot
          only)

     BUGS
          Using chroot, it is quite easy to fool set-userid programs
          about the contents of the password file (for example).