Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 06 Feb 2008 17:19:09 +0000
From:      Alex Zbyslaw <xfb52@dial.pipex.com>
To:        Zbigniew Szalbot <zszalbot@gmail.com>
Cc:        freebsd-questions <freebsd-questions@freebsd.org>
Subject:   Re: /usr/local/etc/rc.d/ scripts and non-root user
Message-ID:  <47A9EC0D.7030109@dial.pipex.com>
In-Reply-To: <94136a2c0802060857k25e55a5bw4c7743cc05dae6bd@mail.gmail.com>
References:  <94136a2c0802060751o7952c2f8w639139271c946e98@mail.gmail.com>	<47A9E568.9040406@dial.pipex.com> <94136a2c0802060857k25e55a5bw4c7743cc05dae6bd@mail.gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help
Zbigniew Szalbot wrote:

>I have never really understood the thing about setuids, gid and etc. :)
>I am not planning a restart so won't try it but I am pretty sure that
>logs are created by root unless the api is started manually. No big
>deal really but thanks for all the suggestions!
>  
>
It's very simple really.  When you run a program it always runs as the 
user who you are right now.  So if you are zbigniew a program you 
execute runs as you.  If you have su'ed or logged in as root, it runs as 
root.

In order to run the program, the user who you are must have the right 
permissions - i.e. they must have an x bit set.  If the program file is 
owned by the same user as who you are, then you look at the first 3 
permissions bits; otherwise if you are in the same group as the program 
file you look at the next three bits; everyone else looks at the last 
three bits.  (Bits as in pieces, not as in 1/8th of a byte).

Some programs need to run as specific users or with a specific group.  
E.g. shutdown must run as root.  You make the file owned by root and set 
the setuid bit.  The permissions might then look like:

    root wheel  r-s-r-x--- shutdown

The s replaces the x to show that the file is both executable by root 
and setuid.

Both root and anyone in group wheel can now run shutdown. and the setuid 
bit says that *whoever* runs the program will run it as if they were root.

It's very similar for groups.

hth,

--Alex




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?47A9EC0D.7030109>