Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/netbsd-1-5]: src/lib/libc/sys Pull up revision 1.13 (requested by kleink):



details:   https://anonhg.NetBSD.org/src/rev/595b825fa6ff
branches:  netbsd-1-5
changeset: 491347:595b825fa6ff
user:      he <he%NetBSD.org@localhost>
date:      Tue Apr 24 22:38:36 2001 +0000

description:
Pull up revision 1.13 (requested by kleink):
  Document fchroot(2).

diffstat:

 lib/libc/sys/chroot.2 |  34 ++++++++++++++++++++++++++++++++--
 1 files changed, 32 insertions(+), 2 deletions(-)

diffs (73 lines):

diff -r ca40bae03bd2 -r 595b825fa6ff lib/libc/sys/chroot.2
--- a/lib/libc/sys/chroot.2     Tue Apr 24 22:32:08 2001 +0000
+++ b/lib/libc/sys/chroot.2     Tue Apr 24 22:38:36 2001 +0000
@@ -1,4 +1,4 @@
-.\"    $NetBSD: chroot.2,v 1.12 1999/12/02 21:42:36 kleink Exp $
+.\"    $NetBSD: chroot.2,v 1.12.4.1 2001/04/24 22:38:36 he Exp $
 .\"
 .\" Copyright (c) 1983, 1991, 1993
 .\"    The Regents of the University of California.  All rights reserved.
@@ -33,7 +33,7 @@
 .\"
 .\"     @(#)chroot.2   8.1 (Berkeley) 6/4/93
 .\"
-.Dd June 4, 1993
+.Dd April 18, 2001
 .Dt CHROOT 2
 .Os
 .Sh NAME
@@ -45,6 +45,8 @@
 .Fd #include <unistd.h>
 .Ft int
 .Fn chroot "const char *dirname"
+.Ft int
+.Fn fchroot "int fd"
 .Sh DESCRIPTION
 .Fa dirname
 is the address of the pathname of a directory, terminated by an ASCII NUL.
@@ -66,6 +68,12 @@
 has no effect on the process's current directory.
 .Pp
 This call is restricted to the super-user.
+.Pp
+The
+.Fn fchroot
+function performs the same operation on an open directory file
+known by the file descriptor
+.Fa fd .
 .Sh RETURN VALUES
 Upon successful completion, a value of 0 is returned.  Otherwise,
 a value of -1 is returned and
@@ -95,6 +103,24 @@
 .It Bq Er EIO
 An I/O error occurred while reading from or writing to the file system.
 .El
+.Pp
+.Fn fchroot
+will fail and the root directory will be unchanged if:
+.Bl -tag -width Er
+.It Bq Er EACCES
+Search permission is denied for the directory referenced
+by the file descriptor.
+.It Bq Er EBADF
+The argument
+.Fa fd
+is not a valid file descriptor.
+.It Bq Er EIO
+An I/O error occurred while reading from or writing to the file system.
+.It Bq Er ENOTDIR
+The argument
+.Fa fd
+does not reference a directory.
+.El
 .Sh SEE ALSO
 .Xr chdir 2
 .Sh HISTORY
@@ -107,3 +133,7 @@
 to prevent one way a process could use a second 
 .Fn chroot
 call to a different directory to "escape" from the restricted subtree.
+The
+.Fn fchroot
+function appeared in
+.Nx 1.4 .



Home | Main Index | Thread Index | Old Index