vshost-util-vserver

Build script and sources for util-vserver.
git clone https://ccx.te2000.cz/git/vshost-util-vserver
Log | Files | Refs

vserver.suexec (2725B)


      1 # $Id$  --*- sh -*--
      2 
      3 # Copyright (C) 2003 Enrico Scholz <enrico.scholz@informatik.tu-chemnitz.de>
      4 #  
      5 # This program is free software; you can redistribute it and/or modify
      6 # it under the terms of the GNU General Public License as published by
      7 # the Free Software Foundation; version 2 of the License.
      8 #  
      9 # This program is distributed in the hope that it will be useful,
     10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
     11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     12 # GNU General Public License for more details.
     13 #  
     14 # You should have received a copy of the GNU General Public License
     15 # along with this program; if not, write to the Free Software
     16 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
     17 
     18 is_stopped=
     19 isVserverRunning "$VSERVER_DIR" S_CONTEXT || is_stopped=1
     20 test -z "$is_stopped" -o "$OPTION_INSECURE" || {
     21     echo $"'vserver ... suexec' is supported for running vservers only; aborting..." >&2
     22     exit 1
     23 }
     24 generateOptions  "$VSERVER_DIR"
     25 addtoCPUSET      "$VSERVER_DIR"
     26 attachToCgroup   "$VSERVER_DIR"
     27 enterNetNS       "$VSERVER_DIR"
     28 
     29 user=$1
     30 shift
     31 
     32 cd "$VSERVER_DIR"/vdir/
     33 
     34 test -z "$OPTION_NONAMESPACE" || USE_VNAMESPACE=
     35 
     36 if $_VSERVER_INFO - FEATURE migrate; then
     37     if test -z "$is_stopped"; then
     38 	exec \
     39 	"${IONICE_CMD[@]}" \
     40 	"${NICE_CMD[@]}" \
     41 	"${NETNS_CMD[@]}" \
     42 	"${CHBIND_CMD[@]}" \
     43 	$_EXEC_ULIMIT "$VSERVER_DIR/ulimits" \
     44 	${USE_VNAMESPACE:+$_VSPACE --mount --fs --enter "$S_CONTEXT" -- } \
     45 	$_VSPACE --enter "$S_CONTEXT" "${OPTS_VSPACE[@]}" "${OPTS_VSPACE_SHARED[@]}" -- \
     46 	$_VTAG --migrate "${OPTS_VTAG_ENTER[@]}" --silent -- \
     47 	$_VCONTEXT $SILENT_OPT --migrate $OPT_VCONTEXT_CHROOT $OPT_VCONTEXT_CLOSE_FD \
     48 	  --xid "$S_CONTEXT" --uid "$user" "${OPTS_VCONTEXT_ENTER[@]}" -- \
     49 	"$@"
     50     else
     51 	exec \
     52 	"${IONICE_CMD[@]}" \
     53 	"${NICE_CMD[@]}" \
     54 	"${CHBIND_CMD[@]}" \
     55 	$_EXEC_ULIMIT "$VSERVER_DIR/ulimits" \
     56 	$_VTAG --create "${OPTS_VTAG_CREATE[@]}" --silent -- \
     57 	$_VSPACE --new "${OPTS_VSPACE[@]}" ${USE_VNAMESPACE:+--mount --fs} -- \
     58         $_VCONTEXT --create "${OPTS_VCONTEXT_CREATE[@]}" -- \
     59 	$_VSPACE --set "${OPTS_VSPACE[@]}" ${USE_VNAMESPACE:+--mount --fs} -- \
     60 	$_VUNAME   --xid self --dir "$VSERVER_DIR"/uts --missingok -- \
     61 	$_VUNAME   --xid self --set -t context="$VSERVER_DIR" -- \
     62 	$_VCONTEXT --migrate-self --endsetup $OPT_VCONTEXT_CHROOT $SILENT_OPT -- \
     63 	"$@"
     64     fi
     65 else
     66     exec \
     67     "${IONICE_CMD[@]}" \
     68     "${NICE_CMD[@]}" \
     69     "${CHBIND_CMD[@]}" \
     70     "$_EXEC_ULIMIT"  "$VSERVER_DIR/ulimits" \
     71     ${USE_VNAMESPACE:+$_VSPACE "${OPTS_VSPACE[@]}" --mount --fs --enter "$S_CONTEXT" --} \
     72     $_CHCONTEXT_COMPAT "${CHCONTEXT_OPTS[@]}" -- \
     73     "$_CAPCHROOT"    "${CAPCHROOT_OPTS[@]}" --suid "$user" . \
     74     "$@"
     75 fi