From cb9940f7341d63e385d804464fb1939de9a4e6e1 Mon Sep 17 00:00:00 2001 From: erdgeist Date: Tue, 8 Nov 2005 15:11:51 +0000 Subject: Start of default config sub system --- ezjail-config.sh | 43 +++++++++++++++++++++++++++++++++++++++++++ ezjail.template | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 79 insertions(+) create mode 100644 ezjail-config.sh create mode 100644 ezjail.template diff --git a/ezjail-config.sh b/ezjail-config.sh new file mode 100644 index 0000000..0b9d083 --- /dev/null +++ b/ezjail-config.sh @@ -0,0 +1,43 @@ +#!/bin/sh + +if [ -f /etc/ezjail.template ]; then + . /etc/ezjail.template + + # we do need to install only once + # rm /etc/ezjail.template +fi + +# set defaults +ezjail_template_root=${ezjail_template_root:-"/basejail/config/_JAILNAME_"} +ezjail_template_files=${ezjail_template_files:-""} +ezjail_template_users=${ezjail_template_users:-""} +ezjail_template_packages=${ezjail_template_packages:-""} + +# try to create users +for user in $ezjail_template_users; do + TIFS=$IFS; IFS=:; set -- $user; IFS=$TIFS + if [ $# -eq 7 ]; then + name=$1; grouplist=$3; gidlist=$4 + + [ $2 ] && uid="-u $2" || uid="" + [ $5 ] && pass=$5 || pass="*" + [ $6 ] && home=$6 + [ $7 ] && shell="-s $7" + + [ x$6 = x${6#-} ] && mkhome="-r" || mkhome=""; home=${6#-} + [ $home ] && home="-h $home"; + + if [ $grouplist ]; then + gc=1 + for $group in `echo $grouplist | tr "," " "`; do + gid=`echo $gidlist | cut -d , -f $gc`; [ $gid ] && gid="-n $gid" + echo pw groupadd -n $group $gid + gc=(($gc + 1)) + done + endif + if [ $name ]; then + echo pw useradd $name $uid $shell $home $grouplist + fi + fi + +done diff --git a/ezjail.template b/ezjail.template new file mode 100644 index 0000000..3f7ebb1 --- /dev/null +++ b/ezjail.template @@ -0,0 +1,36 @@ +# ezjail template example +# refer to ezjail(5) for more information +# +# ezjails jail init script tries to create the following users. Format is +# as follows: +# +# username::group[,group,...]::cryptpw:[-]homedir:shell +# +# Example: +# +# ezjail_template_users=\ +# "admin::wheel::$1$p75bbfK.$Kz3dwkoVlgZrfLZdAXQt91:/home/admin:/bin/sh \ +# pgsql:1002:pgsql:1002:*:-/usr/local/psql:/bin/nologin \ +# ::heroes:1003::::" + +# ezjails init script tries to install all files listed here from the path +# specified in the ezjail_template_root variable root to the corresponding +# location inside the jail. Directories are being copied recursive. Format +# is as follows: +# +# user:group:file(s) +# +# Example: +# +# ezjail_template_root=/basejail/config/_JAILNAME_ +# ezjail_template_files=\ +# "root:wheel:/etc/{resolv,rc,make}.conf \ +# admin:wheel:/home/admin/" + +# ezjails jail init script tries to install packages specified in the +# ezjail_template_packages variable. All packages without an absolute +# path are assumed to be located in /basejail/config/pkg +# +# Example: +# +# ezjail_template_packages="sudo-1.6.8.9.tbz pico-4.64.tbz" -- cgit v1.2.3