Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

how can I get my CGI script to run with my own userid?

Posted on 1998-09-30
4
216 Views
Last Modified: 2013-12-25
I've just moved my web site from one server to another.  They're both redhat linux boxes.  One the old server, when a visitor to my page caused my CGI script to run, it ran with my own userid, so the script was able to update log files and such like, but on the new server the script always runs as the 'nobody' user (which is the user who is running the httpd processes).  So how can I change it to run as myself?  I've been told that maybe using a .htaccess file would do it, but I've tried and failed.  The root user on the server is willing to change the server configuration if that's necessary, too.
0
Comment
Question by:Zwaxy
  • 3
4 Comments
 

Author Comment

by:Zwaxy
ID: 1828887
This is my first question on expert exchange, so please be gentle with me.
0
 

Author Comment

by:Zwaxy
ID: 1828888
This is my first question on expert exchange, so please be gentle with me.
0
 
LVL 7

Accepted Solution

by:
jconde earned 60 total points
ID: 1828889
Hello!.....

In order to run the cgi script with your user ID you must change the cgi's permissions:

ie...

chmod 755 cgi_script
chmod u+s cgi_script

the permissions should look like
-rwsrwxr-x   1 jorge    jorge      736061 Sep 24 15:51 buscar.cgi*

Now, if after doing that it fails, tell the sysadmin you have problems, and to check the httpd.conf file.

If you need a copy of my httpd.conf file, please email me to
jconde@securities.com

bye
jorge
0
 

Author Comment

by:Zwaxy
ID: 1828890
I'm sorry.  I should have said I've already tried the setuid approach.  It doesn't seem to have any affect on the machine.  I don't have the ability to log on as 'nobody', but here are a couple of scripts I've made which are setuid to the 'nobody' account:

--------------------------------
$ ls -l user[35].cgi
-rwsr-xr-x   1 nobody   nobody         53 Oct  1 05:29 user3.cgi
-rwsr-xr-x   1 nobody   nobody         52 Oct  1 05:34 user5.cgi
$ cat user3.cgi
#!/bin/sh

echo 'Content-Type: text/html'
echo ''
id
$ ./user3.cgi
Content-Type: text/html

uid=513(marp) gid=514(marp) groups=514(marp)
$ cat user5.cgi
#!/usr/bin/python

import posix

posix.system('id')
$ ./user5.cgi
uid=513(marp) gid=514(marp) groups=514(marp)
$
--------------------------------

You'll notice that even when I run them from an interactive shell, the output of the 'id' command shows that the euid hasn't changed.  (The 'id' man page says: "By default, it prints the real user ID, real group ID, effective user ID if different from the real user ID,  effective  group ID if different  from the real group ID, and supplemental group IDs."

So I take it that setuid is disabled on this machine, and that this isn't anything to do with the httpd.conf.

Anyway, on the previous server I was using, I didn't have the scripts setuid, and they still ran as my own uid, even though the server was running as 'nobody'.  (And this probably *is* to do with the configuration of the server)...

I just looked in httpd.conf, and saw a reference to Apache docs on the web, which lead me to http://www.apache.org.uk/docs/suexec.html, which begins thusly: "The suEXEC feature -- introduced in Apache 1.2 -- provides Apache users the ability to run CGI and SSI programs under user IDs different from the user ID of the calling web-server."

So I guess I've found what I was looking for.  Now - what happens about the points here?  Your answer kindof helped, in that it lead me to find what I was looking for - so what grade would be fair?  Like I said, I'm new at this...
0

Featured Post

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
get remote physical servers and platforms 5 54
Some AHK commands fail in Microsoft OneNote 5 59
ROBOFTP UNZIP 1 53
Need to combine two scripts 2 33
Introduction:   Welcome to my first article ever. To begin with, the reason I write this article.  I participated in a question on Experts Exchange about the start command in Windows and there were some discussion about the usage. The discussio…
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…
Learn the basics of strings in Python: declaration, operations, indices, and slicing. Strings are declared with quotations; for example: s = "string": Strings are immutable.: Strings may be concatenated or multiplied using the addition and multiplic…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

828 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