From owner-freebsd-stable@FreeBSD.ORG Thu Dec 20 17:41:22 2007 Return-Path: Delivered-To: freebsd-stable@FreeBSD.ORG Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id AD96016A46B for ; Thu, 20 Dec 2007 17:41:22 +0000 (UTC) (envelope-from olli@lurza.secnetix.de) Received: from lurza.secnetix.de (lurza.secnetix.de [IPv6:2001:1b20:1:3::1]) by mx1.freebsd.org (Postfix) with ESMTP id 12F8013C474 for ; Thu, 20 Dec 2007 17:41:21 +0000 (UTC) (envelope-from olli@lurza.secnetix.de) Received: from lurza.secnetix.de (localhost [127.0.0.1]) by lurza.secnetix.de (8.14.1/8.14.1) with ESMTP id lBKHfFLD069153; Thu, 20 Dec 2007 18:41:20 +0100 (CET) (envelope-from oliver.fromme@secnetix.de) Received: (from olli@localhost) by lurza.secnetix.de (8.14.1/8.14.1/Submit) id lBKHfDRb069152; Thu, 20 Dec 2007 18:41:13 +0100 (CET) (envelope-from olli) Date: Thu, 20 Dec 2007 18:41:13 +0100 (CET) Message-Id: <200712201741.lBKHfDRb069152@lurza.secnetix.de> From: Oliver Fromme To: freebsd-stable@FreeBSD.ORG, 000.fbsd@quip.cz, lists@lozenetz.org In-Reply-To: <47682873.8050601@quip.cz> X-Newsgroups: list.freebsd-stable User-Agent: tin/1.8.3-20070201 ("Scotasay") (UNIX) (FreeBSD/6.2-STABLE-20070808 (i386)) MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-2.1.2 (lurza.secnetix.de [127.0.0.1]); Thu, 20 Dec 2007 18:41:21 +0100 (CET) Cc: Subject: Re: jlogin.sh - a small nice jails helper! X-BeenThere: freebsd-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: freebsd-stable@FreeBSD.ORG, 000.fbsd@quip.cz, lists@lozenetz.org List-Id: Production branch of FreeBSD source code List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 20 Dec 2007 17:41:22 -0000 Miroslav Lachman wrote: > It is nice idea, but I think you should have a better scripting style ;) Yes, it almost looked like perl. :-) May I suggest a few further improvements? > login_shell="/bin/tcsh" I certainly wouldn't want tcsh. How about looking at $SHELL, and if it doesn't exist, then fall back to the standard shell (which is /bin/sh). Also, the last command (jexec) should be preceded by "exec" so the shell doesn't hang around. So the last part of the script would look like this: jail_path=$(jls | awk '$1=='$jail_id' {print $4}') if [ -z "$SHELL" -o ! -x "$jail_path/$SHELL" ]; then login_shell="$SHELL" else login_shell="/bin/sh" fi echo "Logging in to $jail_hostname" exec jexec $jail_id $login_shell Best regards Oliver PS: By the way, here's another useful script that displays processes running in jails, ordered by jail IDs: http://www.secnetix.de/~olli/scripts/jps -- Oliver Fromme, secnetix GmbH & Co. KG, Marktplatz 29, 85567 Grafing b. M. Handelsregister: Registergericht Muenchen, HRA 74606, Geschäftsfuehrung: secnetix Verwaltungsgesellsch. mbH, Handelsregister: Registergericht Mün- chen, HRB 125758, Geschäftsführer: Maik Bachmann, Olaf Erb, Ralf Gebhart FreeBSD-Dienstleistungen, -Produkte und mehr: http://www.secnetix.de/bsd One Unix to rule them all, One Resolver to find them, One IP to bring them all and in the zone to bind them.