CHDIR(2) CHDIR(2) NAME chdir, chroot - change working or root directory SYNOPSIS chdir(dirname) char *dirname; 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, defined when the system is built. Login(1) initially sets the working directory as specified in the password file, passwd(5). 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) DIAGNOSTICS Zero is returned if the directory was changed; -1 is returned if the given pathname doesn't exist, isn't a direc- tory or can't be searched, or if chroot is used by other than the super-user. BUGS Using chroot, it is quite easy to fool set-UID programs about the contents of the password file (for example).