473,385 Members | 1,908 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,385 software developers and data experts.

Running as root, yet permission denied

jn
They have a server here that runs PHP as root (which is probably bad). I
wrote a test script that tries to create a text file.

echo "<B>I'm running as user: " . $_ENV['USER'] . "</B><BR/><BR/>";

//open the file
echo "<B>Opening file text.txt for writing:</B>";
$fp = fopen('text.txt',w);
echo "<BR/>";

if(!$fp){
echo "<B>UNABLE TO CREATE THE FILE!</B>";
exit;
}
I get a permission denied error. The directory is CHMOD 755.
Jul 17 '05 #1
5 2543
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

jn wrote:
They have a server here that runs PHP as root (which is probably
bad). I wrote a test script that tries to create a text file.

echo "<B>I'm running as user: " . $_ENV['USER'] . "</B><BR/><BR/>";


$USER == root is no guarantee that you are running as root. Try adding:

<?php passthru('id'); ?>
Bob

-----BEGIN PGP SIGNATURE-----
Comment: B. Johannessen <bo*@db.org> - http://db.org/contact/en/

iD8DBQFAQH1OooisUyMOFlgRAtRuAJ9LGAfQn+uOxOctYdSfXm 4VJFdBVwCfVT/v
BW/CT3LehI/jWcSxyeMlm04=
=Ykss
-----END PGP SIGNATURE-----
Jul 17 '05 #2
jn
"B. Johannessen" <bo*@db.org> wrote in message
news:i3******************@news4.e.nsc.no...
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

jn wrote:
They have a server here that runs PHP as root (which is probably
bad). I wrote a test script that tries to create a text file.

echo "<B>I'm running as user: " . $_ENV['USER'] . "</B><BR/><BR/>";


$USER == root is no guarantee that you are running as root. Try adding:

<?php passthru('id'); ?>
Bob

-----BEGIN PGP SIGNATURE-----
Comment: B. Johannessen <bo*@db.org> - http://db.org/contact/en/

iD8DBQFAQH1OooisUyMOFlgRAtRuAJ9LGAfQn+uOxOctYdSfXm 4VJFdBVwCfVT/v
BW/CT3LehI/jWcSxyeMlm04=
=Ykss
-----END PGP SIGNATURE-----


Aha:
uid=80(www) gid=80(www) groups=80(www)

So, what do I need to do? Modify the permissions for this user or create a
new user just for PHP?
Jul 17 '05 #3
"jn" <us********************************@jasonnorris.ne t> wrote in message
news:ig**********************@twister.tampabay.rr. com...
Aha:
uid=80(www) gid=80(www) groups=80(www)

So, what do I need to do? Modify the permissions for this user or create a
new user just for PHP?


Modify owner group of directory you want to write (chown root:www
/path/to/dir) and give group www permissions to write (chmod 775
/path/to/dir).
Jul 17 '05 #4
jn
"Pertti Kosunen" <pe************@kolumb.us.fi_invalid> wrote in message
news:c1**********@phys-news1.kolumbus.fi...
"jn" <us********************************@jasonnorris.ne t> wrote in message
news:ig**********************@twister.tampabay.rr. com...
Aha:
uid=80(www) gid=80(www) groups=80(www)

So, what do I need to do? Modify the permissions for this user or create a new user just for PHP?


Modify owner group of directory you want to write (chown root:www
/path/to/dir) and give group www permissions to write (chmod 775
/path/to/dir).


It's fixed. Thanks
Jul 17 '05 #5
In message <ig**********************@twister.tampabay.rr.com> , jn
<us********************************@jasonnorris.ne t> writes
"B. Johannessen" <bo*@db.org> wrote in message
news:i3******************@news4.e.nsc.no...
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

jn wrote:
> They have a server here that runs PHP as root (which is probably
> bad). I wrote a test script that tries to create a text file.
>
> echo "<B>I'm running as user: " . $_ENV['USER'] . "</B><BR/><BR/>";
$USER == root is no guarantee that you are running as root. Try adding:

<?php passthru('id'); ?>
Bob

-----BEGIN PGP SIGNATURE-----
Comment: B. Johannessen <bo*@db.org> - http://db.org/contact/en/

iD8DBQFAQH1OooisUyMOFlgRAtRuAJ9LGAfQn+uOxOctYdSfXm 4VJFdBVwCfVT/v
BW/CT3LehI/jWcSxyeMlm04=
=Ykss
-----END PGP SIGNATURE-----


Aha:
uid=80(www) gid=80(www) groups=80(www)

So, what do I need to do? Modify the permissions for this user or create a
new user just for PHP?

Ensure you have write permissions to the current working directory - if
that is / it shouldn't be!


--
Five Cats
Email to: cats_spam at uk2 dot net
Jul 17 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Jerry | last post by:
Hi All: Is there any way I can get my script to be able to create and CHMOD folders and files??? I always get the following error: mkdir(TESTDIR): Permission denied in /usr/www/users... Is...
1
by: Goblin | last post by:
Hello i have a little code for updating somethink in my SQL database. I get the error: bash: /root/remstats.pl: /usr/bin/perl: bad interpreter: Permission denied Can someone tell me what's wrong?...
1
by: Klunk | last post by:
Hi, last week I moved the folder of my Intranet application to another disk of the same server. After this change all the ASP page return this error: Microsoft VBScript runtime error...
2
by: Rocket Hawk | last post by:
Hello All, I am using windows 2000 server IIS 5.0 i was trying to run bat file from asp page and getting: Access Denied but when i run the bat file from the command prompt on the local...
10
by: Florian G. Pflug | last post by:
Hi I installed a postgres-application (which was developed on debian woody) on red hat 9 today, using the postgres 7.3 rpms from redhad. One of my the triggers uses the pg_settings table (more...
2
by: Taishi | last post by:
New user of SQL Everything is on the same machine My error is close to the bottom After reading it today, I can see there is a problem with 2 dbases 'PUBS' and 'Master' There are also some...
0
by: paulhjwu | last post by:
Hi, I have problems running a couple of shell scripts from PHP. I found a similar posting, so I posted my question to the original author. But unfortunately the original author is not at the...
4
by: stephen | last post by:
Hi, I am getting an error while trying to create an excel file. "Description: The application attempted to perform an operation not allowed by the security policy. To grant this application the...
3
by: chernevik | last post by:
Here is a newbie question: how do I get the server examples in the Preview chapter of "Progamming Python" (Lutz) to run? The code is supposed to be a little webserver on which to run examples,...
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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...
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.