Page 1 of 1

CHMOD - User Permissions & "Operation not permitted"

Posted: Sat Jul 19, 2008 9:22 pm
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:

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

Posted: Sat Jul 19, 2008 9:25 pm
by s.dot
I think it depends on whether php is owned by apache or nobody.

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

Posted: Sat Jul 19, 2008 9:27 pm
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?

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

Posted: Sat Jul 19, 2008 9:30 pm
by JAB Creations
ftp_login perhaps?

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

Posted: Sat Jul 19, 2008 9:53 pm
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);