From owner-freebsd-questions@FreeBSD.ORG Fri Dec 1 16:41:12 2006 Return-Path: X-Original-To: freebsd-questions@freebsd.org Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 660C916A403 for ; Fri, 1 Dec 2006 16:41:12 +0000 (UTC) (envelope-from xfb52@dial.pipex.com) Received: from smtp-out2.blueyonder.co.uk (smtp-out2.blueyonder.co.uk [195.188.213.5]) by mx1.FreeBSD.org (Postfix) with ESMTP id 8D87443CA6 for ; Fri, 1 Dec 2006 16:40:56 +0000 (GMT) (envelope-from xfb52@dial.pipex.com) Received: from [172.23.170.140] (helo=anti-virus02-07) by smtp-out2.blueyonder.co.uk with smtp (Exim 4.52) id 1GqBRm-00072K-0f; Fri, 01 Dec 2006 16:41:10 +0000 Received: from [82.46.239.57] (helo=[192.168.0.2]) by asmtp-out3.blueyonder.co.uk with esmtp (Exim 4.52) id 1GqBRk-0001Ak-Pu; Fri, 01 Dec 2006 16:41:08 +0000 Message-ID: <45705B24.8040509@dial.pipex.com> Date: Fri, 01 Dec 2006 16:41:08 +0000 From: Alex Zbyslaw User-Agent: Mozilla/5.0 (X11; U; FreeBSD i386; en-GB; rv:1.7.13) Gecko/20061106 X-Accept-Language: en MIME-Version: 1.0 To: Ray Still References: <004601c71559$f2d645f0$6700a8c0@New> <45704A22.9060100@dial.pipex.com> <007101c7155f$f1fb6790$6700a8c0@New> In-Reply-To: <007101c7155f$f1fb6790$6700a8c0@New> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: freebsd-questions@freebsd.org Subject: Re: Fw: Re: problem with script execution X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 01 Dec 2006 16:41:12 -0000 Ray Still wrote: > > Alex Zbyslaw wrote: > >> Ray Still wrote: >> >>>>> Just out of curiosity: What is the "echo * |" supposed to do? From my >>>>> point of view the shell will expand "*" to the list of files and >>>>> directories in PWD, so "echo *" acts like a simple ls in this >>>>> context. >>>>> This list is piped to sudo. But what does sudo do with these? >>>> >>>> >>>> >>>> sorry, I didn't want to show my passwords, so I replaced it with an >>>> astrix. the password of course is being read from the pipe by sudo >>>> because of the -S option. >>> >>> >> Probably nothing to do with your original problem, but you do know >> that you can allow sudo to execute certain commands without a >> password? Passwords in shell scripts isn't exactly ideal... > > > I am aware of the security issues, but in this case I think it's the > best option because: > > 1) any one who can login to the machine also knows root passwords. > 2) this script lives in a directory that is password protected by apache. > 3) I don't like the thought of turning off passwords. > so if you can see the script, you won't learn anything you don't > already know. > am I totally out to lunch? IMHO, putting passwords in a script is a bad idea and putting a root password in a script is just asking for trouble. Sure, when all is well, all your users know it anyway. Then one day you forget and add a user who doesn't know it, or you distribute the script somewhere external by accident, or someone hacks in to your machine and you have given them the password on a plate. From what I understand, this script is being run only from apache, and you have password protected it from the apache server. So the only user you need to allow to run the script without a password is "apache". As you have it, any user on the system who can read the file can already run it without a password unless you have directory/script permissions set up to lock them out - apache password protection only protects you when the script is accessed through apache. If you use sudo to allow apache to run the script passwordless, then to run the script as apache you either need to be the apache server or root, so random logged in users can't run it without knowing the root password unless you let them. What I think sudo (correctly set up to only allow apache to run the script) buys you is this: 1) Your password is not visible anywhere so can't be given away by accident. 2) The script is exactly as well protected for web use as when you just include the password in the script. Any web user who can click on the right link and supply the apache authentication can run the script. If you feel apache authentication is enough protection, then passwordless sudo changes nothing, as far as I can see. 3) Random users gaining access to your machine cannot run the script without knowing the root password. Right now any user on your system who has execute permission in the script can run it without knowing the root password. My tuppence, --Alex