Solved

Nobody:Nobody Permission error

Posted on 2003-11-23
3
1,018 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
3 Comments
 
LVL 1

Accepted Solution

by:
zariok earned 125 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Deprecated and Headed for the Dustbin By now, you have probably heard that some PHP features, while convenient, can also cause PHP security problems.  This article discusses one of those, called register_globals.  It is a thing you do not want.  …
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

920 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now