[cgi] error - 엣메세지 메일서버 Premature end of script head

coca73의 이미지

잘 사용하던 웹메일 서비스(엣메세지)에서 아래와 같은 에러메세지가 갑자기 발생하고 있습니다.

Quote:

[Wed Dec 1 07:35:13 2004] [error] [client xxx.xxx.xxx.xxx] Premature end of script headers: /home/Atmessage-5.05R9/cgi-auth/composer.cgi

간간히 발생한 적은 있지만 현재는 지속적으로 발생이 되고 있습니다.
c로 컴파일 된 cgi라서 정확히 원인이 뭔지 모르고 있습니다.
반면 다른 cgi들은 정상적으로 동작하고 있습니다.
리부팅을 해봐도 마찬가지로 에러가 발생합니다.

수년동안 정상적으로 동작하던 cgi가 어떤 변화를 통해 이런 오류가 발생할 수 있을까요?
시스템의 환경변화는 없었습니다.
에러에서 보시는데로 composer.cgi는 메일쓰기에 해당하는 cgi로 메일을 작성하여 발송하고 나면 정상적으로 발송되었다는 메세지와 함께 메일박스가 리스트되어야 하는데 Internal Error를 내고 있습니다.
하지만 메일은 정상적으로 발생하고 있으며 composer.cgi가 정상적으로 처리를 하고나서 리턴페이지를 제대로 불러들이지 못하는 것응로 추측됩니다.

그렇지만 이를 유발할만한 변화는 없었다고 생각하는데 갑자기 문제가 발생하니 원인이 어디에 있는지 난감합니다.

이와 유사한 경험이 있으시거나 추측 가능한 이유를 아시면 알려주시면 감사하겠습니다.

atie의 이미지

아파치 FAQ 인용 합니다.
http://httpd.apache.org/docs/misc/FAQ-F.html#premature-script-headers

Quote:
This is generally only necessary when you are calling external programs from your script that send output to stdout, or if there will be a long delay between the time the headers are sent and the actual content starts being emitted. To maximize performance, you should turn buffer-flushing back off (with $| = 0 or the equivalent) after the statements that send the headers, as displayed above.

If your script isn't written in Perl, do the equivalent thing for whatever language you are using (e.g., for C, call fflush() after writing the headers).


500 에러가 난다면, 이 부분이 가장 의심스럽습니다.

----
I paint objects as I think them, not as I see them.
atie's minipage

ironiris의 이미지

혹시 스팸메일러들이 장난치는 것은 아닌지요?

coca73의 이미지

우선 atie님 ironiris님 답변 감사합니다.
먼저 cgi는 컴파일된 바이너리라서 제가 재작성이 불가능한 상태입니다. -_-;; perl이나 다른 것이라면 이미 위 내용을 찾아봤기에 적용해봤을 것입니다만;;;
잘 동작하던 cgi가 어느날 갑자기 위와 같은 에러를 발생한다면 원인은 무엇이 있을까요? 특정 작업을 한적이 없어서 시스템 환경변화가 없다는 가정하에 무엇때문인지 추측이 안되고 있습니다.

특이사항은 엣메세지 웹메일서비스는 아파치소스를 수정한 mhttpd라는 자체 웹서버를 사용합니다.

릴레이는 모두 막혀있고 로칼 사용자(웹메일)만 사용이 가능하며 테스트를 위해 cgi 접근을 막고 혼자만 테스트 해봐도 결과는 마찬가지였습니다.

atie의 이미지

웹 메일에서 무언가 상수값을 시스템 환경 변수로 읽어 처리하지는 않나요?

----
I paint objects as I think them, not as I see them.
atie's minipage

coca73의 이미지

그럴 것이라고 막연하게 추측은 합니다만 구체적으로 어떤 내용인지는 감이 안잡힙니다 -_-;;

atie의 이미지

혼자서 테스트할 때, stderr을 stdout으로 redirect할 수는 있나요?

----
I paint objects as I think them, not as I see them.
atie's minipage

coca73의 이미지

현재 구성된 cgi로는 불가능합니다.
cgi 자체가 login session이 존재하고 valid 할때만 동작하게 구성되어 있어서 터미날을 통한 stderr, stdout 을 볼 수가 없습니다.
다음과 같이 lynx를 통해 테스트 해봤는데 결과는 다음과 같습니다.
도메인정보는 익명처리하였습니다.

[test@root 09:46:33 /var/log]# lynx -mime_header http://test.com//cgi-auth/composer.cgi?cmd=form
HTTP/1.1 200 OK
Date: Wed, 01 Dec 2004 00:45:37 GMT
Server: Apache/1.3.9 (Unix)
Expires: 0
Connection: close
Content-Type: text/html

<SCRIPT LANGUAGE="JavaScript">
alert('사용자 아이디가 입력되지 않았습니다');
top.location='http://test.com:80/index.cgi?lang=kor&tnum=2';
</SCRIPT>
atie의 이미지

이렇게 해서 실마리를 찾아보면 어떨까요

strace -i lynx -auth=user:password -dump -mime_header http://test.com//cgi-auth/composer.cgi?cmd=form

----
I paint objects as I think them, not as I see them.
atie's minipage

coca73의 이미지

passwd가 plain text로 입력되서인지 역시 같은 결과 이내요.

Quote:

HTTP/1.1 200 OK
Date: Wed, 01 Dec 2004 04:52:28 GMT
Server: Apache/1.3.9 (Unix)
Expires: 0
Connection: close
Content-Type: text/html

<SCRIPT LANGUAGE="JavaScript">
alert('사용자 아이디가 입력되지 않았습니다');
top.location='http://test.com:80/index.cgi?lang=kor&tnum=2';
</SCRIPT>

atie의 이미지

그럼 -auth, -dump 옵션 빼고, http://test.com:80/index.cgi?lang=kor&tnum=2 부터 시작을 하고, 첫 화면에 user와 password을 묻는다고 보고 키 입력을 해주면 어떨런지.

----
I paint objects as I think them, not as I see them.
atie's minipage

coca73의 이미지

먼저 여러가지로 감사하다는 말씀 드립니다.

auth가 시작시 post로 진행되버려서 역시나 동작하질 않네요 ^^;;

여러모로 감사합니다.

누군가 ulimit를 언급하셔서 혹시 급속히 사용자가 늘어서 그런가하고 몇가지 테스트 해봤는데도 마찬가지네요 ㅜ.ㅜ;;

cjh의 이미지

apache errorlog에 오류 메시지가 남지 않나요?

세션이 필요한 경우라면 결국 로그인 과정부터 죽 따라가는 수 밖에는 없을 겁니다. 패킷 스니퍼나 proxy등을 사용해서 로그인부터 해당 스크립트에 도달할 때 까지 주고받는 파라미터나 쿠키등을 사용할 수 밖에요.

--
익스펙토 페트로눔

댓글 달기

Filtered HTML

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

BBCode

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param>
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

Textile

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • You can use Textile markup to format text.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Markdown

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • Quick Tips:
    • Two or more spaces at a line's end = Line break
    • Double returns = Paragraph
    • *Single asterisks* or _single underscores_ = Emphasis
    • **Double** or __double__ = Strong
    • This is [a link](http://the.link.example.com "The optional title text")
    For complete details on the Markdown syntax, see the Markdown documentation and Markdown Extra documentation for tables, footnotes, and more.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Plain text

  • HTML 태그를 사용할 수 없습니다.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 줄과 단락은 자동으로 분리됩니다.
댓글 첨부 파일
이 댓글에 이미지나 파일을 업로드 합니다.
파일 크기는 8 MB보다 작아야 합니다.
허용할 파일 형식: txt pdf doc xls gif jpg jpeg mp3 png rar zip.
CAPTCHA
이것은 자동으로 스팸을 올리는 것을 막기 위해서 제공됩니다.