포럼: users (Thread #33436)

imap/ruby-1.9.3.362-24.fc18.i686 (2013-01-25 11:09 by kazufurutaka #67131)

こんにちわ。

昨年夏頃(bsfilterの作者様にプライベート・メイルにて)bsfilter+ruby-1.9について相談させて頂いた者です。
今度は、職場でimapでアクセスして--insert-probabilityするためにcronで叩いていたものが動かなくなっていることに気づき、相談させて頂きたく…

環境は、Fedora 18 linux (i686)、その rpm packageである ruby-1.9.3.362-24.fc18.i686 と、bsfilter 1.0.18.ruby1.9.rc3/rev.1.86.2.6 の組み合わせです。

この環境で、imap-auth auto, imap-port 143 という .bsfilter/bsfilter.conf という設定の下(サーバ、ユーザー名、パスワードは省略)、
$ bsfilter --imap --imap-fetch-unflagged --insert-flag --insert-probability inbox
すると、
/usr/share/ruby/net/imap.rb:1143:in `get_tagged_response': Expected search_key (Net::IMAP::BadResponseError)
from /usr/share/ruby/net/imap.rb:1195:in `block in send_command'
from /usr/share/ruby/monitor.rb:211:in `mon_synchronize'
from /usr/share/ruby/net/imap.rb:1177:in `send_command'
from /usr/share/ruby/net/imap.rb:1330:in `block in search_internal'
from /usr/share/ruby/monitor.rb:211:in `mon_synchronize'
from /usr/share/ruby/net/imap.rb:1326:in `search_internal'
from /usr/share/ruby/net/imap.rb:757:in `uid_search'
from /home/furutaka/bin/bsfilter:2461:in `imap_get_target_uids'
from /home/furutaka/bin/bsfilter:2750:in `block in do_imap'
from /home/furutaka/bin/bsfilter:2749:in `each'
from /home/furutaka/bin/bsfilter:2749:in `do_imap'
from /home/furutaka/bin/bsfilter:3397:in `run'
from /home/furutaka/bin/bsfilter:3449:in `<main>'
といって、シクジリます。

シクジリだしたのは(済みません、気がつかなかったもので、その後fedora/ruby package及び(改善するかと思ってbsfilterを)を更新してしまっていますが)、今年の1/7で、その際は、ruby-1.9.3.327-19.fc17.i686 及び bsfilter-1.86.2.4 を使っていたと思います(特に、rubyのパッケージが更新されたというタイミングと一致している事は無いようです)。

なお、同じサーバにimapでアクセスして新着メイルを通知させている mail-notification ソフトが、最近ではメイルを読後も読んだことにならない、などという現象もありますので、imap serverの方がおかしい可能性もあり大いにあります。(telnet で port 143を叩くと、"* OK SERVER.IP deepimap4d 3.7.0 Service is ready"と応答します。)

どなたかご示唆を頂けますとさいわいです。

Reply to #67131×

You can not use Wiki syntax
You are not logged in. To discriminate your posts from the rest, you need to pick a nickname. (The uniqueness of nickname is not reserved. It is possible that someone else could use the exactly same nickname. If you want assurance of your identity, you are recommended to login before posting.) Login

RE: imap/ruby-1.9.3.362-24.fc18.i686 (2013-07-17 18:57 by kazufurutaka #69526)

bsfilter 1.86.2.10, Fedora-19, ruby 2.0.0p247 (2013-06-27 revision 41674) [x86_64-linux]でも発生しています。お知恵頂けますとさいわいです。
Reply to #67131

Reply to #69526×

You can not use Wiki syntax
You are not logged in. To discriminate your posts from the rest, you need to pick a nickname. (The uniqueness of nickname is not reserved. It is possible that someone else could use the exactly same nickname. If you want assurance of your identity, you are recommended to login before posting.) Login

RE: imap/ruby-1.9.3.362-24.fc18.i686 (2013-07-21 01:39 by nabeken #69554)

以下の環境で、問題が再現できていません。
クライアント: Mac OS X 10.8, ruby 1.9.3p448/2.0.0p247, bsfilter 1.86.2.10
IMAPサーバ: FreeBSD 9.1, courier-imap 4.13,2

IMAPサーバ依存の問題だと難しいですね...

Reply to #69526

Reply to #69554×

You can not use Wiki syntax
You are not logged in. To discriminate your posts from the rest, you need to pick a nickname. (The uniqueness of nickname is not reserved. It is possible that someone else could use the exactly same nickname. If you want assurance of your identity, you are recommended to login before posting.) Login

RE: imap/ruby-1.9.3.362-24.fc18.i686 (2013-08-01 08:18 by kazufurutaka #69696)

こんにちわ。

放置するわけにもいかず、ちょっとずつIMAP & rubyの勉強をしながら原因を追求しております。

bsfilter-1.86.2.10 の
def setup_imap
の直後に
Net::IMAP.debug=(true)
を仕込んで見てみた結果が以下です。なにがいけなくて、それはどこでどうなっている為
なのか、まだ全然見てみてはいませんが、取り急ぎお知らせまで。
# サーバ名、ユーザ名・パスワードは書き換えて消してあります。

$ bsfilter --imap --imap-fetch-unflagged --insert-flag --insert-probability inbox
S: * OK SERVERNAME deepimap4d 3.7.0 Service is ready
C: RUBY0001 CAPABILITY
S: * CAPABILITY IMAP4rev1 IDLE NAMESPACE QUOTA CHILDREN STARTTLS
S: RUBY0001 OK CAPABILITY completed.
C: RUBY0002 LOGIN USERNAME PASSWORD
S: RUBY0002 OK LOGIN completed.
C: RUBY0003 SELECT inbox
S: * 7 EXISTS
S: * 0 RECENT
S: * OK [UIDVALIDITY 1357510085] UID validity status
S: * OK [UIDNEXT 12709] Predicted next UID
S: * FLAGS (\Answered \Flagged \Deleted \Recent \Seen \Draft)
S: * OK [PERMANENTFLAGS (\Answered \Flagged \Deleted \Seen \Draft)] Limited
S: RUBY0003 OK [READ-WRITE] SELECT completed
C: RUBY0004 UID SEARCH ALL
S: * SEARCH 12211 12212 12372 12444 12657 12706 12708
S: RUBY0004 OK UID SEARCH completed
C: RUBY0005 UID SEARCH HEADER X-Spam-Flag ""
S: RUBY0005 BAD Expected search_key
/usr/share/ruby/net/imap.rb:1158:in `get_tagged_response': Expected search_key (Net::IMAP::BadResponseError)
from /usr/share/ruby/net/imap.rb:1210:in `block in send_command'
from /usr/share/ruby/monitor.rb:211:in `mon_synchronize'
from /usr/share/ruby/net/imap.rb:1192:in `send_command'
from /usr/share/ruby/net/imap.rb:1345:in `block in search_internal'
from /usr/share/ruby/monitor.rb:211:in `mon_synchronize'
from /usr/share/ruby/net/imap.rb:1341:in `search_internal'
from /usr/share/ruby/net/imap.rb:773:in `uid_search'
from /home/USERNAME/bin/bsfilter:2506:in `imap_get_target_uids'
from /home/USERNAME/bin/bsfilter:2795:in `block in do_imap'
from /home/USERNAME/bin/bsfilter:2794:in `each'
from /home/USERNAME/bin/bsfilter:2794:in `do_imap'
from /home/USERNAME/bin/bsfilter:3443:in `run'
from /home/USERNAME/bin/bsfilter:3495:in `<main>'

現在のクライアント側の環境は、

Fedora release 19 (Schrödinger’s Cat)
$ uname -p =>
i686
$ ruby --version =>
ruby 2.0.0p247 (2013-06-27 revision 41674) [i386-linux]

です。

状況報告まで…
Reply to #69554

Reply to #69696×

You can not use Wiki syntax
You are not logged in. To discriminate your posts from the rest, you need to pick a nickname. (The uniqueness of nickname is not reserved. It is possible that someone else could use the exactly same nickname. If you want assurance of your identity, you are recommended to login before posting.) Login

RE: imap/ruby-1.9.3.362-24.fc18.i686 (2013-08-01 21:25 by kazufurutaka #69709)

続報です(とは言っても、大した情報ではございませぬ)が…

現象が起きている
null = imap.uid_search(["HEADER", x_spam_flag.sub(/:$/, ''), ""])
と、それ(null)を使っている部分を(それほど重要な役割は担っていないようなので)コメントアウトすることで、(searchで必要なstringが無い、という)最初のエラーは回避できるようです。
# rfc 的には、HEADER の場合、長さゼロの文字列を検索しようとした場合は、
# そのヘッダを持つ全てのuidを返す、と書かれているので、サーバがエラーを
# 返すのは誤りだと思います。
# 一方、ここでのnullの使途は、どこにあるのでしょうか?

しかしながら、処理する最初のメッセージで、imap.rb で、次なる障害にぶち当たってしまっているようです。
(最後だけ抜粋しますと、
/usr/share/ruby/net/imap.rb:3363:in `parse_error': unexpected token LITERAL (expected SPACE) (Net::IMAP::ResponseParseError)
from /usr/share/ruby/net/imap.rb:3215:in `match'
from /usr/share/ruby/net/imap.rb:2316:in `rfc822_text'
from /usr/share/ruby/net/imap.rb:2236:in `msg_att'
from /usr/share/ruby/net/imap.rb:2210:in `numeric_response'
from /usr/share/ruby/net/imap.rb:2152:in `response_untagged'
from /usr/share/ruby/net/imap.rb:2132:in `response'
from /usr/share/ruby/net/imap.rb:2058:in `parse'
from /usr/share/ruby/net/imap.rb:1181:in `get_response'
from /usr/share/ruby/net/imap.rb:1089:in `receive_responses'
from /usr/share/ruby/net/imap.rb:1075:in `block in initialize'
と言われました。)
Reply to #69554

Reply to #69709×

You can not use Wiki syntax
You are not logged in. To discriminate your posts from the rest, you need to pick a nickname. (The uniqueness of nickname is not reserved. It is possible that someone else could use the exactly same nickname. If you want assurance of your identity, you are recommended to login before posting.) Login

RE: imap/ruby-1.9.3.362-24.fc18.i686 (2013-11-03 19:39 by nabeken #70672)

null = の行を削除して、1.0.19をリリースしました。
`parse_error': unexpected token LITERAL (expected SPACE)
については変更していません。
エラーが再現しましたら、メッセージ全体を見せて下さい。
Reply to #69709

Reply to #70672×

You can not use Wiki syntax
You are not logged in. To discriminate your posts from the rest, you need to pick a nickname. (The uniqueness of nickname is not reserved. It is possible that someone else could use the exactly same nickname. If you want assurance of your identity, you are recommended to login before posting.) Login