Solved

How to get write permission through web/cgi?

Posted on 1997-05-31
5
158 Views
Last Modified: 2013-12-25
Hi,
I am writing a cgi-perl script that need to open a file(new file),this script will work for all people who have accounts on our server,it should create file in their own home directory.I can check their login names and passwords(let's not worry about security about passwords here).I tried so hard just can not open a file even I made the owner of the script as root(superuser).But if I create a empty file before I run the script(give it write permission), it works!
I hope I do not have to make home directory writeable, and the files have to be in home directory.
Thanks.
shu
0
Comment
Question by:shuchunz
  • 3
  • 2
5 Comments
 
LVL 5

Accepted Solution

by:
julio011597 earned 100 total points
ID: 1828158
It doesn't matter who is the owner of the CGI script.
The script permissions say who can execute the script, but the script itself is run by the web server, which is often user nobody.

So user nobody runs a script which tries to create a file into a directory, and the directory permissions matter: in order to allow the CGI script to create a file, you must make the directory _writable_ to the user who runs the CGI; if the web server runs as user nobody, the directory must be writable by all (i.e. directory mode must be 777 - read, write, search by all).

HTH, julio
0
 

Author Comment

by:shuchunz
ID: 1828159
Thank you, Julio, your answer helps, but I and other people can not make their home directory writable, anyway I have tried what you suggested and it did work.
shu
0
 

Author Comment

by:shuchunz
ID: 1828160
Edited text of question
0
 
LVL 5

Expert Comment

by:julio011597
ID: 1828161
Hello shu,

i'm afraid you want get any further help on this subject, apart by me, since you accepted the answer and this has become a 'Previously Asked Question'.

About your problem, i may see one only work-around, which involves the system administrator's support:

on the target machine there should be a server application which runs as user root (or any other user who may have write permissions on your directories);

your CGI then connects to this server program (maybe through a socket), passing it user name and data to store into the file; the server prog at its turn creates the file in the right directory, possibly setting its owner and permissions, so that the user may then access it.

HTH, julio
0
 
LVL 5

Expert Comment

by:julio011597
ID: 1828162
Hello shu,

i'm afraid you want get any further help on this subject, apart by me, since you accepted the answer and this has become a 'Previously Asked Question'.

About your problem, i may see one only work-around, which involves the system administrator's support:

on the target machine there should be a server application which runs as user root (or any other user who may have write permissions on your directories);

your CGI then connects to this server program (maybe through a socket), passing it user name and data to store into the file; the server prog at its turn creates the file in the right directory, possibly setting its owner and permissions, so that the user may then access it.

HTH, julio
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

The following is a collection of cases for strange behaviour when using advanced techniques in DOS batch files. You should have some basic experience in batch "programming", as I'm assuming some knowledge and not further explain the basics. For some…
This tutorial will discuss the log-in process using WhizBase. In this article I assume you already know HTML. I will write the code using WhizBase Server Pages, so you need to know some basics in WBSP (you might look at some of my other articles abo…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

758 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

19 Experts available now in Live!

Get 1:1 Help Now