Problem running CGI scripts ar a user (not root)

Problem running CGI scripts ar a user (not root)

Post by Ioannis Rizo » Wed, 08 Dec 1999 04:00:00



I try to execute cgi scripts as a normal user. They work fine but they
refuse to write to a user directory if this is
not world writable or own by the apache user (wwwrun). They also refuse
to execute if they are not world readable
and executable.
I have suexec running and the relevant part of httpd.conf file is

ScriptAlias /user/cgi-bin/  "/home/user/public_html/cgi-bin/"
AddHandler cgi-script .cgi
<Directory "/home/user/public_html/cgi-bin">
    AllowOverride None
    Options +ExecCGI -FollowSymLinks
    Order allow,deny
    Allow from all
</Directory>

I would appreciate any help.
Regards
I. Rizos

 
 
 

Problem running CGI scripts ar a user (not root)

Post by Kurt J. Lanz » Thu, 09 Dec 1999 04:00:00



> I try to execute cgi scripts as a normal user. They work fine but they
> refuse to write to a user directory if this is
> not world writable or own by the apache user (wwwrun). They also refuse
> to execute if they are not world readable
> and executable.
> I have suexec running and the relevant part of httpd.conf file is

> ScriptAlias /user/cgi-bin/  "/home/user/public_html/cgi-bin/"
> AddHandler cgi-script .cgi
> <Directory "/home/user/public_html/cgi-bin">
>     AllowOverride None
>     Options +ExecCGI -FollowSymLinks
>     Order allow,deny
>     Allow from all
> </Directory>

The Apache server runs as a particular user with a
particular group id. For a cgi to execute, it must be
executable by that user. For a CGI to create a file, it
must be creating in a directory which is writeable by
that user or group. That's how unix works. Arrange your
permissions accordingly.

 
 
 

Problem running CGI scripts ar a user (not root)

Post by Bill Mosele » Thu, 09 Dec 1999 04:00:00



Quote:> The Apache server runs as a particular user with a
> particular group id. For a cgi to execute, it must be
> executable by that user.

There's a case where that's not exactly correct, from what I've seen.

Say you start Apache non-root, say, user moseley.  

If you have static files (.html, .jpg) owned by moseley, they can be
served with permissions as 400 as expected.

Now, for a CGI owned by user moseley you would expect that to execute
you would need permissions 500.  That doesn't work.  You need 501.

I'm not sure if that's a bug or by design.

If you start Apache as root, but set User moseley then it will execute
with 500 permissions.

This has only been tested on 1.3.9 and Sun 2.6.

--

pls note the one line sig, not counting this one.

 
 
 

Problem running CGI scripts ar a user (not root)

Post by David Efflan » Tue, 14 Dec 1999 04:00:00



>I try to execute cgi scripts as a normal user. They work fine but they
>refuse to write to a user directory if this is
>not world writable or own by the apache user (wwwrun). They also refuse
>to execute if they are not world readable
>and executable.
>I have suexec running and the relevant part of httpd.conf file is

Apparently your suexec is not running properly.  If it was the following
CGI script would show the directory owner's name instead of 'nobody' (or
whoever the webserver is running as).

#!/bin/sh
echo "Content-type: text/plain"
echo ""
echo "This script is running as user:"
/usr/bin/whoami

Also if suexec is working properly a CGI script can run with 700
permission and be able to read and write files with 600 permission.  You
also should not have any trouble creating files in a dir with 755
permission.  What do your suexec_log and error_log say?

Quote:>ScriptAlias /user/cgi-bin/  "/home/user/public_html/cgi-bin/"
>AddHandler cgi-script .cgi
><Directory "/home/user/public_html/cgi-bin">
>    AllowOverride None
>    Options +ExecCGI -FollowSymLinks
>    Order allow,deny
>    Allow from all
></Directory>

>I would appreciate any help.
>Regards
>I. Rizos

--

http://www.de-srv.com/  http://cgi-help.virtualave.net/
http://thunder.prohosting.com/~cv-elgin/
 
 
 

1. How do I enable users to run scripts from ~user/cgi-bin ?

I'm using apache 1.3 on a linux 7.2 system.

I added:

<Directory /home/*/public_html/cgi-bin>
        Options ExecCGI
        SetHandler cgi-script
</Directory>

to my httpd.conf file and restarted, per the FAQ.

When I try to run a script in a users cgi-bin directory I get an error
500.

What am I missing?

Mark Healey
marknews(the 'at' thing)healeyonline.com

2. Patch: allow booting from 21 sectors/track (1722K) floppies

3. Problem running Sybperl scripts as root user

4. mp3 to wave converter of choice

5. run a non-root user's program from a non-root user

6. .Xdefaults widgets

7. PROBLEM: Running X-11 as a normal user (not root)

8. 'ps -aux' and vmstat

9. CGI running as root user

10. CGI running as root user II

11. Running CGI scripts with user permissions in Apache?

12. running cgi scripts in both system and user directories - help

13. can't get cgi scripts to run in user's home directory