Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

suexec error

167 views
Skip to first unread message

nikos...@gmail.com

unread,
May 30, 2013, 9:30:05 AM5/30/13
to
i want to test a python script i made online online and i receive this message:

[Thu May 30 15:29:33 2013] [error] [client 46.12.46.11] suexec failure: could not open log file
[Thu May 30 15:29:33 2013] [error] [client 46.12.46.11] fopen: Permission denied
[Thu May 30 15:29:33 2013] [error] [client 46.12.46.11] Premature end of script headers: koukos.py
[Thu May 30 15:29:33 2013] [error] [client 46.12.46.11] File does not exist: /home/nikos/public_html/500.shtml

when i tail -F /usr/local/apache/logs/error_log &

What this error means?

Jeff Long

unread,
May 30, 2013, 11:11:23 AM5/30/13
to
On 05/30/2013 08:30 AM, nikos...@gmail.com wrote:
> i want to test a python script i made online online and i receive this message:
>
> [Thu May 30 15:29:33 2013] [error] [client 46.12.46.11] suexec failure: could not open log file
> [Thu May 30 15:29:33 2013] [error] [client 46.12.46.11] fopen: Permission denied
> [Thu May 30 15:29:33 2013] [error] [client 46.12.46.11] Premature end of script headers: koukos.py
> [Thu May 30 15:29:33 2013] [error] [client 46.12.46.11] File does not exist: /home/nikos/public_html/500.shtml


It appears koukos.py is not executing "properly". Have you tried
running it from the command line to see what output it produces?

Jeff Long

Lew Pitcher

unread,
May 30, 2013, 1:04:08 PM5/30/13
to
It appears that the effective user of the script does not have permission to open the log file
that the suexec call requires.
- fopen reported "permission denied", presumably on the logfile
- suexec, receiving the fopen "permission denied" error, reported "could not open log file"

These errors, in turn, seem to have prematurely terminated the script headers that you use in your
koukos.py script, causing the koukos.py script to fail. This caused apache to report (with a generic
and inappropriate error message) that the shtml file that invokes the script failed.

check the user, group, and permissions of the suexec log file, and adjust your script's owner
accordingly.

HTH
--
Lew Pitcher
"In Skills, We Trust"

nagia....@gmail.com

unread,
May 30, 2013, 4:09:10 PM5/30/13
to
Hello Lew, can you please tell me how to do that?

chown nikos:nikos ./koukos.py

and

chmod 755 ./koukos.py

is what you mean? these are all okey.

Richard Kettlewell

unread,
May 30, 2013, 5:16:14 PM5/30/13
to
Lew Pitcher <lew.p...@digitalfreehold.ca> writes:
> nikos...@gmail.com wrote:

>> i want to test a python script i made online online and i receive
>> this message:
>>
>> [Thu May 30 15:29:33 2013] [error] [client 46.12.46.11] suexec failure: could not open log file
>> [Thu May 30 15:29:33 2013] [error] [client 46.12.46.11] fopen: Permission denied
>> [Thu May 30 15:29:33 2013] [error] [client 46.12.46.11] Premature end of script headers: koukos.py
>> [Thu May 30 15:29:33 2013] [error] [client 46.12.46.11] File does not exist: /home/nikos/public_html/500.shtml
>>
>> when i tail -F /usr/local/apache/logs/error_log &
>>
>> What this error means?
>
> It appears that the effective user of the script does not have
> permission to open the log file that the suexec call requires.

That can’t be right; suexec opens the logfile before changing UID. The
most likely explanation is that suexec is wrongly installed.

--
http://www.greenend.org.uk/rjk/

nagia....@gmail.com

unread,
May 31, 2013, 12:40:14 AM5/31/13
to
But i have mnay python scripts why the problem only appear to this one (koukos.py) ?

nikos...@gmail.com

unread,
May 31, 2013, 4:00:34 AM5/31/13
to
If i delete the script and recreate it i would still ahve the same problem?
Whjy the problem doesnt appear in other scrips as well?

Richard Kettlewell

unread,
May 31, 2013, 4:07:06 AM5/31/13
to
nagia....@gmail.com writes:
> Richard Kettlewell έγραψε:
>> That can’t be right; suexec opens the logfile before changing UID.
>> The most likely explanation is that suexec is wrongly installed.
>
> But i have mnay python scripts why the problem only appear to this one
> (koukos.py) ?

Perhpas you’re not invoking those scripts through suexec.

--
http://www.greenend.org.uk/rjk/

nikos...@gmail.com

unread,
May 31, 2013, 4:29:30 AM5/31/13
to
I'am using CentOS v6.4

What is 'suexec' and why is this happening only when i try to run koukos.py script and doesnt not also happen to any other pythons cripts iam using too?

Richard Kettlewell

unread,
May 31, 2013, 5:16:58 AM5/31/13
to
nikos...@gmail.com writes:
> Richard Kettlewell έγραψε:
>> nagia....@gmail.com writes:
>>> Richard Kettlewell έγραψε:

>>>> That can’t be right; suexec opens the logfile before changing UID.
>>>> The most likely explanation is that suexec is wrongly installed.
>>
>>> But i have mnay python scripts why the problem only appear to this one
>>> (koukos.py) ?
>>
>> Perhpas you’re not invoking those scripts through suexec.
>
> I'am using CentOS v6.4
>
> What is 'suexec' and why is this happening only when i try to run
> koukos.py script and doesnt not also happen toany other pythons cripts
> iam using too?

http://httpd.apache.org/docs/2.2/suexec.html

I have no idea what’s special about this particular script. Studying
the ‘Using suEXEC’ section of the documentation might help.

--
http://www.greenend.org.uk/rjk/

nikos...@gmail.com

unread,
May 31, 2013, 8:42:48 AM5/31/13
to
[QUOTE=zxq9]On CentOS the Apache server is guarded by a pretty huge set of SELinux protections. These are almost certainly denying access to stuff in /home from scripts run by Apache.

suexec is an Apache plugin that lets the part of Apache that executes scripts run another program as a user other than "apache". In this case it is trying to execute your .py script as your username.

I hate to sound paternal here, but you should read the Apache and RHEL/CentOS/SL docs to understand what you're getting into.

That said, what problem are you actually trying to solve? What is the overall thing you are trying to do or effect you are trying to achieve?[/QUOTE]

I have created a python 3 script to actually try to set up a cooki, nothign special or somethign that need some extra access. here is the code:


[code]
#!/usr/bin/python3
# coding=utf-8

import cgitb; cgitb.enable()
import cgi, os, sys
from http import cookies

# initialize cookie
cookie = cookies.SimpleCookie( os.environ.get('HTTP_COOKIE') )
cookie.load( cookie )
nikos = cookie.get('nikos')

# if visitor cookie does exist
if nikos:
msg = "ΑΠΟ ΤΗΝ ΕΠΟΜΕΝΗ ΕΠΙΣΚΕΨΗ ΣΟΥ ΘΑ ΣΕ ΥΠΟΛΟΓΙΖΩ ΩΣ ΕΠΙΣΚΕΠΤΗ ΑΥΞΑΝΟΝΤΑΣ ΤΟΝ ΜΕΤΡΗΤΗ!"
cookie['nikos'] = 'admin'
cookie['nikos']['path'] = '/'
cookie['nikos']['expires'] = -1 #this cookie will expire now
else:
msg = "ΑΠΟ ΔΩ ΚΑΙ ΣΤΟ ΕΞΗΣ ΔΕΝ ΣΕ ΕΙΔΑ, ΔΕΝ ΣΕ ΞΕΡΩ, ΔΕΝ ΣΕ ΑΚΟΥΣΑ! ΘΑ ΕΙΣΑΙ ΠΛΕΟΝ Ο ΑΟΡΑΤΟΣ ΕΠΙΣΚΕΠΤΗΣ!!"
cookie['nikos'] = 'admin'
cookie['nikos']['path'] = '/'
cookie['nikos']['expires'] = 60*60*24*30*12 #this cookie will expire in a year


#needed line, script does *not* work without it
sys.stdout = os.fdopen(1, 'w', encoding='utf-8')

print( cookie )
print ( "Content-type: text/html; charset=utf-8\n" )
print( msg )

sys.exit(0)
[/code]

is till wonder how the other scripts which they do more stuff dont provide me this suecec error.

Should i delete and recreate the koukos.py file?

Richard Kettlewell

unread,
May 31, 2013, 8:53:44 AM5/31/13
to
nikos...@gmail.com writes:
> Should i delete and recreate the koukos.py file?

There is no point doing that. suexec is not getting as far as running
the script. You need to study the Apache manual and your local
configuration, to discover why suexec is being used when (apparently)
you don’t want it to be. Making random changes without understanding
what’s going on is not likely to help.

--
http://www.greenend.org.uk/rjk/

nikos...@gmail.com

unread,
May 31, 2013, 9:03:26 AM5/31/13
to
Can someone please look into this because iam unexperienced with these types of issues?

Richard can you give it a try please if i provide you with access to my VPS?
0 new messages