Source-Changes-HG archive

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

[src/netbsd-1-5]: src/etc pull up revs 1.22-1.23:



details:   https://anonhg.NetBSD.org/src/rev/422fdb39957a
branches:  netbsd-1-5
changeset: 489202:422fdb39957a
user:      lukem <lukem%NetBSD.org@localhost>
date:      Wed Aug 23 11:31:54 2000 +0000

description:
pull up revs 1.22-1.23:
        add ${name}_chroot support

approved: thorpej

diffstat:

 etc/rc.subr |  23 +++++++++++++++++++----
 1 files changed, 19 insertions(+), 4 deletions(-)

diffs (62 lines):

diff -r e9406e7a742b -r 422fdb39957a etc/rc.subr
--- a/etc/rc.subr       Wed Aug 23 09:17:27 2000 +0000
+++ b/etc/rc.subr       Wed Aug 23 11:31:54 2000 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: rc.subr,v 1.20.2.1 2000/08/09 18:40:25 lukem Exp $
+# $NetBSD: rc.subr,v 1.20.2.2 2000/08/23 11:31:54 lukem Exp $
 #
 # Copyright (c) 1997-2000 The NetBSD Foundation, Inc.
 # All rights reserved.
@@ -185,12 +185,17 @@
 #                              the action should be run.
 #                              If this variable isn't set, ${name} is checked 
 #                              instead.
-#      ${name}_chdir   n       Directory to cd to before running ${command}.
+#      ${name}_chroot  n       Directory to chroot to before running ${command}
+#      ${name}_chdir   n       Directory to cd to before running ${command}
+#                              (if not using ${name}_chroot).
 #      ${name}_flags   n       Arguments to call ${command} with.
 #                              NOTE:   if $flags is set (e.g, from the parent
 #                                      environment), it overrides this.
 #      ${name}_nice    n       Nice level to run ${command} at.
-#      ${name}_user    n       User to run ${command} as.
+#      ${name}_user    n       User to run ${command} as, using su(1) if not
+#                              using ${name}_chroot.
+#      ${name}_group   n       Group to run chrooted ${command} as.
+#      ${name}_groups  n       Group list to run chrooted ${command} with.
 #      ${_arg}_cmd     n       If set, use this as the action when invoked;
 #                              $_arg is available to the action to use.
 #                              Otherwise, use default command (see below)
@@ -271,8 +276,11 @@
                eval _flags=\$${name}_flags
        fi
        eval _chdir=\$${name}_chdir
+       eval _chroot=\$${name}_chroot
        eval _nice=\$${name}_nice
        eval _user=\$${name}_user
+       eval _group=\$${name}_group
+       eval _groups=\$${name}_groups
 
        eval $_pidcmd
 
@@ -333,12 +341,19 @@
 
                        eval $_precmd || return 1
                        echo "Starting ${name}."
-                       _doit="\
+                       if [ -n "$_chroot" ]; then
+                               _doit="\
+${_nice:+nice -n $_nice }\
+chroot ${_user:+-u $_user }${_group:+-g $_group }${_groups:+-G $_groups }\
+$_chroot $command $_flags $command_args"
+                       else
+                               _doit="\
 ${_user:+su -m $_user -c 'sh -c \"}\
 ${_chdir:+cd $_chdir; }\
 ${_nice:+nice -n $_nice }\
 $command $_flags $command_args\
 ${_user:+\"'}"
+                       fi
                        eval $_doit
                        ;;
 



Home | Main Index | Thread Index | Old Index