YANO's digital garage

Copyright ©YANO All rights reserved. https://www.bravotouring.com/~yano/

Last-modified: 2024-04-17 (水)


[一語一絵/IT系]

メール送信フォーム復旧 / 2005-03-24 (木)

地震の影響では無く、年明けに新サーバーを導入したところでの移行漏れだ。情けな〜。

バックアップからwwwmail.cgiを導入。しかし入れただけはうまくいかないのがSELinuxの定めだ。permissiveモードに切替えて動作を確認し、"audit2allow -d -l"の出力をセキュリティポリシーに追加しなければならない。

/etc/selinux/targeted/src/policy/domains/program/apache.teの差分は以下のとおりとなった。

allow httpd_suexec_t user_home_dir_t:dir search;
allow httpd_suexec_t user_home_t:dir { add_name remove_name getattr search write };
allow httpd_suexec_t user_home_t:file { execute execute_no_trans getattr ioctl read rename append create unlink write };
allow httpd_suexec_t tmpfs_t:dir search;
allow httpd_sys_script_t tmpfs_t:dir search;

allow httpd_sys_script_t devpts_t:chr_file { read write };
allow httpd_sys_script_t httpd_sys_script_exec_t:dir { read add_name remove_name write };
allow httpd_sys_script_t httpd_sys_script_exec_t:file { create unlink write };
allow httpd_sys_script_t httpd_sys_script_exec_t:lnk_file read;
allow httpd_sys_script_t var_t:dir { add_name remove_name write };
allow httpd_sys_script_t var_t:fifo_file write;
allow httpd_sys_script_t var_t:file { create execute execute_no_trans getattr link read unlink write };
allow httpd_t httpd_sys_script_exec_t:lnk_file read;
allow httpd_t user_home_t:dir { getattr search };
allow httpd_t user_home_t:file { getattr read };

取り敢えず動くようなったところで、文字化けの対応。まずはスクリプトソースをUTF-8へコンバート。

nkf -Ew wwwmail.cgi
nkf -Ew mimew.pl

続いてviエディタで

require 'jcode.pl';
use Jcode;
$charset = &Jcode::getcode(\'漢字');
に、
&jcode'convert(*mail, "euc");
&Jcode::convert(\$mail, $charset);
と変更すべし。