LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices



Reply
 
Search this Thread
Old 04-19-2004, 06:50 PM   #1
lemotion
LQ Newbie
 
Registered: Apr 2004
Posts: 6

Rep: Reputation: 0
php script can not write text file


Hello everyone !!!

Since a couple of weeks I am using LINUX SuSE 9.0 . Its more than lovely.
Also it can be said of this great forum. It is very very very good. It already helped me a lot finding solutions.

But now I am having a major problem:
I managed to make a FAT32 partition where i've placed my htdos. I also managed to give my FAT32 partition read and write permissions by using the following into my fstab:
/dev/hda7 /windows/win_G vfat defaults,rw,gid=users,uid=dude 0 0
And the write permission works on all files and directories
BUT
My PHP script which should write txt - files gives an error : failed to open stream: Permission denied
So my php script suddenly won't work anymore, and it worked before when I was using windows. I know for sure that the PHP - script is correct. I hope its correct

So I don't know why my PHP script doesn't have write permission !!
I can write the same text - file by using an text-editor like KATE.


Anyone knows how to solves it ?


Philippe
 
Old 04-19-2004, 07:25 PM   #2
mandeltuete
Member
 
Registered: Mar 2003
Location: Switzerland
Distribution: Fedora 3
Posts: 75

Rep: Reputation: 15
You give permissions to user "dude" of group "users" to access your partition, right? (You've set that in your fstab)
Well, if you write to your partition as user "dude" => no problems.
But now, you want to write to the partition from a PHP script. PHP scripts are called by your webserver, it might be Apache in your case. Apache is normally run by user "nobody", group "nobody".
If user nobody tries to write to your FAT partition, it will encounter an error, because only user "dude" has permissions. Either you can set "chmod 666" to your directory, where nobody has to write to. But that let's all other users write in there, what you might not want.
Best way may be to change your fstab.

HTH
 
Old 04-19-2004, 08:31 PM   #3
lemotion
LQ Newbie
 
Registered: Apr 2004
Posts: 6

Original Poster
Rep: Reputation: 0
Thx for your quick reply mandeltuete

Like you mentioned:
I have put user dude of group users in my fstab.
And true I can write as user dude.
But not my PHP - script
I thought it had something to do with Apache using user "nobody".
So
I have two solutions:
either "chmod 666" my directory . Do i do this by the command - konsole ? for example:
chmod 666 txt/ cause all files in this directory may be written by any user (no problem).

The other solutions is the Fstab.
So how do I put user "nobody" in the fstab with also write permissions ?
And is it possible to specify it only on several directories ?

my fstab looks like this right now:
/dev/hda7 /windows/win_G vfat defaults,rw,gid=users,uid=dude 0 0
so gid is group
uid is user
but what and how do i put other users in there ? In that case users nobody for apache ?

P+
 
Old 04-20-2004, 04:45 AM   #4
mandeltuete
Member
 
Registered: Mar 2003
Location: Switzerland
Distribution: Fedora 3
Posts: 75

Rep: Reputation: 15
defaults is the same as the options " rw, suid, dev, exec, auto, nouser and async". So you don't need to specify rw explicitly.

I think you can't add several users to the fstab file. But you could make a new group, put it in your fstab, and then put nobody and dude in the newly created group. Afterwards you can edit the permissions of the group. That should work on a normal filesystem
However fat doesn't support unix permissions, and I can't get a clue out of it, if permissions are used and how they work there :-S

You can add "umask=000" after "uid=dude", and you will have set permissions of 777 to all files on your fat harddisk, and "nobody" should be able to write on it. However now _all_ users can write and read, and execute files. I haven't found other solutions yet

HTH
 
Old 04-20-2004, 06:50 AM   #5
brasshopper
LQ Newbie
 
Registered: Apr 2004
Location: Boca Raton, Florida
Distribution: Fedora/Redhat
Posts: 8

Rep: Reputation: 3
Using a DOS filesystem in a case like this is a big mistake because, as you see, all of the files in the while filesystem take the same permissions. Is there a reason you have to have this partition as DOS?

If you really, really need to do this, you could write a simple program, about 10 lines of Perl, that simply read a filename from stdin and then wrote everything else it read to that filename. You could write a daemon (it could be a shell script even) that ran as dude, user and which ran under xinetd, listening to a particular socket on localhost only, and then you could have it run under a socket and whenever you needed to output, you just open a connection to the socket, sent a line with the name of the file you want to create or append to, and then write your data.

OR you could just change your filesystem type.
 
Old 04-20-2004, 11:14 PM   #6
lemotion
LQ Newbie
 
Registered: Apr 2004
Posts: 6

Original Poster
Rep: Reputation: 0
OKAY I managed to do it like this:

OLD fstab
/dev/hda7 /windows/win_G vfat defaults,rw,gid=users,uid=dude 0 0
NEW fstab
/dev/hda7 /windows/win_G vfat defaults,rw,gid=www,uid=dude,umask=0002 0 0

it works perfect for me

thx for the support

P+


http://www.lemotion.be
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
PHP Shell Script - Read piped text dlublink Linux - Software 3 08-13-2005 02:57 PM
How to find and change a specific text in a text file by using shell script Bassam Programming 1 07-18-2005 08:15 PM
Using c++ to write to a text file. Im having problem with strings swatward Programming 4 02-03-2005 10:17 PM
Linux shell command for makefile.in to create a text file and write to it alix123 Programming 8 01-07-2005 09:18 AM
Red Hat 9 server can't write PHP script, problem in httpd.conf file? x_menno_x Linux - Newbie 27 06-29-2004 05:44 PM


All times are GMT -5. The time now is 11:10 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration