Pocketstudio.jp :: Logbook :: Linux :: Fedora Core 3のメモ
 Contributed at:   2004/11/18 (Thu) 00:42

■ /linux/FedoraCore3/ 一般ユーザのウェブ公開方法


 一般ユーザを http://URL/~アカウント名/ として表示するためには /home/アカウント名 自身のパーミッションに o+x (その他ユーザへの実行権限が必要。
 初期状態は 700(rwx———) なので chmod o+x /home/アカウント名、もしくは chmod 701 /home/アカウント名 のコマンド実行が必要となる。

 httpd.conf 側での設定変更箇所は /home/*/public_html に関しての部分。354 行目付近。

<Directory /home/*/public_html>
    AllowOverride FileInfo AuthConfig Limit
    Options MultiViews Indexes SymLinksIfOwnerMatch IncludesNoExec <b style="color:white">ExecCGI</b>
    <Limit GET POST OPTIONS>
        Order allow,deny
        Allow from all
    </Limit>
    <LimitExcept GET POST OPTIONS>
        Order deny,allow
        Deny from all
    </LimitExcept>
</Directory>
 もう1カ所、ハマりかけたのは初期状態で一般ユーザのディレクトリは無効にされている事。339 行目『 UserDir disable 』をコメント(先頭に # ) して、346 行目『 UserDir public_html 』をコメントアウト  コメントアウト+CGI 実行のために『 ExecCGI 』の追加。その後、apache の再起動。

 

 ……で OK のはずが、ここでも FedoraCore 3 初期状態でアクティブにしてしまった影響が……。/var/log/messages を読むと、

Nov 15 18:50:29 sion kernel: audit(1100512229.876:0): avc:  denied  { getattr } 
for  pid=8129 exe=/usr/sbin/httpd path=/home/zem/public_html dev=dm-0 ino=6864912
scontext=root:system_r:httpd_t tcontext=root:object_r:user_home_t tclass=dir
 『 { getattr } 』はアクセス・ベクター=アクセス制御可能な操作の種類の事。write とか read とかがある。
 『 exe=/usr/sbin/httpd 』は実行しようとしているプロセス(apache 本体ですね)
 『 scontext=root:system_r:httpd_t 』は「httpd_t」という名前のプロセスのドメイン。
 『 tcontext=root:object_r:user_home_t 』は「user_home_t」というリソースの種類。
 『 tclass=file 』はオブジェクト・クラス。要はアクセス対象が file (ファイル) ですという意味。
 /etc/selinux/targeted/contexts/files/file_contexts に関連項目がありました。
# apache
/home/[^/]+/((www)|(web)|(public_html))(/.+)? system_u:object_r:httpd_user_content_t
 現在の状態を ls で見ると  
# ls --context /home/zem/public_html/
-rw-rw-r--  zem      zem      user_u:object_r:user_home_t      index.html
 このようになっていました(/home/zem/public_html/ が公開用のディレクトリです)。  先ほどの file_contexts を次のように書き換えました。
# apache
/home/[^/]+/((www)|(web)|(public_html))(/.+)? system_u:object_r:httpd_sys_script_rw_t
 設定ファイル側はこれで完了。あとは設定を restorecon コマンドで反映させます。
# /sbin/restorecon -R /home/zem/public_html/
 これで完了です。ls で見ても public_html 以下の情報が書き換わっている事が分かります。
# ls --context /home/zem/
drwxr-xr-x  zem      zem      user_u:object_r:user_home_t      Desktop
drwxr-xr-x  zem      zem      system_u:object_r:httpd_sys_script_rw_t public_html
 これで HTML ファイルの表示は OK です。
 でも CGI の実行・ファイルの書き出しには障害が出てきました。SuEXEC を有効にしている為のようです。
 ……うーん、いろいろ考えましたがここから先はアウト。。SELinux は無効にして運用指定校と思います。う〜む。
Nov 15 20:12:01 sion kernel: audit(1100517121.306:0): avc:  denied  { append } for
  pid=8395 exe=/usr/sbin/suexec name=suexec.log dev=dm-0 ino=12944681 scontext=root:
  system_r:httpd_suexec_t tcontext=root:object_r:httpd_runtime_t tclass=file
 どうやら /var/log/httpd/suexec.log の書込が出来ない模様。

 ちなみに「/sbin/restorecon /usr/sbin/suexec」と実行すると、file_contexts 変更後の設定が反映されます。うーん。。うまくいかない。

[2004/11/17追記]FedoraCore3付属のapache(SELinux)でSuEXECを有効にする方法

[分類 /linux/FedoraCore3 ] 固定リンク

 
 書込記録 - Calendar -
11月(November)
Sun Mon Tue Wed Thu Fri Sat
 
18
       
2004
11月
 お品書き[ BLOG ] - Weblog -
 過去ログ書庫 - Archives -

  "ポケットスタジオ" Copyright ©1997-2004 Pocketstudio.jp. Some rights reserved.