473,386 Members | 1,798 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

PHP issues with file ownership

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
2 1812
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
>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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Julia Goolia | last post by:
hello everyone, i have the following problem. I am trying to create maildir directories on the local filesystem then chmod, chown them to courier:courier (for courier mail server). the courier...
4
by: tarmat | last post by:
I've been using code such as the following, whereby I call the constructor of a class with an object allocated on the heap. The class is responsible for tidying up the memory. class Base{};...
11
by: Jacob | last post by:
I am trying to find the best way of documenting (in code and comments) ownership of secondary contained objects. This is my current status, and I would appreciate feedback on it: Case 1: ...
13
by: raykyoto | last post by:
Hi all, I'm sure this is a popular question that comes up every few months here. Indeed, I've looked at some of the past postings, but I would like to ask things differently. Basically, I'm...
2
by: Benden Ziyade | last post by:
Hello; I want to write a C program that check file ownership in /bin directory(ls, mkdir...). But I don't know how I start. I'm happy with your helping.
1
by: ShaiH | last post by:
When I create a file from a simple command line application written in C# the file ownership given to the newly created file is of administrators group although I am running this application in my...
5
by: bluter | last post by:
We have server components which were created by a third party and compiled in VC++5 (sp3). They run fine on NT4 and 2000, however during testing of our migration to Server 2003, these components...
3
by: Ethan Strauss | last post by:
Hi, I have a C#.Net 2.0 web app which needs to be able to read a bunch of files from a user's computer, but I have not be able to get it to do so without "Access denied" errors. The main piece of...
13
by: eclipsme | last post by:
I thought I had this licked, but apparently not. I have a file upload script that attempts to upload a file to a directory in the public_html directory - www.domain.com/upload The permissions...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.