print yum.__version__ instead of executing "yum --version" which is very heavyweighte...
[util-vserver.git] / scripts / vserver.suexec
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
27 user=$1
28 shift
29
30 cd "$VSERVER_DIR"/vdir/
31
32 test -z "$OPTION_NONAMESPACE" || USE_VNAMESPACE=
33
34 if $_VSERVER_INFO - FEATURE migrate; then
35     if test -z "$is_stopped"; then
36         exec \
37         "${IONICE_CMD[@]}" \
38         "${NICE_CMD[@]}" \
39         "${CHBIND_CMD[@]}" \
40         $_EXEC_ULIMIT "$VSERVER_DIR/ulimits" \
41         ${USE_VNAMESPACE:+$_VNAMESPACE --enter "$S_CONTEXT" -- } \
42         $_VSPACE --enter "$S_CONTEXT" "${OPTS_VSPACE[@]}" -- \
43         $_VTAG --migrate "${OPTS_VTAG_ENTER[@]}" --silent -- \
44         $_VCONTEXT $SILENT_OPT --migrate --chroot \
45           --xid "$S_CONTEXT" --uid "$user" "${OPTS_VCONTEXT_ENTER[@]}" -- \
46         "$@"
47     else
48         exec \
49         "${IONICE_CMD[@]}" \
50         "${NICE_CMD[@]}" \
51         "${CHBIND_CMD[@]}" \
52         $_EXEC_ULIMIT "$VSERVER_DIR/ulimits" \
53         $_VTAG --create "${OPTS_VTAG_CREATE[@]}" --silent -- \
54         $_VCONTEXT --create "${OPTS_VCONTEXT_CREATE[@]}" -- \
55         $_VUNAME   --xid self --dir "$VSERVER_DIR"/uts     --missingok -- \
56         $_VUNAME   --xid self --set -t context="$VSERVER_DIR" -- \
57         $_VCONTEXT --migrate-self --endsetup --chroot $SILENT_OPT -- \
58         "$@"
59     fi
60 else
61     exec \
62     "${IONICE_CMD[@]}" \
63     "${NICE_CMD[@]}" \
64     "${CHBIND_CMD[@]}" \
65     "$_EXEC_ULIMIT"  "$VSERVER_DIR/ulimits" \
66     ${USE_VNAMESPACE:+$_VNAMESPACE --enter "$S_CONTEXT" --} \
67     $_CHCONTEXT_COMPAT "${CHCONTEXT_OPTS[@]}" -- \
68     "$_CAPCHROOT"    "${CAPCHROOT_OPTS[@]}" --suid "$user" . \
69     "$@"
70 fi