3 # Copyright (C) 2003,2004,2005,2006 Enrico Scholz <enrico.scholz@informatik.tu-chemnitz.de>
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.
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.
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.
23 declare -r _VS_NEWLINE=${_VS_NEWLINE:0-1}
24 declare -r VS_ALLVSERVERS_ARGS=all,marked,unmarked,stopped,running
35 test -n "$_fo_i" || continue
36 test ! $_fo_mod "$_fo_i" || { _fo_file=$_fo_i; break; }
39 test -z "$_fo_i" -o -n "$_fo_file" || {
40 echo "Can not find file for '$_fo_var'; aborting"
44 eval "$_fo_var=\"$_fo_file\""
60 test ! -s "$dst" || return 0
66 test -n "$tmp" -a -s "$tmp" || return 0
67 $_CP -af "$tmp" "$dst"
70 ## Usage: isRegularFile <filename> [<mod>]
71 function isRegularFile
73 test ${2:--f} "$1" || return 1
76 (*.rpmsave|*.rpmnew|*.rpmorig|*.cfsaved*|*.~*~) return 1;;
82 function getPhysicalDir
84 ( set -P && cd "$1" && pwd )
87 ## Usage:: isDirectoryEmpty <dir> [<ignore-lost+found>]
88 function isDirectoryEmpty
92 shopt -s nullglob || *
95 test -z "$2" -o "$2" = 0 || ignore_lostfound=
100 test "$ignore_lostfound" || exit 1
102 (*) echo "$i"; exit 1
110 ## Usage: logging <message>
113 if test -n "$_VS_LOGFILE"; then
114 echo "$@" >>"$_VS_LOGFILE"
120 ## Usage: warning <message>
123 if test -n "$_VS_ERRFILE"; then
124 echo "$@" >>"$_VS_ERRFILE"
130 ## Usage: panic <message>
133 if test -n "$_VS_ERRFILE"; then
134 echo "$@" >>"$_VS_ERRFILE"
142 ## Usage: execute <message>
145 test -z "${DEBUG_EXEC:-}" || echo "$@"
146 test "${DEBUG_EXEC:-}" = noexec || exec "$@"
151 ## Usage: spawn <message>
154 test -z "${DEBUG_EXEC:-}" || echo "$@"
155 test "${DEBUG_EXEC:-}" = noexec || "$@"
158 ## Usage: isNumber <arg>
162 let tmp=$1+0 2>/dev/null || test -z "${1//0/}" -a -n "$1" || return 1
166 ## Usage: hasSubstring <haystack> <needle>+
167 function hasSubstring
175 test x"${pat/*$i*/$i}" = x"$i" || continue
182 ## Usage: colorize <style> <command>
192 findFile cfile "$__CONFDIR"/.defaults/styles/"$style" ''
193 if test -n "$cfile"; then
197 (bold) echo -ne "\e[1m";;
198 (emph) echo -ne "\e[34m";;
199 (info) echo -ne "\e[0;34m";;
200 (warn*) echo -ne "\e[1;31m";;
201 (error) echo -ne "\e[1;33;41m";;
213 if test -n "$_VS_ERRFILE"; then
214 echo "$@" >>"$_VS_ERRFILE"
216 colorize error echo -n "$@" >&2
225 colorize warning warning "$@"
230 colorize info echo "$@"
234 ## Usage: xtermTitle <title>
238 echo -ne "\e]0;$@\007"
242 ## Usage: lock <lockfile> [<timeout>]
245 local tmp=$($_MKTEMP vserver-lock.XXXXXX)
249 $_LOCKFILE "$1" $tmp $2 &
250 $_GREP -q true $tmp 2>/dev/null || return 1
252 _VS_LOCKS="$! $_VS_LOCKS"
255 ## Usage: unlock [<num>]
262 while test "$#" -gt 0; do
263 kill -HUP "$1" >/dev/null || :
265 test "$num" != 1 || break
266 test -z "$num" || let --num
271 function get_init_cwd
273 if test -n "$INIT_CWD"; then
279 function set_init_cwd
285 function _getVserverDir
289 ./*) VSERVER_DIR="`get_init_cwd`/$vserver";;
290 /*) VSERVER_DIR="$vserver" ;;
291 *) VSERVER_DIR="$__CONFDIR/$vserver" ;;
295 function _pkgMountBindDir()
297 test "$1" != "$2" || return 0
299 $_MOUNT -n --bind "$1" "$2"
302 function _pkgSetVarsBase
306 if test -d "$vserver/vdir"; then
308 VDIR=$(getPhysicalDir "$vserver/vdir")
310 PKGDIR=$BASEDIR/apps/pkgmgmt
311 test -d "$PKGDIR" || {
312 echo "Can not find configuration-directory for package-managment tools"
315 findDir EXECDIR $PKGDIR/execdir /
317 VDIR=$(getPhysicalDir "$vserver")
322 BASEDIR=$__CONFDIR/$vserver
323 test -d "$BASEDIR" || {
324 echo "Can not find configuration-directory"
329 test -d "$VDIR" || VDIR=$__DEFAULT_VSERVERDIR/$vserver
330 VDIR=$(getPhysicalDir "$VDIR")
332 PKGDIR=$BASEDIR/apps/pkgmgmt
333 test -d "$PKGDIR" || {
334 echo "Can not find configuration-directory for package-managment tools"
338 findDir EXECDIR $PKGDIR/execdir /
343 if test -z "$WORKAROUND_106057"; then
346 _rpmdb_mntpoint=/.rpmdb
350 function _pkgSetVarsRPM
352 if test -n "$PKGDIR"; then
353 findDir RPMETCDIR $PKGDIR/rpmetc $PKGDIR/base/rpm/etc /etc/rpm
354 findDir RPMSTATEDIR $PKGDIR/rpmstate $PKGDIR/base/rpm/state
356 findDir RPMLIBDIR $PKGDIR/rpmlib /
359 findDir RPMETCDIR "$VDIR"/etc/rpm /etc/rpm
360 findDir RPMSTATEDIR "$VDIR"/var/lib/rpm
364 RPMSTATEDIR=$(getPhysicalDir "$RPMSTATEDIR")
365 RPMETCDIR=$(getPhysicalDir "$RPMETCDIR")
368 function _pkgSetVarsApt
370 if test -n "$PKGDIR"; then
371 findDir APTETCDIR $PKGDIR/aptetc $PKGDIR/base/apt/etc /etc/apt
372 findDir APTSTATEDIR $PKGDIR/aptstate $PKGDIR/base/apt/state
373 findDir APTCACHEDIR $PKGDIR/aptcache $PKGDIR/base/apt/cache
374 findDir APTARCHIVDIR $PKGDIR/aptarchives $PKGDIR/base/apt/archives /var/cache/apt/archives
376 findDir APTETCDIR "$VDIR"/etc/apt /etc/apt
377 findDir APTSTATEDIR "$VDIR"/var/state/apt
378 findDir APTCACHEDIR "$VDIR"/var/cache/apt
379 findDir APTARCHIVDIR "$VDIR"/var/cache/apt/archives /var/cache/apt/archives
382 findFile APT_CONFIG "$APTETCDIR"/apt.conf ""
383 test -z "$APT_CONFIG" || export APT_CONFIG
386 function _pkgSetVarsYum
388 if test -n "$PKGDIR"; then
389 findDir YUMETCDIR $PKGDIR/yumetc $PKGDIR/base/yum/etc /etc
390 findDir YUMCACHEDIR $PKGDIR/yumcache $PKGDIR/base/yum/cache
392 findDir YUMETCDIR "$VDIR"/etc /etc
393 findDir YUMCACHEDIR "$VDIR"/var/cache/yum
398 function _pkgMountBase
403 function _pkgMountApt
408 function _pkgMountYum
413 function _pkgMountRPM
415 _pkgMountBindDir "$RPMETCDIR" /etc/rpm
416 test "$RPMLIBDIR" = "/" || _pkgMountBindDir "$RPMLIBDIR" /usr/lib/rpm
418 pushd "$VDIR" >/dev/null
420 $_SECURE_MOUNT --chroot -n --bind "$RPMSTATEDIR" "$_rpmdb_mntpoint"
421 test -z "$WORKAROUND_106057" || mount -n --bind "$RPMSTATEDIR" "$_rpmdb_mntpoint"
423 test -e "$VDIR"/proc/self/status || \
424 $_SECURE_MOUNT --chroot -n -t proc none /proc
429 function _pkgSetEnvBase
431 test "$EXECDIR" = "/" || {
433 LD_LIBRARY_PATH=$EXECDIR${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}
436 export PATH LD_LIBRARY_PATH
439 function _pkgSetEnvApt
444 function _pkgSetEnvYum
449 function _pkgSetEnvRPM
452 RPM_FAKE_NAMESPACE_MOUNTS=$_rpmdb_mntpoint
453 RPM_BINARY=$_VRPM_PRELOAD
455 export CUR_VSERVER RPM_FAKE_NAMESPACE_MOUNTS RPM_BINARY
467 rpm) _pkgSetVarsRPM;;
468 apt) _pkgSetVarsApt;;
469 yum) _pkgSetVarsYum;;
470 *) echo "Unknown packaging flavor" >&2; exit 1;;
493 _PKG_VSERVER=$vserver
496 function isAvoidNamespace
500 $_VSERVER_INFO - FEATURE namespace || return 0
501 cfgdir=$($_VSERVER_INFO "$1" CFGDIR) || return 0
502 test ! -e "$cfgdir"/namespace || return 1
503 test -e "$__CONFDIR"/.defaults/nonamespace -o \
504 -e "$cfgdir"/nonamespace
507 function isNamespaceCleanup
511 $_VSERVER_INFO - FEATURE namespace || return 1
512 cfgdir=$($_VSERVER_INFO "$1" CFGDIR) || return 1
513 test -e "$cfgdir"/namespace-cleanup && return 0
514 test -e "$cfgdir"/nonamespace-cleanup -o \
515 -e "$__CONFDIR"/.defaults/nonamespace-cleanup && return 1
519 ## Usage: getAllVservers <var> [<KIND>*]
520 function getAllVservers
523 declare -a _ga_tmp=()
525 for _ga_i in $__CONFDIR/*; do
526 isRegularFile "$_ga_i" -d || continue
528 test ! -e "$_ga_i"/disabled || continue
529 test -d "$_ga_i"/vdir || continue
532 local _ga_markfile=$_ga_i/apps/init/mark
535 (MARKED) test -s "$_ga_markfile" || _ga_doadd=;;
536 (UNMARKED) test ! -s "$_ga_markfile" || _ga_doadd=;;
537 (STOPPED) ! $_VSERVER "$_ga_i" running &>/dev/null || _ga_doadd=;;
538 (RUNNING) $_VSERVER "$_ga_i" running &>/dev/null || _ga_doadd=;;
540 (*) panic $"Unknown vserver tagging '$2'";;
543 test -z "$_ga_doadd" || _ga_tmp=( "${_ga_tmp[@]}" "${_ga_i##$__CONFDIR/}")
546 eval $1='( "${_ga_tmp[@]}" )'
549 ## Usage: getAllVserversByArg <var> <arg>
550 function getAllVserversByArg
555 (--all) _gav_mark=ALL;;
556 (--marked) _gav_mark=MARKED;;
557 (--unmarked) _gav_mark=UNMARKED;;
558 (--stopped) _gav_mark=STOPPED;;
559 (--running) _gav_mark=RUNNING;;
563 getAllVservers "$1" "$_gav_mark"
566 ## Usage: _getProcNumberCount <ctx> <var>
567 function _getProcNumberCount
570 local _gp_procnr_cnt=0
572 # Use /proc/virtual from kernel 2.6 when possible
573 if test -d "/proc/virtual"; then
574 set -- $($_GREP '^PROC:' "/proc/virtual/$1/limit" 2>/dev/null)
577 _gp_procnr_cnt=$($_VPS ax | $_AWK '{print $2}' | $_GREP -x "$1" | $_WC -l )
580 let _gp_procnr_cnt=_gp_procnr_cnt+0
581 eval $_gp_var=\$_gp_procnr_cnt
584 ## Usage: getVserverCtx <vdir> <result-varname> [<procnumber-varname> [<do-cleanup>]]
585 ## Returns: 0 iff vserver is running
586 function getVserverStatus
588 test -r "$1"/run || return 1
591 read _gvs_ctx <"$1"/run
594 test -n "$3" || return 0
596 _getProcNumberCount "$_gvs_ctx" _gvs_tmp
599 if test "$_gvs_tmp" = 0; then
600 local runfile=$($_READLINK "$1/run")
601 test -z "$4" || $_RM -f "$runfile"
608 ## Usage: isCtxRunning <ctx>
609 function isCtxRunning
612 _getProcNumberCount "$1" _tmp
616 ## Usage: isVserverRunning <vdir> [<ctx-varname>]
617 function isVserverRunning
619 local _ivr_ctx _ivr_procnum
621 getVserverStatus "$1" _ivr_ctx _ivr_procnum 1 || return 1
622 test "$_ivr_procnum" != 0 || return 1
623 test -z "$2" || eval "$2"=\$_ivr_ctx
627 ## Called as 'getFileValue <varname> <filename>+'
628 function getFileValue
634 findFile _gfv_file "$@" ''
635 test -n "$_gfv_file" -a -r "$_gfv_file" || return 0
636 eval read "$_gfv_var" <"$_gfv_file"
639 ## Called as 'getFileArray <varname> <filename>+'
640 function getFileArray
646 findFile _gfa_file "$@" ''
647 test -n "$_gfa_file" -a -r "$_gfa_file" || return 0
648 local IFS=$_VS_NEWLINE
649 eval "$_gfa_var"='( $(< "$_gfa_file") )'
652 function checkComponents
663 (core) test -x "$_CHBIND" || failed=1;;
664 (build) test -x "$_VSERVER_BUILD" || failed=1;;
665 (sysv) test -x "$__INITRDDIR/vserver" || failed=1;;
666 (devel) test -d "$__INCLUDEDIR/vserver.h" || failed=1;;
667 (*) echo "Unknown component '$i'" >&2
672 test -z "$failed" || {
681 ## Usage: isKernelAPI <ver> [<cmp-modifier>]
685 api=$($_VSERVER_INFO - APIVER) || api=0
686 test $[ $api ] -${2:-ge} $[ $1 ]
689 ## Usage: callInNamespace <vserver> <command> <args>*
690 function callInNamespace
694 isAvoidNamespace "$1" || \
695 ctx=$( $_VSERVER_INFO "$1" CONTEXT f ) || ctx=
698 if test -n "$ctx"; then
699 $_VNAMESPACE --enter "$ctx" -- "$@"
705 ## Usage: setDefaultTTY <vdir> [<fallback-tty>]
706 function setDefaultTTY
710 cfgdir=$($_VSERVER_INFO "$1" APPDIR init) || cfgdir=
711 findObject -e ttyname \
712 ${cfgdir:+"$cfgdir"/tty} \
713 "$__CONFDIR/.defaults/apps/init/tty" \
720 ## Usage: killContext <XID> [<SIG>]
725 #$_VKILL -s STOP --xid "$1" 1 &>/dev/null || :
726 $_VKILL -s "$sig" --xid "$1" 1 &>/dev/null || :
727 $_VKILL -s "$sig" --xid "$1" &>/dev/null || :
728 #$_VKILL -s "$sig" --xid "$1" 1 &>/dev/null || :
729 #$_VKILL -s CONT --xid "$1" 1 &>/dev/null || :
734 test ! -e "$__CONFDIR/.defaults/apps/vlogin/disable"
737 ## Usage: pkgmgmt.guessStyle <vserver> <resultvar>
738 function pkgmgmt.guessStyle()
741 _pgs_vdir=$($_VSERVER_INFO "$1" VDIR) || {
742 echo $"Can not determine vserver-root" >&2
745 local _pgs_cfgdir=$($_VSERVER_INFO "$1" APPDIR pkgmgmt) || :
747 if test -n "$_pgs_cfgdir" -a -e "$_pgs_cfgdir"/style; then
748 read style <"$_pgs_cfgdir"/style
749 elif test -e "$_pgs_vdir"/etc/redhat-release -o -e "$_pgs_vdir"/etc/fedora-release; then
751 elif test -e "$_pgs_vdir"/etc/mandrake-release; then
753 elif test -e "$_pgs_vdir"/etc/debian_version; then
755 elif test -e "$_pgs_vdir"/etc/SuSE-release; then
758 echo $"Can not determine packagemanagement style" >&2
766 ## Usage: pkgmgmt.isInternal <vserver>
767 ## returns true iff <vserver> is configured for internal packagemanagement
768 ## A typical application is
770 ## | pkgmgmt.isInternal "$vserver" || is_external=1
771 function pkgmgmt.isInternal
773 local cfgdir=$($_VSERVER_INFO "$1" APPDIR pkgmgmt) || :
775 test -z "$cfgdir" -o ! -d "$cfgdir" -o -e "$cfgdir"/internal
778 ## Usage: pkgmgmt.isAptAvailable <cfgdir> <vdir> [<is-internal>]
779 function pkgmgmt.isAptAvailable
783 local is_internal="$3"
786 if test -n "$is_internal"; then
788 test -d "$cfgdir"/base/apt -o -d "$cfgdir"/aptetc || have_apt=
791 for i in /bin /usr/bin /usr/local/bin; do
792 test ! -x "$vdir$i"/apt-get || { have_apt=1; break; }
796 test -n "$have_apt" && return 0 || return 1
799 ## Usage: pkgmgmt.isYumAvailable <cfgdir> <vdir> [<is-internal>]
800 function pkgmgmt.isYumAvailable
804 local is_internal="$3"
807 if test -n "$is_internal"; then
809 test -d "$cfgdir"/base/yum -o -d "$cfgdir"/yumetc || have_yum=
812 for i in /bin /usr/bin /usr/local/bin; do
813 test ! -x "$vdir$i"/yum || { have_yum=1; break; }
817 test -n "$have_yum" && return 0 || return 1
821 function vshelper.doSanityCheck
823 local vshelper this_xid i
824 declare -a warnings=()
825 local solution_disable=
826 local solution_sysctl=
828 vshelper.isEnabled && vshelper.isEnabled warning || return 0
830 this_xid=$($_VSERVER_INFO - XID) ||
831 panic $"Failed to determine current context; aborting..."
833 ## Do nothing in other xid's; the helper will be executed in xid 0 only
834 test "$this_xid" = 0 || return 0
836 local proc_file=/proc/sys/kernel/vshelper
838 if ! test -r "$proc_file"; then
840 warnings=( "${warnings[@]}"
841 $"File '$proc_file' does not exist but is required for vshelper setup" )
844 vshelper=$(cat "$proc_file")
846 $_CMP -s "$vshelper" "$_VSHELPER" || {
847 warnings=( "${warnings[@]}"
848 $"The configured vshelper '$vshelper' does not match the 'vshelper'
849 script of the util-vserver package"
856 test -d "$__VSHELPERSTATEDIR" || {
857 warnings=( "${warnings[@]}"
859 The vshelper state-directory '$__VSHELPERSTATEDIR' does not exist; since
860 it is created by 'make install', this indicates a serious problem with
861 your util-vserver installation" )
865 test "${#warnings[@]}" -eq 0 || {
867 The following problem(s) were encountered while verifying vshelper
870 for i in "${warnings[@]}"; do
876 To fix this, you can:"
878 test -z "$solution_disable" || warning $"\
879 * disable vshelper entirely by executing
880 | touch \"$__CONFDIR/.defaults/apps/vshelper/disabled\"
881 * disable only this message by executing
882 | touch \"$__CONFDIR/.defaults/apps/vshelper/warning-disabled\""
884 test -x "$solution_sysctl" || warning $"\
885 * configure the util-vserver vshelper script, e.g. by adding
886 | kernel.vshelper = $_VSHELPER
887 to /etc/sysctl.conf and rebooting the machine, or by executing
888 | echo \"$_VSHELPER\" >$proc_file"
898 ## Usage: vshelper.isEnabled [<style>] [<vserver>]
899 function vshelper.isEnabled
901 local f=${1:+$1-}disabled
902 test ! -e "$__CONFDIR"/.defaults/apps/vshelper/"$f" || return 1
903 $_VSERVER_INFO - FEATURE vshelper || return 1
904 if test -n "$2"; then
906 appdir=$($_VSERVER_INFO "$2" APPDIR vshelper) || return 0
907 test -z "$2" -o ! -e "$appdir/$f" || return 1
913 ## Usage: vshelper.isDebug [<vserver>]
914 function vshelper.isDebug
916 test ! -e "$__CONFDIR"/.defaults/apps/vshelper/debug || return 0
917 $_VSERVER_INFO - FEATURE vshelper || return 1
918 if test -n "$1"; then
920 appdir=$($_VSERVER_INFO "$1" APPDIR vshelper) || return 1
921 test ! -e "$appdir/debug" || return 0
927 function vshelper._getHandlerInternal
932 shift ## HACK: see below the note about the 'set -u' mode
934 while test "$#" -ge 2; do
939 test "$_vghi_mod" "$_vghi_obj" || continue
942 eval $_vghi_var=\$_vghi_obj
945 read _vghi_tmp <"$_vghi_obj"
946 eval $_vghi_var=:\$_vghi_tmp
948 (*) panic $"Internal error, unexpected modifier '$_vghi_mod'"
956 ## Usage: vshelper.getHandler <result-var> <vserver> <action>
957 function vshelper.getHandler
960 _vgh_appdir=$($_VSERVER_INFO "$2" APPDIR vshelper) || _vgh_appdir=
962 declare -a _vgh_search_list=( X )
963 ## HACK: when we are in 'set -u' mode, empty lists are causing errors
965 test -z "$_vgh_appdir" || _vgh_search_list=( "${_vgh_search_list[@]}" -x "$_vgh_appdir/$3" )
966 test -z "$_vgh_appdir" || _vgh_search_list=( "${_vgh_search_list[@]}" -e "$_vgh_appdir/action" )
967 _vgh_search_list=( "${_vgh_search_list[@]}" -x "$__CONFDIR"/.defaults/apps/vshelper/"$3" )
968 _vgh_search_list=( "${_vgh_search_list[@]}" -e "$__CONFDIR"/.defaults/apps/vshelper/action )
970 ! vshelper._getHandlerInternal "$1" "${_vgh_search_list[@]}" || return 0
974 ## Usage: vshelper.init <vserver> [<method> <args>*]
975 function vshelper.doInit
977 vshelper.isEnabled || return 0
980 xid=$($_VSERVER_INFO "$1" CONTEXT false) && test -n "$xid" || {
981 warning $"vshelper.init: can not determine xid of vserver '$vserver'; returned value was '$xid'"
985 local f="$__VSHELPERSTATEDIR/$xid"
992 if test -n "$2"; then
1005 ## Usage: vshelper.doDestroy <vserver> <xid>
1006 function vshelper.doDestroy
1008 vshelper.isEnabled || return 0
1010 $_RM -f "$__VSHELPERSTATEDIR/$2"
1013 ## Usage: vshelper.initSync <vserver> <pipe-varname> [<method>]
1014 function vshelper.initSync
1017 _vis_tmpdir=$($_MKTEMPDIR vserver-stop.XXXXXX) || {
1018 warning $"Failed to generate temporary directory for vshelper sync"
1022 local _vis_fifo="$_vis_tmpdir"/pipe
1023 $_MKFIFO -m700 "$_vis_fifo"
1024 vshelper.doInit "$1" "${3:-sync}" "$_vis_fifo"
1028 ## Usage: vshelper.getSyncTimeout <vserver> <varname>
1029 function vshelper.getSyncTimeout
1031 local _vgst_appdir _vgst_file _vgst_tmp
1032 _vgst_appdir=$($_VSERVER_INFO "$1" APPDIR vshelper) || _vgst_appdir=
1034 findFile _vgst_file ${_vgst_appdir:+"$_vgst_appdir"/sync-timeout} "$__CONFDIR"/.defaults/apps/vshelper/sync-timeout ''
1035 test -n "$_vgst_file" || return 1
1036 read _vgst_tmp <"$_vgst_file"
1040 function vshelper.initStopSync
1042 local _iss_sync_dir=$($_MKTEMPDIR vshelper-stop-sync.XXXXXX) || {
1043 warning $"Failed to generate directory for vshelper sync"
1046 $_MKFIFO -m700 "$_iss_sync_dir/pipe"
1048 eval "$1"=\$_iss_sync_dir
1049 VSHELPER_STOP_SYNC="$_iss_sync_dir/pipe"
1050 export VSHELPER_STOP_SYNC
1053 function vshelper.waitForStopSync
1056 cat "$sync_dir/pipe" &> /dev/null
1060 function vshelper.doStopSync
1062 test ! -p "$VSHELPER_STOP_SYNC" || echo stopped > "$VSHELPER_STOP_SYNC"
1065 function _rpmFake.getCapFlags
1069 if test -n "$ctx" && ! $_VSERVER_INFO - FEATURE migrate; then
1070 set -- $($_CHCONTEXT_COMPAT --xid 1 \
1071 $_SH -c "$_CAT /proc/[0-9]*/status | $_EGREP '^(CapBset|s_context|ctxflags)'" | \
1072 $_GREP -B 1 -A 1 "^s_context: $ctx " | \
1073 $_SED -e '1,3p;d' | $_AWK '{ print $2 }')
1078 if test -n "$3"; then
1079 RPM_FAKE_CAP=$[ ~0x$1 ]
1082 RPM_FAKE_CAP=$[ ~0xd40c04ff ]
1087 function rpmFake.init
1091 vdir=$($_VSERVER_INFO "$1" VDIR) || vdir="$1"
1092 ctx=$($_VSERVER_INFO "$1" CONTEXT) || ctx=
1095 panic $"Can not find chroot environment at '$vdir' for '$1'"
1097 _rpmFake.getCapFlags "$ctx"
1099 RPM_FAKE_CHROOT=$vdir
1103 function rpmFake.exec
1105 export RPM_FAKE_CHROOT RPM_FAKE_CTX RPM_FAKE_CAP RPM_FAKE_FLAGS
1107 LD_PRELOAD=$_RPM_FAKE_SO${LD_PRELOAD:+:$LD_PRELOAD} \