Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

chroot(2) [osx man page]

CHROOT(2)						      BSD System Calls Manual							 CHROOT(2)

NAME
chroot -- change root directory SYNOPSIS
#include <unistd.h> int chroot(const char *dirname); DESCRIPTION
Dirname is the address of the pathname of a directory, terminated by an ASCII NUL. Chroot() causes dirname to become the root directory, that is, the starting point for path searches of pathnames beginning with '/'. In order for a directory to become the root directory a process must have execute (search) access for that directory. If the program is not currently running with an altered root directory, it should be noted that chroot() has no effect on the process's cur- rent directory. If the program is already running with an altered root directory, the process's current directory is changed to the same new root directory. This prevents the current directory from being further up the directory tree than the altered root directory. This call is restricted to the super-user. RETURN VALUES
Upon successful completion, a value of 0 is returned. Otherwise, a value of -1 is returned and errno is set to indicate an error. ERRORS
Chroot() will fail and the root directory will be unchanged if: [ENOTDIR] A component of the path name is not a directory. [ENAMETOOLONG] A component of a pathname exceeded {NAME_MAX} characters, or an entire path name exceeded {PATH_MAX} characters. [ENOENT] The named directory does not exist. [EACCES] Search permission is denied for any component of the path name. [ELOOP] Too many symbolic links were encountered in translating the pathname. [EFAULT] Path points outside the process's allocated address space. [EIO] An I/O error occurred while reading from or writing to the file system. SEE ALSO
chdir(2) WARNINGS
There are ways for a root process to escape from the chroot jail. HISTORY
The chroot() function call appeared in 4.2BSD. 4.2 Berkeley Distribution June 4, 1993 4.2 Berkeley Distribution

Check Out this Related Man Page

CHROOT(2)							System Calls Manual							 CHROOT(2)

NAME
chroot - change root directory SYNOPSIS
#include <unistd.h> int chroot(const char *dirname) DESCRIPTION
Dirname is the address of the pathname of a directory, terminated by a null byte. Chroot causes this directory to become the root direc- tory, the starting point for path names beginning with ``/''. In order for a directory to become the root directory a process must have execute (search) access to the directory. This call is restricted to the super-user. RETURN VALUE
Upon successful completion, a value of 0 is returned. Otherwise, a value of -1 is returned and errno is set to indicate an error. ERRORS
Chroot will fail and the root directory will be unchanged if one or more of the following are true: [ENOTDIR] A component of the path name is not a directory. [ENAMETOOLONG] The path name exceeds PATH_MAX characters. [ENOENT] The named directory does not exist. [EACCES] Search permission is denied for any component of the path name. [ELOOP] Too many symbolic links were encountered in translating the pathname. (Minix-vmd) [EFAULT] Path points outside the process's allocated address space. [EIO] An I/O error occurred while reading from or writing to the file system. SEE ALSO
chdir(2). 4.2 Berkeley Distribution August 26, 1985 CHROOT(2)
Man Page

15 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

? question mark, how to get back to the root directory

hiyas I am trying to get back to the root directory: I went into MAIL directory and now I can't get back to the root directory. What are the commands... I have '?' coming up and I cannot proceed with this, HELP Cheers (1 Reply)
Discussion started by: etravels
1 Replies

2. UNIX for Dummies Questions & Answers

Message trying to list contents of directory

I'm getting this return whenever I try to do anything on a directory root# ls -al /directory ls: .: Value too large to be stored in data type. total 0 I can change directory down two levels but can not list contents of the root of this directory. ANy one seen this? (1 Reply)
Discussion started by: sallender
1 Replies

3. UNIX for Advanced & Expert Users

can hanging perl process wipe out a directory?

Hi, This weekend i left a perl script running , I was running it in a remote machine. The machine seems to have been rebooted during the weekend. When i got back on monday the entire directory containing the script was wiped out. The process had been aborted. Nobody has access to the directory... (2 Replies)
Discussion started by: aboxilica
2 Replies

4. UNIX for Dummies Questions & Answers

How to get the path of a file in UNIX?

Hi Frindz, I want to get the entire path of a file. I am in root directory and i know the file name, However dont know the path where it is. Please tell me the command to get the entire path for the file? Thanks in advance, Rashmy. (14 Replies)
Discussion started by: smr_rashmy
14 Replies

5. Shell Programming and Scripting

Question on Verifying root's current directory

From a script how would I verify that the current directory (.) is not in root's path. Now when the script is going to be run the auditor wil not be signed in as root, but rather running it via sudo, so I'm thinking the standard $path won't work for that case. Derek:confused: (3 Replies)
Discussion started by: sport
3 Replies

6. UNIX for Dummies Questions & Answers

how to find a path within unix root directory

I need to know whether nyfile/mypath exists on the file system in the root directory. How to do this (1 Reply)
Discussion started by: ramky79
1 Replies

7. UNIX for Dummies Questions & Answers

Get directory address

what is the command that print the full address of the directory that im in it? (1 Reply)
Discussion started by: nirnir26
1 Replies

8. UNIX for Advanced & Expert Users

Damaged root directory ..

With the cpio command of a Unix File System for error I have replaced the directory “.. “ (when you give the command “ls -la” under root you see at the beginning the hidden directory “. “ followed by a hidden file who is called “..” ) I have the copy on a cartridge of the whole file system, but... (3 Replies)
Discussion started by: SISQUEZ
3 Replies

9. Solaris

setfacl on a directory

Hi All, I am trying to set an ACL for a directory on my Solaris 10 box. I have an application which resides under /opt/CA directory. Application is installed by root and running as root. All log and configuration files are placed under /opt/CA as well. What I am trying to do is granting... (1 Reply)
Discussion started by: niyazi
1 Replies

10. UNIX for Advanced & Expert Users

Chroot jail environment puzzle

I have a simple sandbox program which runs a command as user "nobody" in a chroot jail. It sets resource limits with setrlimit, changes the user id with setuid, changes the root dir with chroot, and then calls exec to execute the command given as command line parameters. It is of course a... (8 Replies)
Discussion started by: john.english
8 Replies

11. Solaris

Access Denied

Hi All, I have a root access for one of the server. But, when i try to cd one particular directory i will get the access denied message. Even though that particular directory is created under root. What would be the cause for this? I really wonder if any one have answer for my... (20 Replies)
Discussion started by: Sricharan21
20 Replies

12. Solaris

Find path of executable having problem

Hi cannot find the path to a running process on a host. I looked and tried some suggestions in forums to no avail. can someone please help? I need to know where this process is starting from as we have several versions in multiple directories --------- Process name 1201 1 0 Feb 14 ?... (14 Replies)
Discussion started by: mnassiri
14 Replies

13. UNIX for Dummies Questions & Answers

Removing directory with leading hyphen from root directory

I know that this basic question has been asked many times and solutions all over the internet, but none of the are working for me. I have a directory in the root directory, named "-p". # ls -l / total 198 <snip> drwxr-xr-x 4 root root 4096 Dec 3 14:18 opt drwxr-xr-x 2 root ... (2 Replies)
Discussion started by: edstevens
2 Replies

14. UNIX for Beginners Questions & Answers

Why does a fakechroot exist?

I am really confused as to why a tool like fakechroot exists and what does it do. Chroot is an ability only for root users, correct? Then a tool that allows to bypass that is clearly a security flaw, correct? When and why would you need something like this? Is there any relation between... (7 Replies)
Discussion started by: sreyan32
7 Replies

15. UNIX for Advanced & Expert Users

Stop root from writing to directory

Is there a way to stop root from writing to a directory? I already tried chattr but that did not seem to work. chattr +i directory (12 Replies)
Discussion started by: cokedude
12 Replies