Question on python script in c wrapper with apache.
Wayne Ringling
wayne at tbnets.com
Wed Sep 5 22:55:29 EDT 2001
I am trying to use a python script to run as root for small special tasks.
I have done the following and at the present getting these errors.
Compiled setuid-prog.c with the below command
cc -DFULL_PATH='"/some_dir/myscriptname.py"' setuid-prog.c -o myscriptname
Copied the wrapper to my web servers cgi-bin dir and it has (for now) 755
permissions.
Next I created /some_dir/myscripname.py as follows and it has permissions
755.
----------------------------------------------------------------------------
-------
#!/usr/bin/python
import string
lines = open('/etc/passwd').readlines()
dict={}
for line in lines:
splitline = string.splitfields(line, ':')
uid = splitline[2]
dict[string.atoi(uid)] = line
keys = dict.keys()
keys.sort()
print 'Content-type: text/html\n\n'
for uid in dict.keys():
print dict[uid],
----------------------------------------------------------------------------
--------
The script runs fine from command line but not from the web server.
Error msgs are :
access_log:
XXX.XXX.XXX.XXX - - [06/Sep/2001:04:48:52 +0000] "GET /cgi-bin/admin
HTTP/1.1" 500 614
error_log:
myscriptname: could not execute the script
[Thu Sep 6 04:48:52 2001] [error] [client XX.XX.XX.XX] Premature end of
script headers: /usr/local/httpd/cgi-bin/admin
Any ideas greatly appreciated.
Wayne
More information about the Python-list
mailing list