Skip to content

Commit

Permalink
kiss-netns: fix getting pid fail when called by non-privileged user
Browse files Browse the repository at this point in the history
Signed-off-by: Jianhong Yin <[email protected]>
  • Loading branch information
tcler committed May 29, 2024
1 parent 662c395 commit fa4da96
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions kiss-netns
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ P=$0; [[ $0 = /* ]] && P=${0##*/}
switchroot() {
local P=$0 SH=; [[ $0 = /* ]] && P=${0##*/}; [[ -e $P && ! -x $P ]] && SH=$SHELL
[[ $(id -u) != 0 ]] && {
echo -e "\E[1;30m{WARN} $P need root permission, switch to:\n sudo $SH $P $@\E[0m"
echo -e "\E[1;30m{WARN} $P need root permission, switch to:\n sudo $SH $P $*\E[0m"
exec sudo $SH $P "$@"
}
}
Expand Down Expand Up @@ -467,6 +467,7 @@ delif() {
}

# command line parse
oat=("$@")
_at=`getopt -o hvdn:x::f \
--long help \
-a -n "$0" -- "$@"`
Expand All @@ -483,7 +484,7 @@ while true; do
esac
done

switchroot "$@"
switchroot "${oat[@]}"
# __prepare__
command -v tmux >/dev/null || dep+=\ tmux
command -v dhclient >/dev/null || dep+=\ dhclient
Expand Down

0 comments on commit fa4da96

Please sign in to comment.