7b1b3e7
#!/bin/bash
7b1b3e7
## BEGIN INIT INFO
7b1b3e7
# Provides: sandbox
7b1b3e7
# Default-Start: 5
7b1b3e7
# Default-Stop: 0 1 2 3 4 6
7b1b3e7
# Required-Start:
7b1b3e7
#              
7b1b3e7
## END INIT INFO
7b1b3e7
# sandbox:        Set up / mountpoint to be shared, /var/tmp, /tmp, /home/sandbox unshared
7b1b3e7
#
7b1b3e7
# chkconfig: 5 1 99
7b1b3e7
#
7b1b3e7
# Description: sandbox is using pam_namespace to share the /var/tmp, /tmp and 
7b1b3e7
#              /home/sandbox accounts.  This script will setup the / mount 
7b1b3e7
#              point as shared and all of the subdirectories just these 
7b1b3e7
#              directories as unshared.
7b1b3e7
#
7b1b3e7
7b1b3e7
# Source function library.
7b1b3e7
. /etc/init.d/functions
7b1b3e7
7b1b3e7
LOCKFILE=/var/lock/subsys/sandbox
7b1b3e7
7b1b3e7
base=${0##*/}
7b1b3e7
7b1b3e7
case "$1" in
7b1b3e7
    start)
7b1b3e7
	[ -f "$LOCKFILE" ] && exit 0
7b1b3e7
7b1b3e7
	touch $LOCKFILE
7b1b3e7
	mount --make-rshared /
7b1b3e7
	mount --bind /tmp /tmp
7b1b3e7
	mount --bind /var/tmp /var/tmp
7b1b3e7
	mount --bind /home /home
7b1b3e7
	mount --make-private /home
7b1b3e7
	mount --make-private /tmp
7b1b3e7
	mount --make-private /var/tmp
7b1b3e7
	RETVAL=$?
7b1b3e7
	exit $RETVAL
7b1b3e7
	;;
7b1b3e7
7b1b3e7
    status)
7b1b3e7
	if [ -f "$LOCKFILE" ]; then 
7b1b3e7
	    echo "$base is running"
7b1b3e7
	else
7b1b3e7
	    echo "$base is stopped"
7b1b3e7
	fi
7b1b3e7
	exit 0
7b1b3e7
	;;
7b1b3e7
7b1b3e7
    stop)
7b1b3e7
	rm -f $LOCKFILE
7b1b3e7
	exit 0
7b1b3e7
	;;
7b1b3e7
7b1b3e7
    *)
7b1b3e7
	echo $"Usage: $0 {start|stop}"
7b1b3e7
	exit 3
7b1b3e7
	;;
7b1b3e7
esac