Skip to content

Busybox lacks test command #6

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 15 commits into
base: anyuser-support
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion atom.mk
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,12 @@ include $(CLEAR_VARS)
LOCAL_MODULE := dropbear-pv
LOCAL_DESCRIPTION := dropbear-pv

LOCAL_AUTOTOOLS_CONFIGURE_ARGS := --enable-static
LOCAL_AUTOTOOLS_CONFIGURE_ARGS := \
--enable-static \
--disable-lastlog \
--disable-wtmp \
$(NULL)

LOCAL_LIBRARIES += zlib

LOCAL_CLEAN_DIRS := $(call local-get-build-dir)/usr/share/ $(call local-get-build-dir)/usr/include/
Expand Down
50 changes: 35 additions & 15 deletions fallbear-cmd
Original file line number Diff line number Diff line change
@@ -1,28 +1,48 @@
#!/bin/sh

echo_debug() {
if [ -n "$PVDEBUG" ]; then
echo $@
fi
}

lxc_pid() {
target=$1
nsenter -m/proc/1/ns/mnt \
lxc-info $target | grep PID: | sed -e 's/^[^0-9]*//'
target=$1
nsenter -m/proc/1/ns/mnt \
lxc-info $target | grep PID: | sed -e 's/^[^0-9]*//'
}

target=$USER
p=1

if ! [ "$target" = "/" ]; then
p=`lxc_pid $target`
p=`lxc_pid $target`

if [ -z "$p" ]; then
echo "no container found: $target"
exit 1
fi
if [ -z "$p" ]; then
echo "no container found: $target"
exit 1
fi
fi

args=${@:-/bin/sh -l}
nsenter -m/proc/$p/ns/mnt \
-n/proc/$p/ns/net \
-p/proc/$p/ns/pid \
-u/proc/$p/ns/uts \
-i/proc/$p/ns/ipc \
$args
PVUSER=${PVUSER:-root}
echo_debug PVUSER: $PVUSER
pwdline=`nsenter -m/proc/$p/ns/mnt -- [ -f /etc/passwd ] \
&& (nsenter -m/proc/$p/ns/mnt cat /etc/passwd | grep ^$PVUSER:) \
|| true`

shell=`echo $pwdline | sed -e 's/^.*:\([^:]*\)$/\1/'`
home=`echo $pwdline | sed -e 's/^.*:\([^:]*\):[^:]*$/\1/'`
echo_debug shell: $shell
echo_debug home: $home

args=${SSH_ORIGINAL_COMMAND:-${shell:-/bin/sh} -l}
echo_debug running shell: $args

USER=root LOGNAME=root HOME=${home:-/tmp1} \
nsenter -m/proc/$p/ns/mnt \
-n/proc/$p/ns/net \
-p/proc/$p/ns/pid \
-u/proc/$p/ns/uts \
-i/proc/$p/ns/ipc \
-- \
$args