I came across the function os.chroot()
and well if I understand that it is to change the root, but I wonder what I want/is it for changing the root, that is, what is the use of this function?
I came across the function os.chroot()
and well if I understand that it is to change the root, but I wonder what I want/is it for changing the root, that is, what is the use of this function?
What is it for?
According to the documentation, the function
os.chroot()
:This command what you do is call the command
chroot(2)
:Processes in Unix-like systems have their own Current Working Directory, which is also known as the Root Directory, by changing the Root Directory of a process with
os.chroot()
you change it also for all its child processes that can be to create.To see the Root Directory of a process you can use the command
pwdx
that receives the PID of the process. For example:This process of modifying the Root Directory is known as "chroot jail" or "chroot cage" since it prevents the process and its threads (children) from accessing a level higher than the specified one.
What uses does it have?
Basically the idea is to isolate a process to:
References