#!/bin/sh
# addjaileduser -- by atje 2001
# This scripts adds a jailed user to the system.
# You need to have a properly setup /etc/jailedskel which can be created automatically by create_jailedskel.sh
# You also need Aaron Gifford's chrsh, which can be downloaded at http://www.aarongifford.com/computers/chrsh.html

if [ "$2" = "" ] ; then printf "Usage: $0 <username> <uid>\n\n" && exit; fi
useradd -u $2 -d /home/$1/./home -g jailed -s /bin/chrsh $1
cp -R /etc/jailedskel /home/$1
chmod 0555 /home/$1/bin/sh
ln /dev/tty /home/$1/dev/tty
chown $1:jailed /home/$1/home 
printf "$1:*:$2:3000::0:0::/home:/bin/sh\n" >> /home/$1/etc/master.passwd
pwd_mkdb -d /home/$1/etc /home/$1/etc/master.passwd
passwd $1
