Thread: Suexec error

    #1
  1. Contributing User
    Devshed Beginner (1000 - 1499 posts)

    Join Date
    Jun 2003
    Location
    Thessaloniki
    Posts
    1,280
    Rep Power
    13

    Question Suexec error


    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?

    [code]
    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"
    /code]

    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.



    chown nikos:nikos ./koukos.py

    and

    chmod 755 ./koukos.py

    is what you mean? these are all okey.
    What is now proved was once only imagined!
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2013
    Location
    Usually Japan when not on contract
    Posts
    240
    Rep Power
    12
    Depending on what flavor of Linux you are using suexec is probably heavily guarded by default and might require a special permission (beyond file permissions) to open files outside of /var/www.

    You need to provide more information about your system before anyone can help.
  4. #3
  5. Contributing User
    Devshed Beginner (1000 - 1499 posts)

    Join Date
    Jun 2003
    Location
    Thessaloniki
    Posts
    1,280
    Rep Power
    13
    Originally Posted by zxq9
    Depending on what flavor of Linux you are using suexec is probably heavily guarded by default and might require a special permission (beyond file permissions) to open files outside of /var/www.

    You need to provide more information about your system before anyone can help.
    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?
    What is now proved was once only imagined!
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2013
    Location
    Usually Japan when not on contract
    Posts
    240
    Rep Power
    12
    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?
  8. #5
  9. Contributing User
    Devshed Beginner (1000 - 1499 posts)

    Join Date
    Jun 2003
    Location
    Thessaloniki
    Posts
    1,280
    Rep Power
    13
    Originally Posted by 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?
    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)
    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?
    What is now proved was once only imagined!
  10. #6
  11. Contributing User
    Devshed Beginner (1000 - 1499 posts)

    Join Date
    Jun 2003
    Location
    Thessaloniki
    Posts
    1,280
    Rep Power
    13
    suexec is not getting as far as running
    the script. I need to study the Apache manual and my local
    configuration, to discover why suexec is being used when
    i donít want it to be. Making random changes without understanding
    whatís going on is not likely to help.

    Can someone please look into this because iam unexperienced with these types of issues?
    What is now proved was once only imagined!

IMN logo majestic logo threadwatch logo seochat tools logo