Skip to content

Commit

Permalink
Add sanity checks for user supplied commands, like no spaces, no rela…
Browse files Browse the repository at this point in the history
…tive paths etc

Signed-off-by: Jari Aalto <jari.aalto@cante.net>
  • Loading branch information
jaalto committed Jun 1, 2013
1 parent 2c18b17 commit f56d21e
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 5 deletions.
4 changes: 3 additions & 1 deletion ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,10 @@
of user supplied $RSHELL. Correct error "--chown is not in
format user:group". Add new option --attribute.
(CreateUser): Option --force now allows changing user's shell.
Add many more RSHELL cases to check.
Add many more RSHELL cases to check. Add sanity checks for
user supplied commands, like no spaces, no relative paths etc.
(Chattr): Activate only on $OPT_CHATTR.
(TMPBASE): master

2013-05-31 Fri Jari Aalto <jari.aalto@cante.net>

Expand Down
40 changes: 36 additions & 4 deletions makefile.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@

AUTHOR="Jari Aalto <jari.aalto@cante.net>"

VERSION="2013.0601.0958"
VERSION="2013.0601.1911"

LICENSE="GPL-2+"
HOMEPAGE=http://freecode.com/projects/restricted-shell-rbash
Expand Down Expand Up @@ -545,8 +545,39 @@ Main ()
fi

if [ "$1" ]; then
COMMANDS="$*"
else
list=""

# Do some sanity checks

for elt in "$@"
do
MatchGrep "^[ ]+$" "$elt" && continue

case "$elt" in
*\ *)
Warn "WARN: Ignoring command with space: '$elt'"
;;
cd)
Warn "WARN: Ignoring command 'cd'. See rbash(1)"
;;
*/) Warn "WARN: Ignoring command: '$elt'"
;;
*/*)Warn "WARN: Ignoring command with relative path: '$elt'"
;;
*) list="$list $elt"
;;
esac
done

Echo "NOTE: Using command set: $list"

COMMANDS="$list"

unset elt
unset list
fi

if [ "$COMMANDS" ]; then
Warn "WARN: list of commands not given for '$LOGIN' to run"
fi

Expand Down Expand Up @@ -578,7 +609,8 @@ Main ()
chown=$(GetUserGroup "$LOGIN")

if [ ! "$chown" ]; then
Die "INTERNAL ERROR: Can't read user:group. Run program option --debug"
Die "INTERNAL ERROR: Can't read user:group." \
"Run program option --debug"
fi

MakeRestrictedBin "$chown"
Expand Down

0 comments on commit f56d21e

Please sign in to comment.