レス
元トピタイトル
Re: 問題ID: 14708
フォーラム
最強WEB問題集LinuC/LPIC Lv2 202
投稿ユーザ(投稿日)
(2015/6/20)本文
-----引用(始)-----
正しくはDenyUsersおよびDenyGroups、AllowUsersおよびAllowGroupsの順番で処理されるのではないでしょうか。
-----引用(終)-----
あー…
これハマるんですよねぇ。
まず、sshd_configのmanページからですが
-----引用(始)-----
AllowGroups
This keyword can be followed by a list of group name patterns, separated by spaces. If speci‐
fied, login is allowed only for users whose primary group or supplementary group list matches
one of the patterns. Only group names are valid; a numerical group ID is not recognized. By
default, login is allowed for all groups.
The allow/deny directives are processed in the fol‐
lowing order: DenyUsers, AllowUsers, DenyGroups, and finally AllowGroups.
-----引用(終)-----
あくまで「processed in the following order(以下の順に処理されます)」なんですよね。
で、ackey1112さんと似たような認識で「ドキュメントバグだ!」ってopenssh-unix-devメーリングリストにPATCH投げた人がいるんですが
[PATCH] document evaluation of {Allow|Deny}{Users|Groups}
https://lists.mindrot.org/pipermail/openssh-unix-dev/2015-February/033465.html
-----引用(始)-----
From: Christoph Anton Mitterer
• Document what the evaluation order of AllowUsers, DenyUsers, AllowGroups and
DenyGroups actually means.
Fixes bug #2292.
(略)
-----引用(終)-----
ばっさり切り捨てられてるんですね
https://lists.mindrot.org/pipermail/openssh-unix-dev/2015-February/033485.html
-----引用(始)-----
> +The first one that matches determines whether the login is allowed or
> +denied, with the later processed directives being ignored.
This is actually not true. You can specify {Allow|Deny}{Users|Groups}
multiple times and all of the rows are applied.
超意訳)
全然合ってないし。どこに書いても何回書いても有効だから。
-----引用(終)-----
じゃーmanは正しいのか?ってことでopenssh-6.8p1のソース見てみたら、auth.cの88行目からのint allowed_user(struct passwd * pw)でここの判定がされてるみたいです。false(数字の0)が返却されたら許可されてないユーザーだとみなすという。
実際の判定は189行目からで、
・DenyUsersに書いてあるユーザーとマッチしたらfalse
・AllowUsersになんか書いてあるけどそこに書いてあるユーザーにマッチしなかったらfalse
213行目からはグループ判定で、DenyGroupsかAllowGroupsのどっちかが設定されてる時に
・DenyGroups, AllowGroupsどっちのグループにも所属してなかったらfalse(不明なのは拒否)
・DenyGroupsに書いてあるグループに所属してたらfalse
・AllowGroupsになんか書いてあるけど、ユーザーのどの所属グループもそこに書いてあるグループにマッチしなかったらfalse
で、そこを全部パスして252行目に来ると
-----引用(始)-----
/* We found no reason not to let this user try to log on... */
(超意訳)
ログオンしにきたやつを拒否する理由がねぇよ…
return 1; ←True返却=このユーザーはログインできる
-----引用(終)-----
ってことで、ちゃんとmanにある通り
DenyUsers -> AllowUsers -> DenyGroups -> AllowGroups
の順に処理されてるんですね。で、Denyする理由がなかったら許可されると。
「Denyに書いてあったらその意図の通りDenyするよ!」ってことは間違いないです。でも解説にある順番も、公式manページ通り間違ってないです。
ややこしー (^^;
レス一覧
- Re: 問題ID: 14708(2015/6/22)
元トピ
Copyright (c) 2010
Ping-t All rights reserved.