[alt.sources] [comp.sys.tahoe] Re: Need "chroot

bostic@ucbvax.BERKELEY.EDU (Keith Bostic) (02/07/90)

Archive-name: chroot/bsd-tahoe
Original-posting-by: bostic@ucbvax.BERKELEY.EDU (Keith Bostic)
Original-subject: Re: Need "chroot(8)" Sources
Reposted-by: emv@math.lsa.umich.edu (Edward Vielmetti)

[This is an experimental alt.sources re-posting from the newsgroup(s)
comp.sys.tahoe. Comments on this service to emv@math.lsa.umich.edu 
(Edward Vielmetti).]


In article <1990Jan22.172627.16417@uncecs.edu>, khj@uncecs.edu (Kenneth H. Jacker) writes:
> I have looked through the entire /tahoe/* tree, as well as the archives
> on uunet and ucbvax, but still have been unable to locate machine
> readable copies of
> 
> 	Makefile, chroot.8, chroot.c, pathnames.h and strerror.c

Here's chroot and strerror.c.

--keith

# This is a shell archive.  Save it in a file, remove anything before
# this line, and then unpack it by entering "sh file".  Note, it may
# create directories; files and directories will be owned by you and
# have default permissions.
#
# This archive contains:
#
#	Makefile
#	chroot.8
#	chroot.c
#	strerror.c
#
echo x - Makefile
sed 's/^X//' >Makefile << 'END-of-Makefile'
X#
X# Copyright (c) 1989 The Regents of the University of California.
X# All rights reserved.
X#
X# Redistribution and use in source and binary forms are permitted
X# provided that the above copyright notice and this paragraph are
X# duplicated in all such forms and that any documentation,
X# advertising materials, and other materials related to such
X# distribution and use acknowledge that the software was developed
X# by the University of California, Berkeley.  The name of the
X# University may not be used to endorse or promote products derived
X# from this software without specific prior written permission.
X# THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
X# IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
X# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
X#
X#	@(#)Makefile	5.2 (Berkeley) 4/18/89
X#
X
XCFLAGS=	-O
XLIBC=	/lib/libc.a
XSRCS=	chroot.c
XOBJS=
XMAN=	chroot.0
X
Xall: chroot
X
Xchroot: ${LIBC}
X	${CC} -o $@ ${CFLAGS} $@.c
X
Xclean:
X	rm -f ${OBJS} core chroot
X
Xcleandir: clean
X	rm -f ${MAN} tags .depend
X
Xdepend: ${SRCS}
X	mkdep -p ${CFLAGS} ${SRCS}
X
Xinstall: ${MAN}
X	install -s -o bin -g bin -m 755 chroot ${DESTDIR}/usr/sbin
X	install -c -o bin -g bin -m 444 ${MAN} ${DESTDIR}/usr/man/cat8
X
Xlint: ${SRCS}
X	lint ${CFLAGS} ${SRCS}
X
Xtags: ${SRCS}
X	ctags ${SRCS}
END-of-Makefile
echo x - chroot.8
sed 's/^X//' >chroot.8 << 'END-of-chroot.8'
X.\" Copyright (c) 1988 The Regents of the University of California.
X.\" All rights reserved.
X.\"
X.\" Redistribution and use in source and binary forms are permitted
X.\" provided that the above copyright notice and this paragraph are
X.\" duplicated in all such forms and that any documentation,
X.\" advertising materials, and other materials related to such
X.\" distribution and use acknowledge that the software was developed
X.\" by the University of California, Berkeley.  The name of the
X.\" University may not be used to endorse or promote products derived
X.\" from this software without specific prior written permission.
X.\" THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
X.\" IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
X.\" WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
X.\"
X.\"	@(#)chroot.8	5.1 (Berkeley) 12/5/88
X.\"
X.TH CHROOT 8 "December 5, 1988"
X.UC 6
X.SH NAME
Xchroot \- change root directory
X.SH SYNOPSIS
X.B chroot newroot [ command ]
X.SH DESCRIPTION
XThe
X.I chroot
Xcommand changes its root directory to the supplied directory
X.I newroot
Xand exec's
X.IR command ,
Xif supplied, or an interactive copy of your shell (as specified
Xby the environmental variable
X.IR SHELL )
Xif not.
X.I /bin/sh
Xis used if
X.I SHELL
Xis not specified.
X.PP
XNote,
X.I command
Xor the shell are run as your real-user-id.
X.SH "SEE ALSO"
Xchdir(2), chroot(2), environ(7)
END-of-chroot.8
echo x - chroot.c
sed 's/^X//' >chroot.c << 'END-of-chroot.c'
X/*
X * Copyright (c) 1988 The Regents of the University of California.
X * All rights reserved.
X *
X * Redistribution and use in source and binary forms are permitted
X * provided that the above copyright notice and this paragraph are
X * duplicated in all such forms and that any documentation,
X * advertising materials, and other materials related to such
X * distribution and use acknowledge that the software was developed
X * by the University of California, Berkeley.  The name of the
X * University may not be used to endorse or promote products derived
X * from this software without specific prior written permission.
X * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
X * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
X * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
X */
X
X#ifndef lint
Xchar copyright[] =
X"@(#) Copyright (c) 1988 The Regents of the University of California.\n\
X All rights reserved.\n";
X#endif /* not lint */
X
X#ifndef lint
Xstatic char sccsid[] = "@(#)chroot.c	5.5 (Berkeley) 5/11/89";
X#endif /* not lint */
X
X#include <stdio.h>
X#include <paths.h>
X
Xmain(argc, argv)
X	int argc;
X	char **argv;
X{
X	extern int errno;
X	char *shell, *getenv(), *strerror();
X
X	if (argc < 2) {
X		fprintf(stderr, "usage: chroot newroot [command]\n");
X		exit(1);
X	}
X	if (chdir(argv[1]) || chroot(argv[1]))
X		fatal(argv[1]);
X	setuid(getuid());
X	if (argv[2]) {
X		execvp(argv[2], &argv[2]);
X		fatal(argv[2]);
X	} else {
X		if (!(shell = getenv("SHELL")))
X			shell = _PATH_BSHELL;
X		execlp(shell, shell, "-i", (char *)NULL);
X		fatal(shell);
X	}
X	/* NOTREACHED */
X}
X
Xfatal(msg)
X	char *msg;
X{
X	extern int errno;
X
X	fprintf(stderr, "chroot: %s: %s\n", msg, strerror(errno));
X	exit(1);
X}
END-of-chroot.c
echo x - strerror.c
sed 's/^X//' >strerror.c << 'END-of-strerror.c'
X/*
X * Copyright (c) 1988 Regents of the University of California.
X * All rights reserved.
X *
X * Redistribution and use in source and binary forms are permitted
X * provided that the above copyright notice and this paragraph are
X * duplicated in all such forms and that any documentation,
X * advertising materials, and other materials related to such
X * distribution and use acknowledge that the software was developed
X * by the University of California, Berkeley.  The name of the
X * University may not be used to endorse or promote products derived
X * from this software without specific prior written permission.
X * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
X * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
X * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
X */
X
X#if defined(LIBC_SCCS) && !defined(lint)
Xstatic char sccsid[] = "@(#)strerror.c	5.1 (Berkeley) 4/9/89";
X#endif /* LIBC_SCCS and not lint */
X
Xchar *
Xstrerror(errnum)
X	int errnum;
X{
X	extern int sys_nerr;
X	extern char *sys_errlist[];
X	static char ebuf[20];
X
X	if ((unsigned int)errnum < sys_nerr)
X		return(sys_errlist[errnum]);
X	(void)sprintf(ebuf, "Unknown error: %d", errnum);
X	return(ebuf);
X}
END-of-strerror.c
exit