CHMOD - User Permissions & "Operation not permitted"

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
JAB Creations
DevNet Resident
Posts: 2341
Joined: Thu Jan 13, 2005 6:44 pm
Location: Sarasota Florida
Contact:

CHMOD - User Permissions & "Operation not permitted"

Post by JAB Creations »

I received the error "Operation not permitted" when attempting to CHMOD with a 777 file to another 777 file in a 777 directory...so I'm pretty sure existing permissions aren't the issue but the user is.

So I've got two questions...

1.) How do I determine who "owns" a file (even though it's MY frigin file!)

2.) How do I make it so my file can CHMOD other files in regards to these permissions?

...in note I usually try to find the lowest CHMOD permissions that work for what I need so I don't leave files at 777 on a regular basis. :mrgreen:
User avatar
s.dot
Tranquility In Moderation
Posts: 5001
Joined: Sun Feb 06, 2005 7:18 pm
Location: Indiana

Re: CHMOD - User Permissions & "Operation not permitted"

Post by s.dot »

I think it depends on whether php is owned by apache or nobody.
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
User avatar
JAB Creations
DevNet Resident
Posts: 2341
Joined: Thu Jan 13, 2005 6:44 pm
Location: Sarasota Florida
Contact:

Re: CHMOD - User Permissions & "Operation not permitted"

Post by JAB Creations »

I had a feeling it had to do with who owns what...so am I in need of telling PHP what group I belong with to begin with? If so how do I declare who/what I am in order to successfully CHMOD?
User avatar
JAB Creations
DevNet Resident
Posts: 2341
Joined: Thu Jan 13, 2005 6:44 pm
Location: Sarasota Florida
Contact:

Re: CHMOD - User Permissions & "Operation not permitted"

Post by JAB Creations »

ftp_login perhaps?
User avatar
JAB Creations
DevNet Resident
Posts: 2341
Joined: Thu Jan 13, 2005 6:44 pm
Location: Sarasota Florida
Contact:

Re: CHMOD - User Permissions & "Operation not permitted"

Post by JAB Creations »

Ah, one of those rare times comments on php.net actually were helpful...adapted with echo (1 = success and I verified this in my FTP)...

Code: Select all

$ftp_details['ftp_user_name'] = username;
$ftp_details['ftp_user_pass'] = passwprd;
$ftp_details['ftp_root'] = '/public_html/';
$ftp_details['ftp_server'] = 'domain.com';
 
function chmod_11oo10($path, $mod, $ftp_details)
{
    // extract ftp details (array keys as variable names)
    extract ($ftp_details);
   
    // set up basic connection
    $conn_id = ftp_connect($ftp_server);
   
    // login with username and password
    $login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);
   
    // try to chmod $path directory
    if (ftp_site($conn_id, 'CHMOD '.$mod.' '.$ftp_root.$path) !== false) {
        $success=TRUE;
    }
    else {
        $success=FALSE;
    }
 
    // close the connection
    ftp_close($conn_id);
    return $success;
}
 
echo chmod_11oo10('members/install.php','777',$ftp_details);
Post Reply