Unix to Windows Porting Dictionary for HPC

Links

Function List

chroot


Table of Contents

Unix
Windows
Purpose
Discussion

Unix

header files: unistd.h

int int chroot(const char *directory);
int int wcs_chroot(const wchar_t *directory);

Windows

header file: n/a

Purpose

Change the root directory for a program.

Discussion

The Unix chroot function changes the root directory for a program causing its view of the filesystem to change. Unix system use a single rooted filesystem that allows for this single point of change to have a broad effect. Files and directories outside of the new root are no longer visible to the program. Because of this chroot is often used as a security tool to restrict a program's access to certain files. A chroot environment is usually a selectively chosen subset of file from the main root to create an environment that the program can fully, but limitly, work.

On Windows systems the filesystems are multi-rooted and the system does not provide a method to change the view of the filesystems to a program. When porting code from Unix that use chroot there is no direct mapping of functionality. It is regularly argued with Unix security people that chroot should not be used as a security tool or "jail" to isolate a program from accessing files. On Windows systems with the more complex ACL file security the logically equivalent intent on the Unix system may be achieved with finely tuned file and directory ACL's instead. If chroot is used on the Unix system to create different versions of the environment so the program behaves differently then a better method should be implemented anyway.

blog comments powered by Disqus