chown bug

chown bug

Post by Felix von Leitne » Wed, 07 Mar 2001 04:10:04



The man page says:

       If the owner or group is specified as -1, then that ID is not
       changed.

If user !root says chown("/usr",-1,-1), he gets EPERM.  Why?
He explicitly told the kernel that he does not actually want to change
anything.  Why would the kernel say EPERM?

Felix
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in

More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

 
 
 

chown bug

Post by Andries.Brou.. » Wed, 07 Mar 2001 05:10:04



    If user !root says chown("/usr",-1,-1), he gets EPERM.  Why?

Because the standard says:

  The chown( ) function shall fail if:

  [EPERM]  The effective user ID does not match the owner of the file, or ..

Andries
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in

More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

 
 
 

1. chown: bug or feature

I've just noticed that I can't cown my own files to other users under
Linux. Tried it under RedHat 5.2 and Slackware 3.5
Examining kernel sources I found in fs/inode.c, line 307 (function
inode_change_ok):
/*make sure a caller can chown*/
if ((attr->ia_valid & ATTR_UID) &&
    (current->fsusid != inode->i_uid ||
    attr->ia_uid != inode->i_uid) && !fsuser())
        return -EPERM;

If my brain is still worth any thing, this means
    "if you are trying to change UID and you are not currently owner of
inode ?OR? you are trying to change UID to something other then it
currently is, and you are not SU, then .....",
that is if you are trying to change owner user and you are not SU, you
are automatically denied access.

I thought it had to be

/*make sure a caller can chown*/
if ((attr->ia_valid & ATTR_UID) && attr->ia_uid != inode->i_uid &&
    (current->fsusid != inode->i_uid || !fsuser())
        return -EPERM;
"if you are trying to change UID to something other then it is now and
you are not owner of inode or SU, then deny access"

Is it a feature of linux,
or perhaps my understanding of meaning of structures is wrong?
inode -- inode we want to change
attr -- new attributes
current->fsuser -- UID of caller

if I am wrong about that, please correct me.
    Thanks.
            Ilya.

2. CHAT scripts

3. Chown: Can non-root user chown?

4. Bootable floppy. PLEASE HELP!

5. chown on AIX != chown on Linux!!!!!!

6. Is 3c509 driver there yet?

7. bug in chown(2) system call

8. : Bootable hot spare and partitioning

9. Bug in chown?

10. chown limit

11. suid root "secure" chown, anyone?

12. chown command

13. chown for normal users?