Net::OpenID::Consumer

OpenID のテストで、perl の Net::OpenID::Consumer モジュールを使ってみた。

とりあえずほぼサンプルそのままで試すと、Google、Yahoo、はてなmixi いずれも OK。

でも、

$claimed_identity->set_extension_args(
    'http://openid.net/extensions/sreg/1.1',
    {
        required    => 'nickname,email',
    },
);
$claimed_identity->set_extension_args(
    'http://openid.net/srv/ax/1.0',
    {
        mode => 'fetch_request',
        'type.nickname' => 'http://axschema.org/namePerson/friendly',
        'type.email'    => 'http://axschema.org/contact/email',
        required        => 'nickname,email',
    },
);

のようにして sreg.nickname を取得しようとすると mixi だけなぜか signature_mismatch になった。email だけだと問題ないんだがなぁ……(mixi ではもともと email は取れないけど)。

色々調べて見たところ、UTF-8文字列が返ってくると失敗しているようだと判明。そういえば、CGI モジュールを使う場合、UTF-8を受ける時におまじないが必用だったなぁ。

ということで、

my $cgi = CGI->new;
for my $p ($cgi->param) {
    my @v = map { decode_utf8($_) } $cgi->param($p);
    $cgi->param($p, @v);
}

のようにデコードしてから Net::OpenID::Consumer->new の args に渡したところ、うまく動くようになったのでした。

Nethackその後

店売りの靴をあさってみたら、+3の水上歩行靴発見。これで先に進める〜。

ということで、メデューサを倒して城までおりた。その途中で灰色ドラゴンの鱗も入手したんで、早速鎧に加工して着替え完了。

さて、城から行くか、クエストに進むか、フォートローディオスを片付けるか。どうしようかなぁ。

WordPress のデータベース中の文字列の一括変換

WordPress サイトのドメインを変更したり別ドメインにコピー・引っ越しする場合、データベースの中に記録されているホスト名やURLの書き換えが非常に面倒。

特に wp_options テープルなどはPHPシリアライズされたデータが書き込まれているので、SQLコマンドでUPDATEしたり、ダンプしたSQLをエディタで書き換えてから書き戻したりすると、文字列データの長さが変わってデータが壊れて、ウィジェットの中身とかがなくなってしまう。

んでもって、いろいろ探して見つけたのが WordPress (and others) Search and Replace Tool

利用方法は簡単。ダウンロードして解凍して、WordPress ディレクトリのトップにPHPファイルを一つコピーして、web ブラウザでアクセス。あとは画面を見て作業して、作業が終わったらこのファイルを削除するだけ。

いやぁ、便利便利 \(^^)/

Security Incident on FreeBSD Infrastructure

最近 portsnap fetch update で更新が入ってこないので何かあったのかなと思っていたら、不正侵入があったらしい。


On Sunday 11th November 2012, two machines within the FreeBSD.org infrastructure were found to have been compromised. These machines were head nodes for the legacy third-party package building infrastructure. It is believed that the compromise may have occurred as early as the 19th September 2012.

The compromise is believed to have occurred due to the leak of an SSH key from a developer who legitimately had access to the machines in question, and was not due to any vulnerability or code exploit within FreeBSD.

To understand the impact of this compromise, you must first understand that the FreeBSD operating system is divided into two parts: the "base" maintained by the FreeBSD community, and a large collection of third-party "packages" distributed by the Project. The kernel, system libraries, compiler, core command-line tools (e.g., SSH client), and daemons (e.g., sshd(8)) are all in the "base". Most information in this advisory refers only to third-party packages distributed by the Project.

No part of the base FreeBSD system has been put at risk. At no point has the intruder modified any part of the FreeBSD base system software in any way. However, the attacker had access sufficient to potentially allow the compromise of third-party packages. No evidence of this has been found during in-depth analysis, however the FreeBSD Project is taking an extremely conservative view on this and is working on the assumption that third-party packages generated and distributed within a specific window could theoretically have been modified.

詳細を読んでみると、改竄されていないことが確認できないのは、ports のバイナリパッケージと、svn.freebsd.org やそのミラー以外から取得した ports(cvsup や csup で取得してたらこれですね)とのこと。

base システムや portsnap で取得した ports は大丈夫だったようなので、まずは一安心。

追記

日本語版の詳細ページも出来てました。http://www.freebsd.org/ja/news/2012-compromise.html