*BSD News Article 37799


Return to BSD News archive

Xref: sserve comp.os.386bsd.bugs:2592 comp.os.386bsd.questions:14410
Path: sserve!newshost.anu.edu.au!harbinger.cc.monash.edu.au!bunyip.cc.uq.oz.au!munnari.oz.au!constellation!convex!insosf1.infonet.net!solaris.cc.vt.edu!news.mathworks.com!udel!news.sprintlink.net!pipex!uunet!psinntp!uprc.com!cygnus!z056716
From: z056716@uprc.com (LaCoursiere J. D. (Jeff))
Newsgroups: comp.os.386bsd.bugs,comp.os.386bsd.questions
Subject: chroot() in FreeBSD 1.1.5.1
Date: 11 Nov 1994 14:38:30 GMT
Organization: Union Pacific Resources Corp.
Lines: 34
Distribution: world
Message-ID: <39vvl6$90m@clavin.uprc.com>
Reply-To: z056716@uprc.com
NNTP-Posting-Host: cygnus.uprc.com
Keywords: chroot permissions

I spent several hours last night attempting to debug a small piece of code:

main()
{
	if (chroot("/bbs") < 0) {
		perror("chroot");
	}
}

This snippet was running as the user "bbs" with a non-zero uid.  The
chroot(2) manpage says all that is required is that the target be a
true directory (it is) and have search (execute) perms.  Executing
the snippet returns:

chroot: Operation not permitted.

I attempted to change the ownership of the directory, change its perms
to 777, and running the snippet as root.  As you might guess, all failed
but the last (it runs fine as root).  At the moment I have the relevant
code (in the real program I was trying to debug) setuid to root at execution
time for the chroot(), then setuid() back to the bbs user before fork/exec.
I tried to mount my FreeBSD1.1 CD and check out the source for chroot(),
but I loaned my good copy to a friend and (wouldn't you know it) the chroot()
source is on one of the bad spots in the original 1.1 CD...(groan).

Big question:  why can't normal users call chroot???

Jeff LaCoursiere
Network Admin
UPRC
Ft. Worth, TX