Re: idiot question about chown

From: James Keasley (me_at_privacy.net)
Date: 08/05/04


Date: 5 Aug 2004 18:34:29 GMT


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 2004-08-05, lawrence <lkrubner@geocities.com> wrote:
> I want to chown htdocs. I want htdocs to belong to the same user as
> PHP. Apparently (to my horror) PHP is running as root.

That might be the expected behaviour, I don't know, but it sounds fairly
dumb to me

> So I want to chown to root.

Why do the file in htdocs need to be owned by the user that PHP
is running as? All it means is that you'll have to su to root to
edit the files, don't do it.

If anything, set up PHP to run as the user that owns htdocs, rather
than the other way around, it is somewhat safer that way, unless PHP
requires root permissions

> My username is lkrubner and my co-worker is pagelast. I
> telnet to our webserver and go to the directory I want and get the
> directory info:

And, on a completely irrelevant note, why the hell are you using
telnet, thats just dumb, even on a "private" intranet. Use SSH
instead, it is also more convenient if you put your key on the
boxes you need to get into and use ssh-agent. Then you only
have to type in your key passphrase the once, and not bother
with the individual login passwords.

> chown -v root htdocs
>
> I get "Error: operation not permited."
>
> Okay, that makes sense, I figure, because lkrubner and pagelast have
> the same rank, we're both root, so why should I be able to take his
> ownership away from him.
>
> But then, as an experiment, I try to chown a file I do own:
>
> bash-2.05a$ chown pagelast ppKernel
> chown: ppKernel: Operation not permitted
>
> Why is the operation not permitted in this case?

Because, unless someone has been spectaculary fuckwitted, you aren't
running with root permissions, you can check by doing:

$ less /etc/passwd | grep lkrubner

you'll get a line something like back:

lkrubner:x:1000:1000:Lawrence Rubner,,,:/home/lkrubner:/bin/bash
           ^^^^

that is your UID, if that isn't 0 then you aren't root, so you need
to su to root or, preferably, use sudo.

Neither should your colleague be running as root either.

you need to be root to do anything useful with chown.

- --
James jamesk[at]homeric[dot]co[dot]uk

"God. And I thought +I+ was depressing!" (Cmdr. Ivanova, B5 "The Summoning")
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.5 (GNU/Linux)

iD8DBQFBEn20qfSmHkD6LvoRAqUlAJ9gizuMCEKbqOPbDcduUEylI02JUACgg6FN
GdU2gJqlpPBjQzd4dEw7oI8=
=giFI
-----END PGP SIGNATURE-----