ac56ea0b10e129faef6005cf4da01be35f179a9d
4 jail_dir
="/var/chroot-jails"
5 jail_system
="/var/chroot-sys"
8 home
="$(getent passwd "$user" | cut -f6 -d:)"
9 home_system
="$jail_system/$home"
10 home_chroot
="$jail_dir/$user/$home";
12 echo "$PAM_USER, $PAM_SERVICE, $PAM_TTY, $PAM_RHOST, $PAM_TYPE"
14 [ "$user" = "root" ] && {
15 echo "no chroots for roots"
19 #TODO: test if $home is in /home/
21 mkdir
-p "$home_system"
22 mkdir
-p "$jail_dir/$user"
23 chown
"$user:$user" "$home_system"
24 chown
-R root
:root
"$jail_system"
26 function is_mounted
() {
27 dir
=$
(echo "$1" |
sed -e 's/\/\/*/\//g; s/\/$//g;')
28 cut
-d ' ' -f 2 /proc
/mounts |
grep "^$dir$" >/dev
/null
37 echo "Mounting: $from to $to";
38 mount
-o bind "$from" "$to"
40 [ -n "$opt" ] && mount
-o remount
,bind,"$opt" "$to"
42 echo "Not mounted: $to"
50 #TODO: unmount if not busy
51 #umount "$jail_dir/$user" && umount "$home_chroot"
55 bind "$jail_system" "$jail_dir/$user" ',ro' ||
exit 1
56 bind "$home" "$home_chroot" ||
exit 2
This page took 0.384266 seconds and 5 git commands to generate.