ACCOUNT_NAME="${SAMBA_CPS_ACCOUNT_NAME}"
INVALIDPW="$1"
-NEWPW=`cat -`
+NEWPW=$(cat -)
echo -n "${NEWPW}" | grep -q "^${INVALIDPW}\$" && {
echo "Found invalid password" >&1
#!/bin/sh
-BASENAME=`basename $0`
+BASENAME=$(basename $0)
unset LD_PRELOAD
if [ "x$PLEASE_NO_GDB_BACKTRACE" != "x" ]; then
echo "${BASENAME}: Not running debugger because PLEASE_NO_GDB_BACKTRACE is set"
- exit 0
+ exit 0
fi
-
# we want everything on stderr, so the program is not disturbed
exec 1>&2
-UNAME=`uname`
+UNAME=$(uname)
PID=$1
BINARY=$2
DB_LIST="gdb"
case "${UNAME}" in
- #
- # on Tru64 we need to try ladebug first
- # because gdb crashes itself...
- #
- OSF1)
- DB_LIST="ladebug ${DB_LIST}"
+#
+# on Tru64 we need to try ladebug first
+# because gdb crashes itself...
+#
+OSF1)
+ DB_LIST="ladebug ${DB_LIST}"
;;
- #
- # On solaris dbx is working way more better than gdb
- # let's try it first
- #
- SunOS)
- DB_LIST="dbx ${DB_LIST}"
+#
+# On solaris dbx is working way more better than gdb
+# let's try it first
+#
+SunOS)
+ DB_LIST="dbx ${DB_LIST}"
;;
- #
- # FreeBSD comes with a flavor that works gdb66 and one that don't gdb
- # (gdb 6.1) let's try it first the one that works !
- #
- FreeBSD)
- DB_LIST="gdb66 ${DB_LIST}"
+#
+# FreeBSD comes with a flavor that works gdb66 and one that don't gdb
+# (gdb 6.1) let's try it first the one that works !
+#
+FreeBSD)
+ DB_LIST="gdb66 ${DB_LIST}"
;;
esac
for DB in ${DB_LIST}; do
- DB_BIN=`which ${DB} 2>/dev/null | grep '^/'`
+ DB_BIN=$(which ${DB} 2>/dev/null | grep '^/')
test x"${DB_BIN}" != x"" && {
break
}
need_binary="no"
case "${DB}" in
# These debuggers need the process binary specified:
- ladebug)
+ladebug)
need_binary="yes"
;;
- gdb66)
+gdb66)
need_binary="yes"
;;
- dbx)
+dbx)
need_binary="yes"
;;
esac
test x"${need_binary}" = x"yes" && {
-# we first try to use /proc/${PID}/exe or /proc/{$PID}/path for solaris
-# then fallback to the binary from the commandline
-# then we search for the commandline argument with
-# 'which'
-#
+ # we first try to use /proc/${PID}/exe or /proc/{$PID}/path for solaris
+ # then fallback to the binary from the commandline
+ # then we search for the commandline argument with
+ # 'which'
+ #
test -f "/proc/${PID}/exe" && BINARY="/proc/${PID}/exe"
- test -f "/proc/${PID}/path/a.out" && BINARY=`ls -l /proc/${PID}/path/a.out |sed 's/.*-> //'`
+ test -f "/proc/${PID}/path/a.out" && BINARY=$(ls -l /proc/${PID}/path/a.out | sed 's/.*-> //')
test x"${BINARY}" = x"" && BINARY="/proc/${PID}/exe"
- test -f "${BINARY}" || BINARY=`which ${BINARY}`
-
+ test -f "${BINARY}" || BINARY=$(which ${BINARY})
+
test -f "${BINARY}" || {
- echo "${BASENAME}: ERROR: Cannot find binary '${BINARY}'."
- exit 1
+ echo "${BASENAME}: ERROR: Cannot find binary '${BINARY}'."
+ exit 1
}
}
-BATCHFILE_PRE=`mktemp --tmpdir gdb_backtrace_pre.XXXXXXXXXX`
+BATCHFILE_PRE=$(mktemp --tmpdir gdb_backtrace_pre.XXXXXXXXXX)
test -n "${BATCHFILE_PRE}" || {
echo "mktemp doesn't work" 1>&2
exit 1
}
-BATCHFILE_MAIN=`mktemp --tmpdir gdb_backtrace_main.XXXXXXXXXX`
+BATCHFILE_MAIN=$(mktemp --tmpdir gdb_backtrace_main.XXXXXXXXXX)
test -n "${BATCHFILE_MAIN}" || {
echo "mktemp doesn't work" 1>&2
exit 1
}
case "${DB}" in
- ladebug)
-cat << EOF > ${BATCHFILE_PRE}
+ladebug)
+ cat <<EOF >${BATCHFILE_PRE}
set \$stoponattach
EOF
-cat << EOF > ${BATCHFILE_MAIN}
+ cat <<EOF >${BATCHFILE_MAIN}
where
quit
EOF
${DB_BIN} -c "${BATCHFILE_MAIN}" -i "${BATCHFILE_PRE}" -pid "${PID}" "${BINARY}"
;;
- gdb66)
-cat << EOF > ${BATCHFILE_MAIN}
+gdb66)
+ cat <<EOF >${BATCHFILE_MAIN}
set height 1000
bt full
info locals
EOF
${DB_BIN} -x "${BATCHFILE_MAIN}" "${BINARY}" "${PID}"
;;
- gdb)
-cat << EOF > ${BATCHFILE_MAIN}
+gdb)
+ cat <<EOF >${BATCHFILE_MAIN}
set height 0
bt full
thread apply all bt full
info locals
quit
EOF
- ${DB_BIN} -batch -x "${BATCHFILE_MAIN}" --pid "${PID}" < /dev/null
+ ${DB_BIN} -batch -x "${BATCHFILE_MAIN}" --pid "${PID}" </dev/null
;;
dbx)
${DB_BIN} "where;dump;kill;quit" "${BINARY}" "${PID}"
shift 1
-TMPFILE=`mktemp --tmpdir gdb_run.XXXXXXXXXX`
+TMPFILE=$(mktemp --tmpdir gdb_run.XXXXXXXXXX)
test -n "${TMPFILE}" || {
echo "mktemp doesn't work" 1>&2
exit 1
}
-cat << EOF > $TMPFILE
+cat <<EOF >$TMPFILE
run
bt
EOF
basedir=$TMPDIR
[ -r $basedir/$SERVERNAME.pid ] && {
- for i in {2..100}; do
- if [ ! -r "$basedir/${SERVERNAME}-$i.pid" ]; then
- SERVERNAME="${SERVERNAME}-$i"
- break
- fi
- done
+ for i in {2..100}; do
+ if [ ! -r "$basedir/${SERVERNAME}-$i.pid" ]; then
+ SERVERNAME="${SERVERNAME}-$i"
+ break
+ fi
+ done
}
rm -f $basedir/$SERVERNAME.{launch,log,parent.pid,pid,status}
# set most of the environment vars we have in the screen session too
_ENV=""
printenv |
- egrep -v '^TERMCAP|^WINDOW|^SHELL|^STY|^SHLVL|^SAMBA_VALGRIND|\$' |
- egrep '^[A-Z]' |
- sed "s/\(^[^=]*=\)\(.*\)/export \1'\2'/g" > $basedir/$SERVERNAME.vars
+ egrep -v '^TERMCAP|^WINDOW|^SHELL|^STY|^SHLVL|^SAMBA_VALGRIND|\$' |
+ egrep '^[A-Z]' |
+ sed "s/\(^[^=]*=\)\(.*\)/export \1'\2'/g" >$basedir/$SERVERNAME.vars
-cat <<EOF > $basedir/$SERVERNAME.launch
+cat <<EOF >$basedir/$SERVERNAME.launch
cd $PWD
echo \$\$ > $basedir/$SERVERNAME.pid
. $basedir/$SERVERNAME.vars
EOF
pid=$$
-cleanup() {
- trap "exit 1" SIGINT SIGTERM SIGPIPE
- [ -r $basedir/$SERVERNAME.status ] && {
- read status < $basedir/$SERVERNAME.status
- echo "$(date) samba exited with status $status" >> $basedir/$SERVERNAME.log
- exit $status
- }
+cleanup()
+{
+ trap "exit 1" SIGINT SIGTERM SIGPIPE
+ [ -r $basedir/$SERVERNAME.status ] && {
+ read status <$basedir/$SERVERNAME.status
+ echo "$(date) samba exited with status $status" >>$basedir/$SERVERNAME.log
+ exit $status
+ }
- case $ENVNAME in
- *.nmbd|*.smbd|*.winbindd|*.samba|*.samba_dcerpcd)
- kill $(cat $basedir/../"${ENVNAME%\.*}"/pid/"${ENVNAME##*\.}".pid)
- ;;
- esac
+ case $ENVNAME in
+ *.nmbd | *.smbd | *.winbindd | *.samba | *.samba_dcerpcd)
+ kill $(cat $basedir/../"${ENVNAME%\.*}"/pid/"${ENVNAME##*\.}".pid)
+ ;;
+ esac
- read pid < $basedir/$SERVERNAME.pid
- echo "$(date) Killing samba pid $pid from $$" >> $basedir/$SERVERNAME.log
- if [ "$pid" = "$$" ]; then
+ read pid <$basedir/$SERVERNAME.pid
+ echo "$(date) Killing samba pid $pid from $$" >>$basedir/$SERVERNAME.log
+ if [ "$pid" = "$$" ]; then
+ exit 1
+ fi
+ kill -9 $pid 2>&1
exit 1
- fi
- kill -9 $pid 2>&1
- exit 1
}
-echo $$ > $basedir/$SERVERNAME.parent.pid
+echo $$ >$basedir/$SERVERNAME.parent.pid
trap cleanup SIGINT SIGTERM SIGPIPE
if [[ "$TMUX" ]]; then
- TMUX_CMD=tmux
- if [[ $TMUX = *tmate* ]]; then
- TMUX_CMD=tmate
- fi
+ TMUX_CMD=tmux
+ if [[ $TMUX = *tmate* ]]; then
+ TMUX_CMD=tmate
+ fi
- $TMUX_CMD new-window -n test:$SERVERNAME "bash $basedir/$SERVERNAME.launch"
+ $TMUX_CMD new-window -n test:$SERVERNAME "bash $basedir/$SERVERNAME.launch"
- # tmux seems to lag a bit for new sessions. Don't create them too
- # quickly one after another
- sleep .1
+ # tmux seems to lag a bit for new sessions. Don't create them too
+ # quickly one after another
+ sleep .1
else
- screen -r -X screen -t test:$SERVERNAME bash $basedir/$SERVERNAME.launch
+ screen -r -X screen -t test:$SERVERNAME bash $basedir/$SERVERNAME.launch
fi
-echo "$(date) waiting in $$" >> $basedir/$SERVERNAME.log
+echo "$(date) waiting in $$" >>$basedir/$SERVERNAME.log
read stdin_var
-echo "$(date) EOF on stdin" >> $basedir/$SERVERNAME.log
+echo "$(date) EOF on stdin" >>$basedir/$SERVERNAME.log
case $ENVNAME in
- *.nmbd|*.smbd|*.winbindd|*.samba|*.samba_dcerpcd)
+*.nmbd | *.smbd | *.winbindd | *.samba | *.samba_dcerpcd)
kill $(cat $basedir/../"${ENVNAME%\.*}"/pid/"${ENVNAME##*\.}".pid)
;;
esac
-read pid < $basedir/$SERVERNAME.pid
-echo "$(date) killing $pid" >> $basedir/$SERVERNAME.log
-kill $pid 2> /dev/null
-echo "$(date) exiting" >> $basedir/$SERVERNAME.log
+read pid <$basedir/$SERVERNAME.pid
+echo "$(date) killing $pid" >>$basedir/$SERVERNAME.log
+kill $pid 2>/dev/null
+echo "$(date) exiting" >>$basedir/$SERVERNAME.log
exit 0
# we need to wait for the child namespace to start up and add the new
# interface back to our new namespace
-while ! ip link show $interface > /dev/null 2>&1
-do
- sleep 0.1
- echo "Waiting for $interface to be created..."
+while ! ip link show $interface >/dev/null 2>&1; do
+ sleep 0.1
+ echo "Waiting for $interface to be created..."
done
# bring the bridge-end of the link up and add it to the bridge
ip link set dev $interface up
ip link set $interface master $bridge
-
ip addr add $ip_addr/24 dev $br_name
ip addr add $ipv6_addr/112 dev $br_name
ip link set $br_name up
-
-
# generate the dynamic script
dyn_script="$(dirname $2)/nsenter.sh"
-echo "#!/bin/sh" > $dyn_script
-echo "$nsenter_cmd $helper_script" >> $dyn_script
+echo "#!/bin/sh" >$dyn_script
+echo "$nsenter_cmd $helper_script" >>$dyn_script
chmod 755 $dyn_script
# return the script we created
echo "$dyn_script"
-
# session to a given namespace testenv. This basically just sets up the same
# environment variables as you normally get with selftest, for convenience.
-if [ $# -lt 1 ] ; then
- echo "Usage: $0 <exports-file>"
- exit 1
+if [ $# -lt 1 ]; then
+ echo "Usage: $0 <exports-file>"
+ exit 1
fi
# we get passed a exports file with all the environment variables defined
# read the exports file so the new shell has appropriate variables setup
# (we export rather than sourcing here so they get inherited by the subshell)
-while read -r line ; do
- export $line
- # dump them for the user too
- echo $line
-done < $exports_file
+while read -r line; do
+ export $line
+ # dump them for the user too
+ echo $line
+done <$exports_file
echo ""
echo "Entered $NETBIOSNAME namespace, with above variables defined."
# start a shell session in the new namespace
$SHELL
-
-
#!/bin/sh
{
- vars=`set | \
- grep "^[a-zA-Z][^=]*='[^']*'$" | \
- grep -v '^IFS=' | \
- grep -v '^TERM' | \
- grep -v '^PPID' | \
- grep -v '^PS[1-9]=' | \
- cat `
+ vars=$(set |
+ grep "^[a-zA-Z][^=]*='[^']*'$" |
+ grep -v '^IFS=' |
+ grep -v '^TERM' |
+ grep -v '^PPID' |
+ grep -v '^PS[1-9]=' |
+ cat)
echo "${vars}"
echo "${vars}" | sed -e 's!^\([a-zA-Z][^=]*\)=.*$!export \1!'
-} > bin/restore.env.source
+} >bin/restore.env.source
echo "RUN: '. bin/restore.env.source'"