LoginSignup
1
1

More than 5 years have passed since last update.

SELinux起動時のユーザディレクトリ公開

Last updated at Posted at 2016-12-16

SELinux有効時にラベルを再設定する方法として、以下の方法を見つけました。

# restorecon /home/ユーザディレクトリ/public_html
# restorecon -R /home/ユーザディレクトリ/public_html

ラベルを
system_u:object_r:httpd_user_content_t
に設定できるとありました。

restoreconコマンドは「ファイル、ディレクトリにデフォルトコンテキストを反映する」と説明があって、
そもそも自分で作ったpublic_htmlの“デフォルト”ってなに?と思いました。

# chcon unconfined_u:object_r:httpd_user_content_t /home/ユーザディレクトリ/public_html -R

とセキュリティコンテキストを設定するのであれば分かりますけど・・・

とかなり長いことモヤモヤしていましたが、
「標準のセキュリティコンテキスト定義ファイル」なるモノがあるらしい。

/etc/selinux/targeted/contexts/files/file_contexts.homedirs

の中に下記の行を見つけてやっとすっきりしました。

/home/[^/]*/((www)|(web)|(public_html))(/.+)? unconfined_u:object_r:httpd_user_content_t:s0

 

restorecon コマンドに -v や -F オプションがついている例があって、ここでも
気になってしまったがman restoreconでわかりました。

   -v     show changes in file labels.
   -F     Force  reset

でした。

いままで、なにげなく、/home/ユーザディレクトリ/public_html
を作っていたけど、public_htmlじゃなくてdocumentなんてしちゃったら
動かないよ!

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1