« 05.31 理解されない苦しみが襲うんだ | ココ | 06.04 指令! 雑談せよ »

2010年6月 2日

気がつけばSELinux  このエントリーを含むはてなブックマーク 

SSHでLDAPに登録しているユーザーでログインしたら最初にホームディレクトリ(/var/www/svn)に移動が出来なかったぞ(Permission error)と警告を出されてて、でもなんでか分からなくて放置してたんやけど(というかホームディレクトリを/homeにしてた)…ふと気がついてしまった。

これってひょっとしていつものアレでは。

Jun 2 23:06:05 vestita setroubleshoot: SELinux is preventing sshd (sshd_t) "search" to ./www (httpd_sys_content_t). For complete SELinux messages. run sealert -l 1c89560a-5c19-41d5-9580-4e56499d6dbc
Jun 2 23:49:33 vestita setroubleshoot: SELinux is preventing sshd (sshd_t) "search" to ./svn (httpd_sys_content_rw_t). For complete SELinux messages. run sealert -l 20fbe682-ea6b-448d-92a3-c397b16dca08

やっぱりSELinuxやったわ…。

# sealert -l 1c89560a-5c19-41d5-9580-4e56499d6dbc

要約:

SELinux is preventing sshd (sshd_t) "search" to ./www (httpd_sys_content_t).

詳細説明:

SELinux denied access requested by sshd. It is not expected that this access is required by sshd and this access may signal an intrusion attempt. It is also possible that the specific version or configuration of the application is causing it to require additional access.

アクセスを許可:

Sometimes labeling problems can cause SELinux denials. You could try to restore the default system file context for ./www,

restorecon -v './www'

If this does not work, there is currently no automatic way to allow this access. Instead, you can generate a local policy module to allow this access - see FAQ (http://fedora.redhat.com/docs/selinux-faq-fc5/#id2961385) Or you can disable SELinux protection altogether. Disabling SELinux protection is not recommended.
Please file a bug report (http://bugzilla.redhat.com/bugzilla/enter_bug.cgi) against this package.

追加情報:

ソースコンテキスト system_u:system_r:sshd_t:s0-s0:c0.c1023
ターゲットコンテキ system_u:object_r:httpd_sys_content_t:s0
ターゲットオブジェ ./www [ dir ]
ソース sshd
ソースパス /usr/sbin/sshd
ポート <不明>
ホスト vestita.calanthe
ソース RPM パッケージ openssh-server-5.1p1-3.fc10
ターゲット RPM パッケ
ポリシー RPM selinux-policy-3.5.13-74.fc10
Selinux 有効化 True
ポリシータイプ targeted
MLS 有効化 True
強制モード Enforcing
プラグイン名 catchall_file
ホスト名 vestita.calanthe
プラットフォーム Linux vestita.calanthe
2.6.27.41-170.2.117.fc10.i686 #1 SMP Thu Dec 10
11:00:29 EST 2009 i686 i686
通知カウント 9
最初の画面 Fri Sep 18 23:50:09 2009
最後の画面 Wed Jun 2 23:06:03 2010
ローカル ID 1c89560a-5c19-41d5-9580-4e56499d6dbc
行番号

生の監査メッセージ

node=vestita.calanthe type=AVC msg=audit(1275487563.952:403864): avc: denied { search } for pid=21738 comm="sshd" name="www" dev=dm-0 ino=804253 scontext=system_u:system_r:sshd_t:s0-s0:c0.c1023 tcontext=system_u:object_r:httpd_sys_content_t:s0 tclass=dir

node=vestita.calanthe type=SYSCALL msg=audit(1275487563.952:403864): arch=40000003 syscall=12 success=no exit=-13 a0=1a804e0 a1=1a66b78 a2=f05ee4 a3=1a6eb10 items=0 ppid=21737 pid=21738 auid=1001 uid=1001 gid=1001 euid=1001 suid=1001 fsuid=1001 egid=1001 sgid=1001 fsgid=1001 tty=pts0 ses=58161 comm="sshd" exe="/usr/sbin/sshd" subj=system_u:system_r:sshd_t:s0-s0:c0.c1023 key=(null)

詳細を出してみたところ、restoreconでコンテキストラベルを書き換えればええんちゃう? ということやけど…それはやってもあかんと思うよワトソン君。だってログインしたユーザーはそもそもhttpdちゃうし。というわけでもう1つの荒業audit2allowでポリシーを作ろう編の開始です。

HowTos/SELinux (ref. CentOS Wiki)

7. Creating Custom SELinux Policy Modules with audit2allow をそのままやった。SELinuxも随分ドキュメント類が充実してきたっぽい。

# grep sshd_t /var/log/audit/audit.log | audit2allow -M svnsshlocal
# semodule -i svnsshlocal.pp

素晴らしい、これだけでもういいなんて。

By ただ at 23:58 カテゴリー ; プログラミングとか

« 05.31 理解されない苦しみが襲うんだ | 06月の記事 | 06.04 指令! 雑談せよ »




トラックバック

このエントリーのトラックバックURL:
http://pinmarch.sakura.ne.jp/mt/mt-tb.cgi/1596