Solved

How to get write permission through web/cgi?

Posted on 1997-05-31
5
176 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

Space-Age Communications Transitions to DevOps

ViaSat, a global provider of satellite and wireless communications, securely connects businesses, governments, and organizations to the Internet. Learn how ViaSat’s Network Solutions Engineer, drove the transition from a traditional network support to a DevOps-centric model.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Linux Scripting 3 162
Powershell script- running set owner command on multiple servers at once 7 93
AWK: digits < 10 add a zero how? 11 28
Debug script powershell wmi 3 18
This tutorial will discuss fancy secure registration forms, with AJAX technology support. In this article I assume you already know HTML and some JS. I will write the code using WhizBase Server Pages, so you need to know some basics in WBSP (you mig…
Batch, VBS, and scripts in general are incredibly useful for repetitive tasks.  Some tasks can take a while to complete and it can be annoying to check back only to discover that your script finished 5 minutes ago.  Some scripts may complete nearly …
Learn the basics of if, else, and elif statements in Python 2.7. Use "if" statements to test a specified condition.: The structure of an if statement is as follows: (CODE) Use "else" statements to allow the execution of an alternative, if the …
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…

679 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