Bug #80492 [Nab]: CHMOD does not work

From: Date: Mon, 07 Dec 2020 17:46:37 +0000
Subject: Bug #80492 [Nab]: CHMOD does not work
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-230919@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=80492&edit=1

 ID:                 80492
 User updated by:    gilperon at gmail dot com
 Reported by:        gilperon at gmail dot com
 Summary:            CHMOD does not work
 Status:             Not a bug
 Type:               Bug
 Package:            *General Issues
 Operating System:   CENTOS 7 and 8
 PHP Version:        8.0.0
 Block user comment: N
 Private report:     N

 New Comment:

peehaa@php.net what? Who says that's how it works? You? Check some example man page of chmod

https://linux.die.net/man/1/chmod

I checked others too, there is absolutetly nothing saying the permission should not be changed if
the owner is not who is requesting the permission change. I AM NOT CHANGING owner, I am chaning the
permission. There is no security implication since I can already delete and write to that file.

I cant see how you came to the conclusion on your own.


Previous Comments:
------------------------------------------------------------------------
[2020-12-07 17:33:49] peehaa@php.net

This is just how it works. To chmod a file you either need to be the owner or root

------------------------------------------------------------------------
[2020-12-07 17:30:43] gilperon at gmail dot com

Description:
------------
This bug happens also on PHP 7.X and 8.X.

When using PHP command "chmod(filename,persmission);" on a file owned by "root",
PHP will say "Operation not permitted". Alright, it looks fine, since apache runs as
"apache" user.

HOWEVER I can easily use "unlink", "move_uploaded_file",
"file_put_contents" and many other PHP functions on files OWNED BY ROOT and any other
user.

So why cant "chmod" change the file permission of a file that other PHP functions may well
EVEN DELETE OR WRITE to that file, despite being owned by another user on ther server. I can see how
this isnt a bug and it took me 3 hours to get to the bottom of it cause I couldnt belive what was
happening since I could easily read/write to files but weirdly, "chmod" couldnt change
permission.

Test script:
---------------
chdmod(filename,0777)

Expected result:
----------------
permission should be shown

Actual result:
--------------
OPERATION NOT PERMITTED.


------------------------------------------------------------------------



--
Edit this bug report at https://bugs.php.net/bug.php?id=80492&edit=1


Thread (5 messages)

« previous php.bugs (#230919) next »