By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,157 Members | 891 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,157 IT Pros & Developers. It's quick & easy.

PHP issues with file ownership

P: n/a
Hi,

I have a PHP script which creates new text files in the same directory
as itself. The new files are also PHP scripts and are built with a
line of code within them, which runs a function when they are browsed
to by the user.

E.g. the new file's contents are similar to <?php runFunction(83); ?>

However, because the new file was created by a script, it does not
have the same owner as the and the function fails. An exact copy of
the file uploaded from my FTP software works fine as it has the same
owner as my script.

The error I receive is that there is a safe mode restriction and the
uid/gid does not match.

I use a shared server, so am reluctant to edit the php.ini file.

I have tried to 'chown' the file after creation but it fails,
(probably because my script is not superuser).

I am running out of ideas, is there another way to change the
ownership to match? Or are there any other options that I can
investigate?
Thanks in advance,
Jon

May 15 '07 #1
Share this Question
Share on Google+
2 Replies


P: n/a
On 15.05.2007 23:54 joniboy123 wrote:
Hi,

I have a PHP script which creates new text files in the same directory
as itself. The new files are also PHP scripts and are built with a
line of code within them, which runs a function when they are browsed
to by the user.

E.g. the new file's contents are similar to <?php runFunction(83); ?>

However, because the new file was created by a script, it does not
have the same owner as the and the function fails. An exact copy of
the file uploaded from my FTP software works fine as it has the same
owner as my script.

The error I receive is that there is a safe mode restriction and the
uid/gid does not match.

I use a shared server, so am reluctant to edit the php.ini file.

I have tried to 'chown' the file after creation but it fails,
(probably because my script is not superuser).

I am running out of ideas, is there another way to change the
ownership to match? Or are there any other options that I can
investigate?
Thanks in advance,
Jon
The simplest way to get around "safe mode" is to change the owner of
main script to www or whatever user your apache runs as. Create a file
"generate.php" with something like

<?php file_put_contents('index.php',
<<<EOF
main script goes here...
EOF
);

upload "generate.php" and run it once. You'll get "index.php" owner by
"www", so it will have full access to other www's files.
--
gosha bine

extended php parser ~ http://code.google.com/p/pihipi
blok ~ http://www.tagarga.com/blok
May 16 '07 #2

P: n/a
>However, because the new file was created by a script, it does not
>have the same owner as the and the function fails. An exact copy of
the file uploaded from my FTP software works fine as it has the same
owner as my script.

The error I receive is that there is a safe mode restriction and the
uid/gid does not match.
But you can administer the server? There are some special permissions
you can set on a directory. One of them is that you execute the file or
directory as the user or group that created it. For directories, this
means that you create files as the directory owner or as member or the
directory's group. See the chmod man page.

Best regards,
--
Willem Bogaerts

Application smith
Kratz B.V.
http://www.kratz.nl/
May 16 '07 #3

This discussion thread is closed

Replies have been disabled for this discussion.