Errin when executing a cgi script that sets a cookie in the browser

  • Thread starter Íéêüëáïò Êïýñáò
  • Start date
L

Lele Gaifax

Skip Montanaro said:
He will get an extra blank line, since he added a newline character at
the end of his Content-Type string.

Right, missed that, sorry for the noise.
ciao, lele.
 
Í

Íéêüëáïò Êïýñáò

Any other ideas guys?
I can output for you any command you ask me too, so you have a better understanding about this suexec thing.


I have checked the path to the error log file too, it's not just enough
that the file is accessible for a user, the whole path to the file needs
to have the right permissions.

ls -ld /var/log/httpd
ls -ld /var/log

both of those needs to have xr for group and others (as far as i know x allows a user to get into the directory, r gives the user the ability to list files in the directory).

So,

---------------------------------------------------
(e-mail address removed) [~]# ls -ld /var/log/
drwxr-xr-x 8 root root 4096 Jun 6 08:56 /var/log//

root@nikos [~]# ls -ld /var/log/httpd/
drw-rw-rw- 2 root root 4096 Jun 6 22:03 /var/log/httpd//

root@nikos [~]# chmod 666 /var/log/httpd/
root@nikos [~]# ls -l /var/log/httpd/
total 8
drw-rw-rw- 2 root root 4096 Jun 6 22:03 ./
drwxr-xr-x 8 root root 4096 Jun 7 10:02 ../
-rwxr-xr-x 1 nobody nobody 0 Apr 14 08:57 error_log*
-rwxr-xr-x 1 nobody nobody 0 Jun 1 02:52 suexec_log*

----------------------------------------------------------

(e-mail address removed) [~]# ls -ld /usr/local/apache/logs/
drwxr-xr-x 2 root root 4096 Jun 6 08:14 /usr/local/apache/logs//

(e-mail address removed) [~]# ls -ld /usr/local/apache/
drwxr-xr-x 17 root root 4096 May 16 22:46 /usr/local/apache//

root@nikos [~]# chown nobody:nobody /usr/local/apache/logs/suexec_log

root@nikos [~]# ls -l /usr/local/apache/logs/suexec_log
-rw-rw-r-- 1 nobody nobody 678180 Jun 7 08:29 /usr/local/apache/logs/suexec_log
root@nikos [~]#

----------------------------------------------------------

Because i'm a bit confused both 'suexec' files need to change?
And what are the differences of them?
Why two 'suexec' logs appear?
httpd != Apache ?
 
Í

Íéêüëáïò Êïýñáò

Finally no suexec erros any more after chown all log files to nobody:nobodyand thei corresponding paths.

Now the error has been transformed to:


[Fri Jun 07 10:48:47 2013] [error] [client 79.103.41.173] (2)No such file or directory: exec of '/home/nikos/public_html/cgi-bin/koukos.py' failed
[Fri Jun 07 10:48:47 2013] [error] [client 79.103.41.173] Premature end of script headers: koukos.py
[Fri Jun 07 10:48:47 2013] [error] [client 79.103.41.173] File does not exist: /home/nikos/public_html/500.shtml


but from interpretor view:

(e-mail address removed) [~/www/cgi-bin]# python koukos.py
Set-Cookie: nikos=admin; expires=Mon, 02 Jun 2014 07:50:18 GMT; Path=/
Content-type: text/html; charset=utf-8

ÁÐÏ ÄÙ ÊÁÉ ÓÔÏ ÅÎÇÓ ÄÅÍ ÓÅ ÅÉÄÁ, ÄÅÍ ÓÅ ÎÅÑÙ, ÄÅÍ ÓÅ ÁÊÏÕÓÁ!ÈÁ ÅÉÓÁÉ ÐËÅÏÍ Ï ÁÏÑÁÔÏÓ ÅÐÉÓÊÅÐÔÇÓ!!



(2)No such file or directory: exec of '/home/nikos/public_html/cgi-bin/koukos.py' failed

???? Can find what? koukos.py is there inside the cg-bin dir with 755 perms..
 
M

MRAB

Finally no suexec erros any more after chown all log files to nobody:nobody and thei corresponding paths.

Now the error has been transformed to:


[Fri Jun 07 10:48:47 2013] [error] [client 79.103.41.173] (2)No such file or directory: exec of '/home/nikos/public_html/cgi-bin/koukos.py' failed
[Fri Jun 07 10:48:47 2013] [error] [client 79.103.41.173] Premature end of script headers: koukos.py
[Fri Jun 07 10:48:47 2013] [error] [client 79.103.41.173] File does not exist: /home/nikos/public_html/500.shtml


but from interpretor view:

(e-mail address removed) [~/www/cgi-bin]# python koukos.py
Set-Cookie: nikos=admin; expires=Mon, 02 Jun 2014 07:50:18 GMT; Path=/
Content-type: text/html; charset=utf-8

ÁÐÏ ÄÙ ÊÁÉ ÓÔÏ ÅÎÇÓ ÄÅÍ ÓÅ ÅÉÄÁ, ÄÅÍ ÓÅ ÎÅÑÙ, ÄÅÍ ÓÅ ÁÊÏÕÓÁ! ÈÁ ÅÉÓÁÉ ÐËÅÏÍ Ï ÁÏÑÁÔÏÓ ÅÐÉÓÊÅÐÔÇÓ!!



(2)No such file or directory: exec of '/home/nikos/public_html/cgi-bin/koukos.py' failed

???? Can find what? koukos.py is there inside the cg-bin dir with 755 perms.
It's looking for '/home/nikos/public_html/cgi-bin/koukos.py'.

Have a look in '/home/nikos/public_html/cgi-bin'. Is 'koukos.py' in
there?
 
Í

Íéêüëáïò Êïýñáò

Ôç ÐáñáóêåõÞ, 7 Éïõíßïõ 2013 5:32:09 ì.ì. UTC+3, ï ÷ñÞóôçò MRAB Ýãñáøå:
It's looking for '/home/nikos/public_html/cgi-bin/koukos.py'.

Its looking for its self?!?!
Have a look in '/home/nikos/public_html/cgi-bin'. Is 'koukos.py' in
there?
Yes it is.


(e-mail address removed) [~/www/cgi-bin]# ls -l
total 56
drwxr-xr-x 2 nikos nikos 4096 Jun 6 20:29 ./
drwxr-x--- 4 nikos nobody 4096 Jun 5 11:32 ../
-rwxr-xr-x 1 nikos nikos 1199 Apr 25 15:33 convert.py*
-rwxr-xr-x 1 nikos nikos 5434 Jun 7 14:51 files.py*
-rw-r--r-- 1 nikos nikos 170 May 30 15:18 .htaccess
-rwxr-xr-x 1 nikos nikos 1160 Jun 6 06:27 koukos.py*
-rwxr-xr-x 1 nikos nikos 9356 Jun 6 09:13 metrites.py*
-rwxr-xr-x 1 nikos nikos 13512 Jun 6 09:13 pelatologio.py*
(e-mail address removed) [~/www/cgi-bin]#
 
M

MRAB

Ôç ÐáñáóêåõÞ, 7 Éïõíßïõ 2013 5:32:09 ì.ì. UTC+3, ï ÷ñÞóôçò MRAB Ýãñáøå:
It's looking for '/home/nikos/public_html/cgi-bin/koukos.py'.

Its looking for its self?!?!
Have a look in '/home/nikos/public_html/cgi-bin'. Is 'koukos.py' in
there?
Yes it is.


(e-mail address removed) [~/www/cgi-bin]# ls -l
total 56
drwxr-xr-x 2 nikos nikos 4096 Jun 6 20:29 ./
drwxr-x--- 4 nikos nobody 4096 Jun 5 11:32 ../
-rwxr-xr-x 1 nikos nikos 1199 Apr 25 15:33 convert.py*
-rwxr-xr-x 1 nikos nikos 5434 Jun 7 14:51 files.py*
-rw-r--r-- 1 nikos nikos 170 May 30 15:18 .htaccess
-rwxr-xr-x 1 nikos nikos 1160 Jun 6 06:27 koukos.py*
-rwxr-xr-x 1 nikos nikos 9356 Jun 6 09:13 metrites.py*
-rwxr-xr-x 1 nikos nikos 13512 Jun 6 09:13 pelatologio.py*
(e-mail address removed) [~/www/cgi-bin]#
The prompt says "~/www/cgi-bin".

Is that the same as "/home/nikos/public_html/cgi-bin"?

Try:

ls -l /home/nikos/public_html/cgi-bin
 
Í

Íéêüëáïò Êïýñáò

Ôç ÐáñáóêåõÞ, 7 Éïõíßïõ 2013 11:47:58 ì.ì. UTC+3, ï ÷ñÞóôçò MRAB Ýãñáøå:
Ôç ÐáñáóêåõÞ, 7 Éïõíßïõ 2013 5:32:09 ì.ì. UTC+3, ï ÷ñÞóôçò MRAB Ýãñáøå:


Its looking for its self?!?!
Yes it is.
(e-mail address removed) [~/www/cgi-bin]# ls -l
drwxr-xr-x 2 nikos nikos 4096 Jun 6 20:29 ./
drwxr-x--- 4 nikos nobody 4096 Jun 5 11:32 ../
-rwxr-xr-x 1 nikos nikos 1199 Apr 25 15:33 convert.py*
-rwxr-xr-x 1 nikos nikos 5434 Jun 7 14:51 files.py*
-rw-r--r-- 1 nikos nikos 170 May 30 15:18 .htaccess
-rwxr-xr-x 1 nikos nikos 1160 Jun 6 06:27 koukos.py*
-rwxr-xr-x 1 nikos nikos 9356 Jun 6 09:13 metrites.py*
-rwxr-xr-x 1 nikos nikos 13512 Jun 6 09:13 pelatologio.py*
(e-mail address removed) [~/www/cgi-bin]#

The prompt says "~/www/cgi-bin".



Is that the same as "/home/nikos/public_html/cgi-bin"?



Try:



ls -l /home/nikos/public_html/cgi-bin

Good day MRAB, yes '~/www' its a symlink to '~/public_html'

(e-mail address removed) [~/www/data/apps]# ls -ld /home/nikos/www/
drwxr-x--- 4 nikos nobody 4096 Jun 5 11:32 /home/nikos/www//
(e-mail address removed) [~/www/data/apps]# ls -ld /home/nikos/public_html/
drwxr-x--- 4 nikos nobody 4096 Jun 5 11:32 /home/nikos/public_html//
(e-mail address removed) [~/www/data/apps]# ls -l /home/nikos/public_html/cgi-bin
total 56
drwxr-xr-x 2 nikos nikos 4096 Jun 6 20:29 ./
drwxr-x--- 4 nikos nobody 4096 Jun 5 11:32 ../
-rwxr-xr-x 1 nikos nikos 1199 Apr 25 15:33 convert.py*
-rwxr-xr-x 1 nikos nikos 5793 Jun 8 09:39 files.py*
-rw-r--r-- 1 nikos nikos 170 May 30 15:18 .htaccess
-rwxr-xr-x 1 nikos nikos 1160 Jun 6 06:27 koukos.py*
-rwxr-xr-x 1 nikos nikos 9356 Jun 6 09:13 metrites.py*
-rwxr-xr-x 1 nikos nikos 13512 Jun 6 09:13 pelatologio.py*
(e-mail address removed) [~/www/data/apps]# ls -l /home/nikos/www/cgi-bin/
total 56
drwxr-xr-x 2 nikos nikos 4096 Jun 6 20:29 ./
drwxr-x--- 4 nikos nobody 4096 Jun 5 11:32 ../
-rwxr-xr-x 1 nikos nikos 1199 Apr 25 15:33 convert.py*
-rwxr-xr-x 1 nikos nikos 5793 Jun 8 09:39 files.py*
-rw-r--r-- 1 nikos nikos 170 May 30 15:18 .htaccess
-rwxr-xr-x 1 nikos nikos 1160 Jun 6 06:27 koukos.py*
-rwxr-xr-x 1 nikos nikos 9356 Jun 6 09:13 metrites.py*
-rwxr-xr-x 1 nikos nikos 13512 Jun 6 09:13 pelatologio.py*
(e-mail address removed) [~/www/data/apps]#
 
C

Chris Angelico

Ôç ÐáñáóêåõÞ, 7 Éïõíßïõ 2013 11:47:58ì.ì. UTC+3, ï ÷ñÞóôçò MRAB Ýãñáøå:
It's looking for '/home/nikos/public_html/cgi-bin/koukos.py'.
Have a look in '/home/nikos/public_html/cgi-bin'. Is 'koukos.py' in
there?
Yes it is.
(e-mail address removed) [~/www/cgi-bin]# ls -l
-rwxr-xr-x 1 nikos nikos 1160 Jun 6 06:27 koukos.py*
The prompt says "~/www/cgi-bin".
Is that the same as "/home/nikos/public_html/cgi-bin"?
Good day MRAB, yes '~/www' its a symlink to '~/public_html'

More basics. When someone asks you to check something, check exactly
that. It really does not help to check something unrelated. If you'd
shown in your prompt ~/public_html/cgi-bin rather than your symlink of
www, there would have been less confusion; putting the full path in as
a parameter would eliminate all trouble. By using the symlink, you
demand that we understand or assume something about your system, and
that's unnecessary.

ChrisA
 
Í

Íéêüëáïò Êïýñáò

Ôç ÓÜââáôï, 8 Éïõíßïõ 2013 10:01:51 ð.ì.. UTC+3, ï ÷ñÞóôçò Chris Angelico Ýãñáøå:
Ôç ÐáñáóêåõÞ, 7 Éïõíßïõ 2013 11:47:58 ì.ì. UTC+3, ï ÷ñÞóôçò MRAB Ýãñáøå:
It's looking for '/home/nikos/public_html/cgi-bin/koukos.py'.
Have a look in '/home/nikos/public_html/cgi-bin'. Is 'koukos.py' in
there?
Yes it is.
(e-mail address removed) [~/www/cgi-bin]# ls -l
-rwxr-xr-x 1 nikos nikos 1160 Jun 6 06:27 koukos.py*
The prompt says "~/www/cgi-bin".
Is that the same as "/home/nikos/public_html/cgi-bin"?
Good day MRAB, yes '~/www' its a symlink to '~/public_html'



More basics. When someone asks you to check something, check exactly

that. It really does not help to check something unrelated. If you'd

shown in your prompt ~/public_html/cgi-bin rather than your symlink of

www, there would have been less confusion; putting the full path in as

a parameter would eliminate all trouble. By using the symlink, you

demand that we understand or assume something about your system, and

that's unnecessary.

Well, www as symlink to public_html is always a symlink to any system i have used so its something defaulted.
 
Í

Íéêüëáïò Êïýñáò

Ôç ÓÜââáôï, 8 Éïõíßïõ 2013 7:03:57 ì.ì.UTC+3, ï ÷ñÞóôçò Chris Angelico Ýãñáøå:
It's most certainly not the default, it's definitely not universal
and that has nothing to do with what I said. Use the exact same path,
it reduces confusion. Also, I think it's time to mention again: Get
yourself off Google Groups, or start trimming out the stupid double
spacing! It's getting extremely annoying.


its very tedious to always triming everything for me and i know it is for you to ead it assuc. Damn google groups, why is it behaving as such?
Dont the programmers know about it?

Also everytime i post it always display to me different addresses to get responses back.

Any way what did you say and i havent understand you correctly?
What path do you want me to show to you?

What does this error means anyway?
 
Í

Íéêüëáïò Êïýñáò

Ôç ÊõñéáêÞ, 9 Éïõíßïõ 2013 12:17:16 ð.ì.. UTC+3, ï ÷ñÞóôçò Michael Torrie Ýãñáøå:
It means that Apache is unable to find your cgi script. It's turning
the url into a file path, but it can't find the file path. Sometimes
Apache is configured to not follow symlinks.

Why every other python cgi script of mine that i run via browser doesnt produce this kind of error and only 'koukos.py' does?
It's confusing too because you have two apaches installed. The system
default one and the one that comes with cPanel.

Hi Michael, indeed they are too.
I wonder why cPanel deosnt use the default apache that came with the systemand isntead complied its own.

anyway httpd.conf seems correct
==========
root@nikos [~]# cat /usr/local/apache/conf/httpd.conf | grep 'www'
# system refer to the documentation at: http://www.cpanel.net/support/docs/ea/ea3/customdirectives.html #
# system refer to the documentation at: http://www.cpanel.net/support/docs/ea/ea3/customdirectives.html #
ServerAlias www.varsa.gr
ServerAlias www.parking-byzantio.gr
ServerAlias www.cafebar-idea.gr
ServerAlias www.dauwin.gr
ServerAlias www.leonidasgkelos.com
ServerAlias www.mythosweb.gr
ServerAlias www.superhost.gr
ServerAlias www.panostech.gr
ServerAlias www.pdimou.gr
ServerAlias www.radio-klepsydra.com
ServerAlias www.cravendot.gr
ServerAlias www.ypsilandio.gr
ServerAlias www.oliveoils.mythosweb.gr
ServerAlias www.zimotirio.pdimou.gr

root@nikos [~]# cat /usr/local/apache/conf/httpd.conf | grep 'public_html'
UserDir public_html
DocumentRoot /home/akis/public_html
ScriptAlias /cgi-bin/ /home/akis/public_html/cgi-bin/
DocumentRoot /home/byzantio/public_html
ScriptAlias /cgi-bin/ /home/byzantio/public_html/cgi-bin/
DocumentRoot /home/cafebar/public_html
ScriptAlias /cgi-bin/ /home/cafebar/public_html/cgi-bin/
DocumentRoot /home/dauwin/public_html
ScriptAlias /cgi-bin/ /home/dauwin/public_html/cgi-bin/
DocumentRoot /home/gkelos/public_html
ScriptAlias /cgi-bin/ /home/gkelos/public_html/cgi-bin/
DocumentRoot /home/mythos/public_html
ScriptAlias /cgi-bin/ /home/mythos/public_html/cgi-bin/
DocumentRoot /home/nikos/public_html
ScriptAlias /cgi-bin/ /home/nikos/public_html/cgi-bin/
DocumentRoot /home/panos/public_html
ScriptAlias /cgi-bin/ /home/panos/public_html/cgi-bin/
DocumentRoot /home/pdimou/public_html
ScriptAlias /cgi-bin/ /home/pdimou/public_html/cgi-bin/
DocumentRoot /home/radio/public_html
ScriptAlias /cgi-bin/ /home/radio/public_html/cgi-bin/
DocumentRoot /home/tasos/public_html
ScriptAlias /cgi-bin/ /home/tasos/public_html/cgi-bin/
DocumentRoot /home/ypsiland/public_html
ScriptAlias /cgi-bin/ /home/ypsiland/public_html/cgi-bin/
DocumentRoot /home/mythos/public_html/oliveoils
ScriptAlias /cgi-bin/ /home/mythos/public_html/oliveoils/cgi-bin/
DocumentRoot /home/pdimou/public_html/zimotirio
ScriptAlias /cgi-bin/ /home/pdimou/public_html/zimotirio/cgi-bin/
root@nikos [~]#
=======================

Why every other python cgi script of mines doesnt prodice this error
and only 'koukos.py' does?
 
N

nagia.retsina

Trying

yum install dos2unix

and

root@nikos [/home/nikos/www/cgi-bin]# dos2unix koukos.py
dos2unix: converting file koukos.py to UNIX format ...


Then browsed to the page again in Chrome it worked as expected :)
 
Í

Íéêüëáïò Êïýñáò

Ôç ÊõñéáêÞ, 9 Éïõíßïõ 2013 8:27:53 ð.ì.UTC+3, ï ÷ñÞóôçò (e-mail address removed) Ýãñáøå:
Trying



yum install dos2unix



and



root@nikos [/home/nikos/www/cgi-bin]# dos2unix koukos.py

dos2unix: converting file koukos.py to UNIX format ...





Then browsed to the page again in Chrome it worked as expected :)

So how from python koukos.py script was interpreting correctly and from browser it failed?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top