2007/11/28

squirrelmail-1.4.8-4.0.1.el4.centos4で件名が文字化け2

「http://www.squirrelmail.jp/node.php?id=269」を参照

変更ファイル名
/usr/share/squirrelmail/functions/i18n.php

以下の部分を変更
----------------------------------------------------------------
332行目付近に追加

if ($squirrelmail_language == 'ja_JP') {
header ('Content-Type: text/html; charset=EUC-JP');
if (!function_exists('mb_internal_encoding')) {
echo _("You need to have PHP installed with the multibyte string function
enabled (using configure option --enable-mbstring).");
// Revert to English link has to be added.
// stop further execution in order not to get php errors on mb_internal_en
coding().
return;
}
if (function_exists('mb_language')) {
mb_language('Japanese');
}
mb_detect_order('ASCII,JIS,EUC-JP,UTF-8,SJIS');
mb_internal_encoding('EUC-JP');
mb_http_output('pass');
} elseif ($squirrelmail_language == 'en_US') {
header( 'Content-Type: text/html; charset=' . $default_charset );
} else {

----------------------------------------------------------------
483行目付近を変更

修正前
function japanese_charset_xtra() {
$ret = func_get_arg(1); /* default return value */
if (function_exists('mb_detect_encoding')) {
switch (func_get_arg(0)) { /* action */
case 'decode':
$detect_encoding = @mb_detect_encoding($ret);
if ($detect_encoding == 'JIS' ||
$detect_encoding == 'EUC-JP' ||
$detect_encoding == 'SJIS' ||
$detect_encoding == 'UTF-8') {

$ret = mb_convert_kana(mb_convert_encoding($ret, 'AUTO'), "KV");
}
break;
case 'encode':
$detect_encoding = @mb_detect_encoding($ret);
if ($detect_encoding == 'JIS' ||
$detect_encoding == 'EUC-JP' ||
$detect_encoding == 'SJIS' ||
$detect_encoding == 'UTF-8') {

$ret = mb_convert_encoding(mb_convert_kana($ret, "KV"), 'JIS', 'AUTO');
}
break;
case 'strimwidth':


修正後
function japanese_charset_xtra() {
$ret = func_get_arg(1); /* default return value */
if (function_exists('mb_detect_encoding')) {
switch (func_get_arg(0)) { /* action */
case 'decode':
$detect_encoding = @mb_detect_encoding($ret);
if ($detect_encoding == 'JIS' ||
$detect_encoding == 'EUC-JP' ||
$detect_encoding == 'SJIS' ||
$detect_encoding == 'UTF-8') {

$ret = mb_convert_kana(mb_convert_encoding($ret, 'ASCII,JIS,EUC-JP,UTF-8,SJIS'), "KV");
}
break;
case 'encode':
$detect_encoding = @mb_detect_encoding($ret);
if ($detect_encoding == 'JIS' ||
$detect_encoding == 'EUC-JP' ||
$detect_encoding == 'SJIS' ||
$detect_encoding == 'UTF-8') {

$ret = mb_convert_encoding(mb_convert_kana($ret, "KV"), 'JIS', 'ASCII,JIS,EUC-JP,UTF-8,SJIS');
}
break;
case 'strimwidth':

----------------------------------------------------------------
530行目付近を変更

修正前
case 'decodeheader':
$ret = str_replace("\t", "", $ret);
if (eregi('=\\?([^?]+)\\?(q|b)\\?([^?]+)\\?=', $ret))
$ret = @mb_decode_mimeheader($ret);
$ret = @mb_convert_encoding($ret, 'EUC-JP', 'AUTO');
break;
case 'downloadfilename':
$useragent = func_get_arg(2);
if (strstr($useragent, 'Windows') !== false ||
strstr($useragent, 'Mac_') !== false) {
$ret = mb_convert_encoding($ret, 'UTF-8', 'AUTO');
} else {
$ret = mb_convert_encoding($ret, 'EUC-JP', 'AUTO');
}
break;

修正後
case 'decodeheader':
$ret = str_replace("\t", "", $ret);
if (eregi('=\\?([^?]+)\\?(q|b)\\?([^?]+)\\?=', $ret))
$ret = @mb_decode_mimeheader($ret);
$ret = @mb_convert_encoding($ret, 'EUC-JP','ASCII,JIS,EUC-JP,UTF-8,SJIS');
break;
case 'downloadfilename':
$useragent = func_get_arg(2);
if (strstr($useragent, 'Windows') !== false ||
strstr($useragent, 'Mac_') !== false) {
$ret = mb_convert_encoding($ret, 'UTF-8', 'ASCII,JIS,EUC-JP,UTF-8,SJIS');
} else {
$ret = mb_convert_encoding($ret, 'EUC-JP', 'ASCII,JIS,EUC-JP,UTF-8,SJIS');
}
break;

2007/05/21

CentOSでXEN仮想サーバの作成

之だけで後はウイザード形式でインストール可能だ
# virt-install -n piglet -r 256 -f /xen/piglet -s 16 --nographics -l ftp:
//ftp.riken.go.jp/Linux/centos/5.0/os/i386

参考URL
http://shain.tomocreative.net/2007/04/xen_centos5virtinstall_1.html

2007/05/01

VMWare 仮想マシンの時刻ずれ問題

AMD x2、Pentium4環境で仮想端末のClockが異常に早くなる現象に遭遇
(CentOS4.4)

5秒ほど画面を眺めると1分2分と進んでいく
解決方法はカーネルのブートオプションを変更
「clock=pit nosmp noapic nolapic」を追加する事で解決
 http://webos-goodies.jp/archives/50179807.html

default=0
timeout=5
splashimage=(hd0,0)/grub/splash.xpm.gz
hiddenmenu
title CentOS (2.6.9-42.0.8.EL)
root (hd0,0)
kernel /vmlinuz-2.6.9-42.0.8.EL ro root=LABEL=/ clock=pit nosmp noapic nolapic rhgb quiet
initrd /initrd-2.6.9-42.0.8.EL.img

2007/01/31

squirrelmail-1.4.8-2.el4.centos4でログインIDにデフォルトのドメイン名

バーチャルドメインを運用すると、ユーザーアカウント名にドメイン名を付加する事が有ります。
しかし、大部分の人は固定のドメイン名が付加されている場合デフォルトのドメイン名が有ればユーザビリティが良く成ります。

以下の部分を変更

----------------------------------------------------------------
変更ファイル名:
/usr/share/squirrelmail/src/redirect.php

以下の行(208行目付近)を追加(太字部分)

if (!sqsession_is_registered('user_is_logged_in')) {
do_hook ('login_before');

$onetimepad = OneTimePadCreate(strlen($secretkey));
$key = OneTimePadEncrypt($secretkey, $onetimepad);
sqsession_register($onetimepad, 'onetimepad');

/* remove redundant spaces */
$login_username = trim($login_username);

/* @が無い場合はデフォルトのドメイン名を追加 @example.com */
$domainpos = strrpos($login_username,"@");
if ($domainpos === false) {
$login_username .= "@example.com";
}

/* Verify that username and password are correct. */
if ($force_username_lowercase) {
$login_username = strtolower($login_username);
}

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

2007/01/30

squirrelmail-1.4.8-2.el4.centos4で添付ファイル名が文字化け

件名と同じ直し方で文字化けしなくなったので暫く使う
 →解決しなかった
  結局、1.4.9aの日本語パッチを手動で当てた事で解決
  http://www.yamaai-tech.com/~masato/Download/

以下の部分を変更

----------------------------------------------------------------
変更ファイル名:
/usr/share/squirrelmail/functions/i18n.php

以下の行(540行目)の内容を変更
変更前:
case 'downloadfilename':
$useragent = func_get_arg(2);
if (strstr($useragent, 'Windows') !== false ||
strstr($useragent, 'Mac_') !== false) {
$ret = mb_convert_encoding($ret, 'SJIS', 'AUTO');
} else {
$ret = mb_convert_encoding($ret, 'EUC-JP', 'AUTO');
}
break;

変更後:
case 'downloadfilename':
$useragent = func_get_arg(2);
if (strstr($useragent, 'Windows') !== false ||
strstr($useragent, 'Mac_') !== false) {
$ret = mb_convert_encoding($ret, 'UTF-8', 'AUTO');
} else {
$ret = mb_convert_encoding($ret, 'EUC-JP', 'AUTO');
}
break;
----------------------------------------------------------------

----------------------------------------------------------------
変更ファイル名:
/usr/share/squirrelmail/functions/mime.php

以下の行(2160行目)の内容を変更
変更前:
if (preg_match('/compatible; MSIE ([0-9]+)/', $HTTP_USER_AGENT, $match) &&
((int)$match[1]) >= 6 && strstr($HTTP_USER_AGENT, 'Opera') === false) {
$isIE6plus = true;
}

変更後:
if (preg_match('/compatible; MSIE\s?([0-9]+)/', $HTTP_USER_AGENT, $match) &&
((int)$match[1]) >= 6 && strstr($HTTP_USER_AGENT, 'Opera') === false) {
$isIE6plus = true;
}
----------------------------------------------------------------

2007/01/25

squirrelmail-1.4.8-2.el4.centos4で件名が文字化け


「http://www.squirrelmail.jp/node.php?id=290」より引用

以下の部分を変更
----------------------------------------------------------------
変更ファイル名:
/usr/share/squirrelmail/class/deliver/Deliver.class.php

563行目~569行目あたりのswitch構文の中に、
case 'Subject':
を追加
}
}
$hdr_s .= $sLine;
break;
case 'Subject':
case 'To':
case 'Cc':
case 'Bcc':
case 'From':
$hdr_s .= $header[$i];
break;
default: $hdr_s .= $this->foldLine($header[$i], 78, str_pad('',4)); break;
}

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

2007/01/24

オンラインでLVMボリュームを拡張した


[root@paradise ~]# df
Filesystem 1K-ブロック 使用 使用可 使用% マウント位置
/dev/hda5 13827976 2910672 10214864 23% /
/dev/hda1 101086 11504 84363 12% /boot
none 199044 0 199044 0% /dev/shm
/dev/mapper/gp00-vol00
20642428 77944 19515908 1% /home
/dev/hda3 505636 11767 467764 3% /var/log
[root@paradise ~]# fdisk -l

Disk /dev/hda: 16.1 GB, 16106127360 bytes
255 heads, 63 sectors/track, 1958 cylinders
Units = シリンダ数 of 16065 * 512 = 8225280 bytes

デバイス Boot Start End Blocks Id System
/dev/hda1 * 1 13 104391 83 Linux
/dev/hda2 14 144 1052257+ 82 Linux スワップ
/dev/hda3 145 209 522112+ 83 Linux
/dev/hda4 210 1958 14048842+ 5 拡張領域
/dev/hda5 210 1958 14048811 83 Linux

Disk /dev/hdb: 32.2 GB, 32212254720 bytes
255 heads, 63 sectors/track, 3916 cylinders
Units = シリンダ数 of 16065 * 512 = 8225280 bytes

デバイス Boot Start End Blocks Id System
/dev/hdb1 * 1 3916 31455238+ 8e Linux LVM

Disk /dev/hdd: 32.2 GB, 32212254720 bytes
15 heads, 63 sectors/track, 66576 cylinders
Units = シリンダ数 of 945 * 512 = 483840 bytes

デバイス Boot Start End Blocks Id System
/dev/hdd1 1 66576 31457128+ 8e Linux LVM
[root@paradise ~]# /usr/sbin/vgextend gp00 /dev/hdd1
Physical volume '/dev/hdd1' is already in volume group 'gp00'
Unable to add physical volume '/dev/hdd1' to volume group 'gp00'.
[root@paradise ~]# lvextend -L+1024MB gp00/vol00
Extending logical volume vol00 to 31.00 GB
Logical volume vol00 successfully resized
[root@paradise ~]# lvextend -L+1024MB gp00/vol00
Extending logical volume vol00 to 32.00 GB
Logical volume vol00 successfully resized
[root@paradise ~]# lvextend -L+1024MB gp00/vol00
Extending logical volume vol00 to 33.00 GB
Logical volume vol00 successfully resized
[root@paradise ~]# lvextend -L+17GB gp00/vol00
Extending logical volume vol00 to 50.00 GB
Logical volume vol00 successfully resized
[root@paradise ~]# lvextend -L+5GB gp00/vol00
Extending logical volume vol00 to 55.00 GB
Logical volume vol00 successfully resized
[root@paradise ~]#
    ・
    ・
    ・
[root@paradise ~]#
[root@paradise ~]#
ext2online /dev/mapper/gp00-vol00
ext2online v1.1.18 - 2001/03/18 for EXT2FS 0.5b
[root@paradise ~]# df
Filesystem 1K-ブロック 使用 使用可 使用% マウント位置
/dev/hda5 13827976 2910744 10214792 23% /
/dev/hda1 101086 11504 84363 12% /boot
none 199044 0 199044 0% /dev/shm
/dev/mapper/gp00-vol00
56766780 86032 53797612 1% /home
/dev/hda3 505636 11907 467624 3% /var/log
[root@paradise ~]#

2007/01/13

Fedora DS 起動スクリプト

起動スクリプトをファイル名fdsとして、次の内容で作成しました。



#!/bin/sh
#
# fds Start/Stop Fedora Directory Server
#
# chkconfig: 345 20 20
# description: Fedora Directory Server
# processname: ns-slapd

# Source Directory name
if [ -f /etc/sysconfig/fds ]; then
. /etc/sysconfig/fds
else
echo $"Directory name is not defined in /etc/sysconfig/fds"
exit 1
fi

SLAPD_PATH=/opt/fedora-ds/

case "$1" in
start)
$SLAPD_PATH/slapd-$DIRECTORYNAME/start-slapd
$SLAPD_PATH/start-admin
;;
stop)
$SLAPD_PATH/stop-admin
$SLAPD_PATH/slapd-$DIRECTORYNAME/stop-slapd
;;
restart)
$SLAPD_PATH/restart-admin
$SLAPD_PATH/slapd-$DIRECTORYNAME/restart-slapd
;;
*)
echo $"Usage: $0 {start|stop|restart}"
exit 1
esac

exit $?



ディレクトリサービスの起動スクリプト start-slapdは、作成したディレクトリ名に依存するため、/etc/sysconfig/fdsで設定するようにしてあります。
/etc/sysconfig/fdsに

DIRECTORYNAME=servername

のようにディレクトリの識別子を指定してファイルを作成してください。

またfdsファイルを作成したら、次の手順で、システムに登録を行います。


# cp fds /etc/rc.d/init.d/fds
# chmod 755 /etc/rc.d/init.d/fds
# /sbin/chkconfig fds --add
# /sbin/chkconfig fds on

これで起動時にFDSのディレクトリサーバと管理サーバを自動起動、自動停止することが可能になります。

また、手動でFDSの起動、停止をしたいときは、それぞれ次々のコマンドで可能になります。


# /sbin/service fds start
# /sbin/service fds stop
# /sbin/service fds restart

注意: FC5ではLDAPを利用する設定にした場合、messagebusサービスより先に、FDSが起動していないと、システムが起動しなくなります。