#!/bin/sh jail=$1 user=$2 me=$(id -u) jid="" if test "$jail" = "-h"; then echo "jlogin [jail] [user]" exit fi if test -z "$jail"; then jid=$(jls | head -2 | tail -1 | awk '{print $1}') jail=$(jls | head -2 | tail -1 | awk '{print $2}') else jid=$(jls | grep "$jail" | awk '{print $1}') fi if test -z "$jid"; then echo "jail $jail doesn't run!" exit 1 fi shell=/bin/csh home=/home/$user term=vt100 path=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin jexec=jexec if test -z "$user"; then user=root home=/root fi if test "$me" != "0"; then jexec="sudo jexec" fi echo "# Logging into jail $jail with jid $jid #" env - JAIL="$jail" TERM=$term HOME="$home" SHELL=$shell PATH=$path "$jexec" -U "$user" "$jid" sh