From owner-freebsd-questions@FreeBSD.ORG Mon Jul 29 13:54:08 2013 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id ACC55792 for ; Mon, 29 Jul 2013 13:54:08 +0000 (UTC) (envelope-from freebsd@edvax.de) Received: from mx02.qsc.de (mx02.qsc.de [213.148.130.14]) by mx1.freebsd.org (Postfix) with ESMTP id 7288F2797 for ; Mon, 29 Jul 2013 13:54:08 +0000 (UTC) Received: from r56.edvax.de (port-92-195-48-81.dynamic.qsc.de [92.195.48.81]) by mx02.qsc.de (Postfix) with ESMTP id 4C12D249E8; Mon, 29 Jul 2013 15:54:01 +0200 (CEST) Received: from r56.edvax.de (localhost [127.0.0.1]) by r56.edvax.de (8.14.5/8.14.5) with SMTP id r6TDs1fN002633; Mon, 29 Jul 2013 15:54:01 +0200 (CEST) (envelope-from freebsd@edvax.de) Date: Mon, 29 Jul 2013 15:54:01 +0200 From: Polytropon To: Paul Macdonald Subject: Re: Unusual file: /bin/[ Message-Id: <20130729155401.ec663cb5.freebsd@edvax.de> In-Reply-To: <51F66D34.8010803@ifdnrg.com> References: <51F66D34.8010803@ifdnrg.com> Organization: EDVAX X-Mailer: Sylpheed 3.1.1 (GTK+ 2.24.5; i386-portbld-freebsd8.2) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Cc: "freebsd-questions@freebsd.org" X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list Reply-To: Polytropon List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 29 Jul 2013 13:54:08 -0000 On Mon, 29 Jul 2013 14:25:08 +0100, Paul Macdonald wrote: > > Hi, I spotted what i'd call an unusual file in the basejail on a jail > install, and have since seen this on other non jailed boxes. > > -r-xr-xr-x 2 root wheel 11488 Jun 10 12:19 [ > > man [ reveals > > test, [ -- condition evaluation utility > > just checking thats all ok, and i've not been rooted! The "[" program is the same as the "test" program. It's a valid file name and it's often used in shell scripts instead of "test". % ll /bin/test /bin/\[ -r-xr-xr-x 2 root wheel 8336 2011-08-21 20:23:20 /bin/[* -r-xr-xr-x 2 root wheel 8336 2011-08-21 20:23:20 /bin/test* Consider shell scripts. When you have a script with something like if [ -f bla.txt ]; then ... some stuff ... fi it is the same as if test -f bla.txt; then ... some stuff ... fi It's also often being used like [ -x blah.sh ] && do_something which is identical to calling "test" and acting upon the value of the return code. Nothing to worry here. YOu can _always_ counter-check by building /usr/src/bin/test from source and compare the resulting binary. Both /bin/[ and /bin/test are usually installed as hardlinks (two file names for one / for _the same_ file), as seen in the corresponding Makefile: LINKS= ${BINDIR}/test ${BINDIR}/[ So it's not _that_ unusual. ;-) -- Polytropon Magdeburg, Germany Happy FreeBSD user since 4.0 Andra moi ennepe, Mousa, ...