openwebmail setuid root出錯,perl怎樣才能支持SUIDPERL

轉帖於:

http://cache.baidu.com/cm=9d78d513d98206f40eafc33e53029026475bda257a95c7140cc98e18cd390e564711a5e6783510738298237a5ff41a00bfa0682f621e73f7dd93d9148aa6912e298830340746c01e4c&p=986dc64ad1dd11a058ea8a60575c&user=baidu

 

 

openwebmail setuid root出錯,perl怎樣才能支持SUIDPERL[轉]

 
 

訪問: http://localhost/cgi-bin/openwebmail/openwebmail.pl
系統提示:
Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.
Please contact the server administrator, root@localhost and inform them of the time the error occurred, and anything you might have done that may have caused the error.
More information about this error may be available in the server error log.

分析一:
看日誌tail -f /var/log/httpd/error_log錯誤提示如下:
[Tue Jul 12 15:56:56 2005] [error] [client 127.0.0.1] Premature end of script headers: openwebmail.pl
[Tue Jul 12 15:56:56 2005] [error] [client 127.0.0.1] (2)!!!!!!!!!!!!!!!!!!: exec of '/var/www/cgi-bin/openwebmail/openwebmail.pl' failed
好象是執行/var/www/cgi-bin/openwebmail/openwebmail.pl失敗,所以手工執行此文件:
[root@localhost www]# /var/www/cgi-bin/openwebmail/openwebmail.pl
bash: /var/www/cgi-bin/openwebmail/openwebmail.pl: /usr/bin/suidperl: bad interpreter: 沒有那個文件或目錄
現在問題明朗了,是/var/www/cgi-bin/openwebmail/openwebmail.pl調用/usr/bin/suidperl這個文件失敗,因爲系統根本沒有/usr/bin/suidperl這個文件。解決的辦法很簡單修改/var/www/cgi-bin/openwebmail/所有openwebmail*.pl文件中“#!/usr/bin/suidperl -T”爲“#!/usr/bin/perl”(後來發現openwebmail帶的文檔中提到suidperl的問題,可以重新編譯perl來實現suidperl我沒有實驗,只是根據文檔裏面猜測的)
訪問: http://localhost/cgi-bin/openwebmail/openwebmail.pl
系統提示與以前相同,日誌提示改變:
[Tue Jul 12 16:28:06 2005] [error] [client 127.0.0.1] Premature end of script headers: openwebmail.pl
[Tue Jul 12 16:28:06 2005] [error] [client 127.0.0.1] Can't do setuid

分析二:
重新認真讀openwebmail帶的文檔發現如下如下解決方法:
perl /var/www/cgi-bin/openwebmail/misc/tools/wrapsuid/wrapsuid.pl /var/www/cgi-bin/openwebmail/
訪問: http://localhost/cgi-bin/openwebmail/openwebmail.pl
系統提示:
Software error:
Can't locate Text/Iconv.pm in @INC (@INC contains: /usr/lib/perl5/5.8.0/i386-linux-thread-multi /usr/lib/perl5/5.8.0 /usr/lib/perl5/site_perl/5.8.0/i386-linux-thread-multi /usr/lib/perl5/site_perl/5.8.0 /usr/lib/perl5/site_perl /usr/lib/perl5/vendor_perl/5.8.0/i386-linux-thread-multi /usr/lib/perl5/vendor_perl/5.8.0 /usr/lib/perl5/vendor_perl /usr/lib/perl5/5.8.0/i386-linux-thread-multi /usr/lib/perl5/5.8.0 . /var/www/cgi-bin/openwebmail) at shares/iconv.pl line 7.
BEGIN failed--compilation aborted at shares/iconv.pl line 7.
For help, please send mail to the webmaster (root@localhost), giving this error message and the time and date of the error.

分析三:
閱讀文檔得到如下答案:
iconv是用來支持多國的字集轉換功能,但可能在編輯時有錯
cp /var/www/cgi-bin/openwebmail/misc/patches/iconv.pl.fake /var/www/cgi-bin/openwebmail/shares/iconv.pl
訪問: http://localhost/cgi-bin/openwebmail/openwebmail.pl
系統提示:
Please execute '/var/www/cgi-bin/openwebmail/openwebmail-tool.pl --init' on server first!

分析四:
提示什麼就做什麼,在命令行下執行
/var/www/cgi-bin/openwebmail/openwebmail-tool.pl --init
提示如下
[root@localhost openwebmail]# /var/www/cgi-bin/openwebmail/openwebmail-tool.pl --init
Please change '/var/www/cgi-bin/openwebmail/etc/dbm.conf' from
dbm_ext                 .db
dbmopen_ext             none
dbmopen_haslock         no
to
dbm_ext                 .db
dbmopen_ext             .db
dbmopen_haslock         no
And execute '/var/www/cgi-bin/openwebmail/openwebmail-tool.pl --init' again!
ps: If you are running openwebmail in persistent mode,
    don't forget to 'touch openwebmail*.pl', so speedycgi
    will reload all scripts, modules and conf files in --init

分析五:
去修改/var/www/cgi-bin/openwebmail/etc/dbm.conf這個文件發現沒有這個文件。沒有就新建,內容爲:
dbm_ext                 .db
dbmopen_ext             .db
dbmopen_haslock         no
然後再執行一次/var/www/cgi-bin/openwebmail/openwebmail-tool.pl --init
訪問: http://localhost/cgi-bin/openwebmail/openwebmail.pl
系統提示:
'/var/www/cgi-bin/openwebmail/.openwebmail.pl' must setuid to root

分析六:
原來剛纔執行perl /var/www/cgi-bin/openwebmail/misc/tools/wrapsuid/wrapsuid.pl /var/www/cgi-bin/openwebmail/後,所有openwebmail*.pl文件的s位沒有了。所以
chmod 4755 /var/www/cgi-bin/openwebmail/openwebmail*.pl
訪問: http://localhost/cgi-bin/openwebmail/openwebmail.pl
OK,可以看到登陸框了,說明openwebmail已經安裝成功了,下面就是來結合sendmail了。

 

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章