2012年10月6日土曜日

otrs3.1をCentOS6で導入テスト(インストール)

otrsが3.1になってる事に気が付いたので久々にotrsを触ってみる。
まあドキュメント読んだらだれでもできるくらいのわかりやすさなんだけど。
# yum -y install perl-DBD-MySQL mysql-server perl perl-libwww-perl perl-Net-DNS perl-IO-Socket-SSL perl-XML-Parser perl-TimeDate gd gd-devel vixie-cron procmail httpd-devel
確か、予期に計らってくれるとおもったけど一応/etc/my.cnfはutf8にしたりinnodbにしておいてみたり。
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
user=mysql
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
default-character-set=utf8
default-storage-engine=INNODB

[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid

[mysql]
default-character-set=utf8
mysqlの起動
# /etc/init.d/mysqld start
MySQL データベースを初期化中:  WARNING: The host 'otrs' could not be looked up with resolveip.
This probably means that your libc libraries are not 100 % compatible
with this binary MySQL version. The MySQL daemon, mysqld, should work
normally with the exception that host name resolving will not work.
This means that you should use IP addresses instead of hostnames
when specifying MySQL privileges !
Installing MySQL system tables...

(中略)

Please report any problems with the /usr/bin/mysqlbug script!

                                                           [  OK  ]
mysqld を起動中:                                           [  OK  ]
#
ここまでが準備。
ダウンロードしておいたotrsをインストール。
# yum install ./otrs-3.1.10-01.noarch.rpm 
(略)
Dependencies Resolved

====================================================================================
 Package              Arch      Version             Repository                 Size
====================================================================================
Installing:
 otrs                 noarch    3.1.10-01           /otrs-3.1.10-01.noarch     80 M
Installing for dependencies:
 mod_perl             x86_64    2.0.4-10.el6        base                      3.2 M
 perl-BSD-Resource    x86_64    1.29.03-3.el6       base                       35 k

Transaction Summary
====================================================================================
Install       3 Package(s)

Total size: 83 M
Total download size: 3.2 M
Installed size: 86 M
Is this ok [y/N]: y
Downloading Packages:
(1/2): mod_perl-2.0.4-10.el6.x86_64.rpm                      | 3.2 MB     00:10     
(2/2): perl-BSD-Resource-1.29.03-3.el6.x86_64.rpm            |  35 kB     00:00     
------------------------------------------------------------------------------------
Total                                               290 kB/s | 3.2 MB     00:11     
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
  Installing : perl-BSD-Resource-1.29.03-3.el6.x86_64                           1/3 
  Installing : mod_perl-2.0.4-10.el6.x86_64                                     2/3 
  Installing : otrs-3.1.10-01.noarch                                            3/3 
Check OTRS user ... otrs added.
hostname: 不明なホスト

Next steps: 

[httpd services]
 Restart httpd 'service httpd restart'

[install the OTRS database]
 Make sure your database server is running.
 Use a web browser and open this link:
 http:///otrs/installer.pl

[OTRS services]
 Start OTRS 'service otrs start' (service otrs {start|stop|status|restart).

((enjoy))

 Your OTRS Team

  Verifying  : perl-BSD-Resource-1.29.03-3.el6.x86_64                           1/3 
  Verifying  : mod_perl-2.0.4-10.el6.x86_64                                     2/3 
  Verifying  : otrs-3.1.10-01.noarch                                            3/3 

Installed:
  otrs.noarch 0:3.1.10-01                                                           

Dependency Installed:
  mod_perl.x86_64 0:2.0.4-10.el6      perl-BSD-Resource.x86_64 0:1.29.03-3.el6     

Complete!
# 
ブラウザ経由でインストーラを実行。。。なのだけどドキュメント通りにちゃんとselinuxを無効にしておかないと謎のエラーで500になっちゃう。
っていうか、なっちゃった。

2012年9月4日火曜日

mod_securityでWebのメソッド制限

アプリケーションサーバと連携をしているApacheだとメソッドの制限がWebとAPでそれぞれ別になるっていう事がある。
それぞれで設定するのは面倒だし、アプリケーションサーバが変わるたびに調査をしないといけないので、Apacheのみでやる事を検討してみた。
どうやら、mod_securityはそういった事もできるみたい。
CentOSだとepelに入っているので、yumでインストール。
WAFは仕事で使う場合、特に稼働中のサービスだったりすると影響が怖いのでせっかくのデフォルトのルールもいったん消す。

# cd /etc/httpd/modsecurity.d
# mv base_rules base_rules.bak
# mkdir base_rules

ルールを新しく作成。
# Accept only commonly used request methods
SecRule REQUEST_METHOD "!@rx ^(?:GET|HEAD|POST)$" \ "phase:1,t:none,deny,msg:'Only standard request methods allowed',logdata:%{REQUEST_METHOD}"
これでいつでもOPTIONSでもDELETEもしらないメソッドもマッチすると落としてくれるみたい。
$ telnet localhost 80
Trying ::1...
Connected to localhost.
Escape character is '^]'.
OPTIONS / HTTP/1.1
HOST: localhost

HTTP/1.1 403 Forbidden
Date: Mon, 03 Sep 2012 18:46:14 GMT
Server: Apache
Last-Modified: Mon, 03 Sep 2012 17:10:29 GMT
ETag: "40a61-1200-4c8cf37fd9f7e"
Accept-Ranges: bytes
Content-Length: 4608
Connection: close
Content-Type: text/html; charset=UTF-8

OPTIONSもへんな結果でない。
$ telnet localhost 80
Trying ::1...
Connected to localhost.
Escape character is '^]'.
aaaaaaaaaaaaa /example/ HTTP/1.1
HOST: localhost.localdomain

HTTP/1.1 403 Forbidden
Date: Mon, 03 Sep 2012 19:13:13 GMT
Server: Apache
Last-Modified: Mon, 03 Sep 2012 17:10:29 GMT
ETag: "40a61-1200-4c8cf37fd9f7e"
Accept-Ranges: bytes
Content-Length: 4608
Connection: close
Content-Type: text/html; charset=UTF-8

よし。
$ telnet localhost 80
Trying ::1...
Connected to localhost.
Escape character is '^]'.
DELETE /example/ HTTP/1.1
HOST: localhost

HTTP/1.1 403 Forbidden
Date: Mon, 03 Sep 2012 19:14:34 GMT
Server: Apache
Last-Modified: Mon, 03 Sep 2012 17:10:29 GMT
ETag: "40a61-1200-4c8cf37fd9f7e"
Accept-Ranges: bytes
Content-Length: 4608
Connection: close
Content-Type: text/html; charset=UTF-8

満足ぢゃ!

2012年8月25日土曜日

何年かぶりにMFCの復習をしてみる(Windowつくって中になんか書く)

Visual Studio2012が公開されて、Professional版も3ヶ月は無料で使える(評価目的だけど)そうなのでインストールしてみた。
せっかくのProfessional版だと、MFCが使えるのでひさびさにいじりはじめてみた。
所有しているのは古い書籍ばっかりだし、近年のMFCなんてさっぱり触ってないのでとっかかりもよくわからないや。
昔のざっくりした印象だと、ちょっと遊ぶにはOnDraw()に書いたらだいたいおっけーって印象なので、本を片手にやってみる。
void CEx03aView::OnDraw(CDC* pDC)
{
    pDC -> TextOutW(0, 0, CString("Hello World"));
}


こんなサンプルでも動くと楽しい。 昔のサンプルはcharだったけど、TextOut()がTextOutW()でCStringじゃないとエラーになるのは厳格になったってことかな。まあ、ざっくりでもなんとかなるのが、インテリセンスのありがたさ。
void CEx03aView::OnDraw(CDC* pDC)
{
    pDC -> TextOut(0, 0, "Hello World");
}
ひきつづき、
void CEx03aView::OnDraw(CDC* pDC)
{
 pDC -> TextOutW(0, 0, CString("Hello World"));
 pDC -> SelectStockObject(GRAY_BRUSH);
 pDC -> Ellipse(CRect(0, 20, 100, 120));
}

おお!いい感じ。こんな簡単な話なら大歓迎。 って、思ったけど座標系の話はやっぱ面倒だなあ。
すげー面倒って思い出してきた。

2012年7月25日水曜日

KINECT for Windows購入

衝動買いだけれど、7月25日にKINECT for Windowsをヨドバシカメラで買ってきた。
パッケージを開けてみたけど、ほんとにセンサー以外は付いてこないのね。。。

開封の儀

箱を開ける。
設置するとこんな感じ。(液晶ディスプレイの上はバランスが悪いからよくいないね)


えっと。。。どこでドライバをもらってくるんだっけ。。。って検索してみたらKINECTサイトがあるのね(あたりまえか)。

日本語のランゲージパックがあったりと思った以上の充実ぶり。

2012年7月21日土曜日

Visual Studio Professional 2012RCのダウンロード

Windows7に64bit Pythonをいれたばっかりにモジュールのインストールに難儀中。
コンパイラが標準でないからいろいろ選択肢があるみたいだけど、実はそうでもなかったりの不便さを実感。
今のところ買うほどでもないしなあ。ってことなので、Visual Studio Professional2012RC
を入れてみることに。
インストーラを起動したら、ライセンスに同意して。。。


オプションを選択して。。。



 インターネットからダウンロード。

 
あとは待つだけ。 さてさて。。。