Re: Warning: chmod(): Operation not permitted ?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



tedd wrote:
At 11:18 AM -0400 5/17/06, John Nichel wrote:
tedd wrote:
Hi (please insert your preference):

This should be simple, but I'm having problems.

I have a program that uploads an image file and then tries to set the permissions for the image (to be altered later). However, I get a "Warning: chmod(): Operation not permitted" error when trying to set the permission, what gives? If my program created the file, shouldn't it have permission to set the files permissions?

What am I not understanding?

Without seeing code, permissions of the directories, what sticky bits might or might not be set, etc., you could not be understanding many things....or just one....who knows.

I read all of your Google links, but no help. Just another example of how Google is not the answer.

Then you're asking the wrong question.

In any event, my code is pretty simple, just:

chmod($url, 0755);  //where $url is the file I want to change.

The error I receive is noted above in the subject line.

The permissions of the directories vary, but the folder that has the file I want to change permissions is currently set at 0777.

Nice security there. Regardless, even if the user your webserver is running as has write permission to the directory (don't know who owns/what group that directory belongs to, as you didn't tell us that), you won't be able to change permissions of a file in that directory if the file isn't owned by the same user apache is running as.

In doing a lstat() of both the parent program that created the file and the child file shows that they both have the identical uid and gid (i.e., the same user and group id's).

And what user does Apache run as?

Now, everything I've read, says:

chmod() changes the permission of the specified file with the following caveat.

"chmod() can only change the permissions of files that are owned by the user running the command. In most cases, this is the user that the web server runs on."

That confuses me, because who's the user here? Is it just the system administrator or the application?

And if it is just the system administrator, then can't the system admin change anything he/she wants anyway? What's the point of having uid and gid's if a program can't change the permissions of a sibling file?

This question should answer the previous question for you.

I have tons of references as to what php filesystem functions are available, but I need a good reference as to what permissions are and how they actually can be changed in php -- does anyone have one a good reference OR care to explain?

As it is now, I know how ride the horse, but I can't get the gate open.

File permissions is beyond the scope of this mailing list. You need to buy a book, research on the web, etc., on *nix system administration, and concentrate on the filesystem/security/permissions sections, and the section on how apps/daemons operate.

--
John C. Nichel IV
Programmer/System Admin (ÜberGeek)
Dot Com Holdings of Buffalo
716.856.9675
jnichel@xxxxxxxxxxxxxxxxxxxxxxxxxxx

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux