Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Nobody:Nobody Permission error

Posted on 2003-11-23
3
Medium Priority
?
1,044 Views
Last Modified: 2012-06-21
Hi

Here is my script



PHP:
--------------------------------------------------------------------------------
 
function copyDirectory($from, $to) {
        $GLOBALS['recursiveCopyFrom'] = $from;
        $GLOBALS['recursiveCopyTo'] = $to;
        _recursiveCopy('');
}        
                 
/**              
* This shouldn't be called directly, it is used by the copyDirectory function.
* Parameters are only relative paths.
*/              
function _recursiveCopy($relPath) {
        $from = $GLOBALS['recursiveCopyFrom'] . '/' . $relPath;
        $to = $GLOBALS['recursiveCopyTo'] . '/' . $relPath;
        $mode = 0755;
        mkdir($to, $mode);  
        $dir = opendir($from);
        while (($item = readdir($dir)) !== false) {
                $path = $from . '/' . $item;
                if (is_dir($path)) {
                        if ($item[0] == '.') continue; // don't copy '.' or '..'
                        _recursiveCopy($relPath . '/' . $item);
                } else {
                        copy($from, $to . '/' . $item);
                }
        }
        closedir($dir);
}


copyDirectory($from,$to);

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



The problem I have it that the permissions are set to nobody:nobody. I do not own the system, is it possible to change nobody:nobody to jamesm:jamesm in that script?

I then tried:

copy($from, $to . '/' . $item);  
chown($to . '/' . $item, "user");
chgrp($to . '/' . $item, "group");

But I got this error:

Warning: chgrp(): Operation not permitted in /home/jamesm/public_html/auto.php on line 52

Warning: chown(): Operation not permitted in /home/jamesm/public_html/auto.php on line 51


Is it possible to create the file with the permission of jamesm:jamesm other than afterwards when I have no controll over it? I am using a shared server.

Thanks
0
Comment
Question by:jamesm87
1 Comment
 
LVL 1

Accepted Solution

by:
zariok earned 500 total points
ID: 9807604
If you are running the script via http://server.example.com/scriptname.php, then NO is your answer.  Apache/PHP will run as nobody:nobody and you will not be able to change it to another user.

Now, if you're running via the CLI PHP (read: cron), then copying the file should create the file with your identity (jamesm).

0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Part of the Global Positioning System A geocode (https://developers.google.com/maps/documentation/geocoding/) is the major subset of a GPS coordinate (http://en.wikipedia.org/wiki/Global_Positioning_System), the other parts being the altitude and t…
This article discusses how to implement server side field validation and display customized error messages to the client.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to dynamically set the form action using jQuery.
Suggested Courses

877 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question