From owner-freebsd-questions@FreeBSD.ORG Wed Feb 6 16:49:03 2008 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 57BDF16A418 for ; Wed, 6 Feb 2008 16:49:03 +0000 (UTC) (envelope-from zszalbot@gmail.com) Received: from ug-out-1314.google.com (ug-out-1314.google.com [66.249.92.172]) by mx1.freebsd.org (Postfix) with ESMTP id C334F13C478 for ; Wed, 6 Feb 2008 16:49:02 +0000 (UTC) (envelope-from zszalbot@gmail.com) Received: by ug-out-1314.google.com with SMTP id y2so629600uge.37 for ; Wed, 06 Feb 2008 08:49:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; bh=MXjkyMlCMopilnLNZ4CGIgTrT5n4Jrd5TIXybsUb1D4=; b=GEfvPHUuqa7ZPoXeiNkuAptkh0Au4mwfq9MXn5ID2AnBmZ/4Ip1D85AGPjD3mbKbr2nxYOm+nLGPtfwOShyQXnvv8vCB9H3ur4mSN75VoBl+CY+iG52dT7PBlq4EsPvUH3WCnVDdYlk2thktxpeKW1GhIWLlV+y/d87nCrq9qDU= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=h2bfmR4vIhatTTmDVkQuh+rfxg4FVaAf7DrfVRjifC8uM7Mq30FJ7Pm2S6UYZ63+qENnmub3vthXRbMalPAy55b7fRdtCru24rr5wHIm0y7EU4jIxAzmRPM0qhA2eIWzFgNGjNATAK5yL3GYzM8V/qlWcH6SviqWuPbz4bFKCpY= Received: by 10.78.122.16 with SMTP id u16mr18103646huc.21.1202316540906; Wed, 06 Feb 2008 08:49:00 -0800 (PST) Received: by 10.78.130.5 with HTTP; Wed, 6 Feb 2008 08:49:00 -0800 (PST) Message-ID: <94136a2c0802060849o1dfb3f6ek67d7d41db5d99102@mail.gmail.com> Date: Wed, 6 Feb 2008 17:49:00 +0100 From: "Zbigniew Szalbot" To: "Alex Zbyslaw" In-Reply-To: <47A9E373.80300@dial.pipex.com> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <94136a2c0802060751o7952c2f8w639139271c946e98@mail.gmail.com> <47A9E373.80300@dial.pipex.com> Cc: freebsd-questions Subject: Re: /usr/local/etc/rc.d/ scripts and non-root user 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: Wed, 06 Feb 2008 16:49:03 -0000 Hello Alex, 2008/2/6, Alex Zbyslaw : > Zbigniew Szalbot wrote: > > >Hello, > > > >I have looked at my /usr/local/etc/rc.d/ and realized that the symlink > >I put there has the root as owner. It all works but I would rather use > >a non-root user for to run that script. > > > >$ ls -l /usr/local/etc/rc.d/ > >lrwxr-xr-x 1 root wheel 40 May 9 2007 sender.sh -> > >/usr/home/api/sender/start.sh > > > >So I tried: > >$ sudo chown api /usr/local/etc/rc.d/sender.sh > > > >No error but no change either. The original start.sh file has user api > >but the symlink is owned by root. > > > >How can I make sure that the file is indeed run as user api? > > > > > AFAIK, the owner of a symlink is completely irrelevant. All accesses to > the file are checked against the permissions of the file pointed to, not > the symlink. (Same if the target of a symlink is a directory). Once > upon a time I'm sure all symlinks were owned by root, but could be > misremembering. > > When you ran your chown, it did nothing at all > > From man chown > > Symbolic links named by arguments are silently left > unchanged unless -h is used. > > If you really care; say you want a find -user api to find that symlink then > > chown -h api /usr/local/etc/rc.d/sender.sh > > should do what you want. Thank you. I realized this was the case before I wrote previous message. The thing is the real file is owned by user api. However, when the application is started following a reboot, its logs are created by user root, whereas when I start it by hand as user api, its logs are owned by user api. So it once caused me a problem because the existing log file was owned by root and I stopped then started this particular software by hand as user api. Needless to say, it panicked about not being able to log what it was doing. I wonder that indeed a better solution may be to use cron for automatic startups, which Lowell rightly pointed out to me. I just loved the simplicity of symlinking sh scripts against /usr/local/etc/rc.d/ :) Thank you! Zbigniew Szalbot