古いProftpdでのLimitの設定
せっかく調べたのでメモ。
proftpd-1.2.10rc1 より前のバージョンでこんな感じのLimit設定を書いた場合、
Order Deny,Allow AllowUser hoge, fuga AllowGroup foo, bar Allow from x.x.x.x, y.y.y.y
AllowUser と AllowGroup 内のユーザ名/グループ名は AND で評価されてしまう。(Allow from は OR) 複数のグループに所属することがあっても複数のユーザに所属することはないので、AllowUser に関しては1行に1ユーザ書かないと有効にならない。
However, it does not make sense for AllowUser, because a user may not be multiple users at the same time. This is a known issue, and a proper, thorough solution is being developed. In the meantime, however, there is a workaround for allowing multiple users via the AllowUser directive. Rather than listing the users using a single AllowUser, using a separate AllowUser for each user.
http://www.proftpd.org/docs/howto/Limit.html
1.2.10rc1 以降では修正されていて、
- AllowUser と DenyUser はデフォルト OR
- AllowGroup と DenyGroup はデフォルト AND
- AllowGroup OR foo,bar と書くことで演算子を変えることも出来る。
Bug 2015 - Add AND, OR keywords to Allow/DenyUser directives. The AllowUser, DenyUser, AllowGroup, and DenyGroup directives now take an optional keyword that indicates what type of expression they are: AND, OR, or regex. By default, AllowUser and DenyUser are OR expressions, and AllowGroup and DenyGroup are AND expressions. For example: AllowUser regex ^ftp DenyUser AND dave,bob AllowGroup OR web,doc These demonstrate that the optional keyword modifier must be the first parameter in the configuration directive.
その他メモ
- Order Deny,Allow の意味はApacheと逆
に対して を書いても意味がない。(ログイン先はディレクトリではなくサーバなので) - ユーザ名、グループ名に対するUID,GIDは確認されない
- ディレクティブはどれか一つでもマッチした段階で処理される。上の例を疑似コード(Perl風)に直すとこんな感じ
if ( ($username eq 'hoge') && ($username eq 'hoge2') ) { <=1.2.10rc1以降は '||' allow(); } elsif ( ($group eq 'foo') && ($group eq 'foo2') ) { allow(); } elsif ( ($ip eq 'x.x.x.x') || ($ip eq 'y.y.y.y') ) { allow(); } else { deny(); }
- ユーザIDとIPアドレス両方で判定させるためには mod_ifsession を組み込んで
で書く