Rudy Ruckerの同名の著書とは直接関係ありませんが、私の思考の道具箱であることは確かです。大抵のページは書きかけで、内容も不完全ですのでご注意を。

SELinuxでキオスクパソコンの構築
Creating a Kiosk Account using SELinux and Fedora 8.

元記事は
http://danwalsh.livejournal.com/13376.html

ここ数ヶ月、自分専用のAVCをいじって遊んでいた。権限が制限されたユーザ、つまりRole(役割)ベースのアクセス制御について試してみていた。
Over the last few months, in between playing my own personal version of Wack A Mole (AVC). I have been working on Roles Based Access Control (RBAC) or confining users.
以前、私のブログでも説明したとおり、端末とXウィンドウを使うだけの最小の権限を持つポリシーをつくってみた。
As I have explained in previous blogs, I have defined a policy to be used for the least privledged login terminal and X Windows users.

その目標とするところは「キオスク端末」のアカウントを定義することだった。つまり、図書館や銀行、空港やカフェで使えるインターネット端末をいかに安全に使えるようにするかである。SELinuxでこれを実現するにはどうしたらいいか調べてみた。
One of the goals of this was to define a Kiosk User account. the idea was to secure these machines that you can walk up to at the library, bank, airport, coffee shop and just login and use the internet. So I investigated how to do this with SELinux.

できあがったアカウント設定をFedoraのデスクトップ開発チームのJonathan Blandfordに見せてみたところ、Fast User Switchingのメニューで使えるアカウントとして登録できたらいいんじゃないか、と言ってくれた。
I demonstrated this account to Jonathan Blandford from the Fedora Desktop Team saw it and suggested it would be cool to use one of these accounts with Fast User Switching.
このアカウントで問題なのはパスワード無しで使えるようにしないといけないことだ。
One problem with this, we need to be able to use this account without a password.
セキュリティを考えれば、このアカウントはSELinuxが有効で、なおかつenforcingのモードでないと使えない。
From a security stand point. we can only protect the account if SELinux is enabled and in enforcing mode.
そのため、新しいPAMのモジュールが必要になったので、Tomas Mrazに頼んでpam_selinux_permitというモジュールを作ってもらった。
We needed a new pam module for this. I asked Tomas Mraz to look into this and he created pam_selinux_permit

pam_selinux_permitのマニュアルはこんな具合だ
man pam_selinux_permit

PAM_SELINUX_PERMIT(8) Linux-PAM Manual PAM_SELINUX_PERMIT(8)

名称
NAME

pam_selinux_permit - SELinuxのenforcementの状態によって、ログインの可否を決定するPAMのモジュール
pam_selinux_permit - PAM module to allow/deny login depending on SELinux enforcement state

書式
SYNOPSIS
pam_selinux_permit.so [debug] [conf=/path/to/config/file]

説明
DESCRIPTION

pam_selinuxモジュールは、SELinuxのenforcementの状態によって、ログインの可否を決定する。
The pam_selinux module allows or denies login depending on SELinux enforcement state.

ログインしようとするユーザが設定ファイルの中のエントリと一致した場合、そのユーザはSELinuxがenforcingモードのときにのみログインが許可される。
When the user which is logging in matches an entry in the config file he is allowed access only when the SELinux is in enforcing mode.
そうでなければログインできない。
エントリと一致しないユーザの場合は、pam_selinx_permitモジュールはPAM_IGNOREの値を返す。(おそらくは別のPAMモジュールの設定によって認証が行われる)
Otherwise he is denied access. For users not matching any entry in the config file the pam_selinux_permit module returns PAM_IGNORE return value.

設定ファイルは1行に1つ、ユーザ名が書いてあるだけの単純なファイルである。
ユーザ名が@で始まっている場合は、グループ名と解釈される。
ユーザ名が%の文字で始まっている場合には、OSのユーザ名ではなく、ログインのアカウント名と解釈される。
註:もし、SELinuxがdisabledの状態だった場合には、アカウント名の割り当ては決定できない。したがって、SELinuxがdisabledであれば、%で始まるエントリーにマッチする場合は無いので、pam_selinux_permitのモジュールは常にPAM_IGNOREを返すことになる。(以下略)
The config file contains a simple list of user names one per line. If the name is prefixed with @ character it means that all users in the group name match. If it is prefixed with a % character the SELinux user is used to match against the name instead of the account name. Note that when SELinux is disabled the SELinux user assigned to the account cannot be determined. This means that such entries are never matched when SELinux is disabled and pam_selinux_permit will return PAM_IGNORE.
...


というわけで、パスワードが無効になったxguestというアカウントを作ることができる。pam_selinx_permitを利用して、このアカウントでxdmが使えるようにしてみよう。
Now we can create an xguest account with disabled password. Then we can setup xdm to use pam_selinux_permit.

# useradd -Z xguest_u xguest


# cat /etc/pam.d/gdm
#%PAM-1.0
auth [success=done ignore=ignore default=bad] pam_selinux_permit.so
auth required pam_env.so
auth include system-auth
auth optional pam_gnome_keyring.so auto_start
account required pam_nologin.so
account include system-auth
...
session required pam_selinux.so open
session required pam_namespace.so
session optional pam_gnome_keyring.so

/etcv/security/sepermit.conf にxguestユーザを追加する
Add the xguest user to the /etcv/security/sepermit.conf

# cat /etc/security/sepermit.conf
# /etc/security/sepermit.conf
#
# Each line contains either:
# - an user name
# - a group name, with @group syntax
# - a SELinux user name, with %seuser syntax
xguest

SELinuxがenforcingモードならば、xdmのログインメニューのxguestのアカウントをクリックするだけで(パスワード無しで)ログインできるはずだ。
If SELinux is in enforcing mode, you can log into this account just by clicking on the xguest user.
もし、xdm以外の方法でこのアカウントでログインしようとすると、ログインに失敗するだろう。sshd, rshd, telnetdのいずれもダメなはずだ。
If you try to reach this accound by any means other then xdm you will not be able to login. sshd, rshd, telnetd will all fail.

マシンをpermissiveモードにしたり、SELinuxを無効にしたら、このアカウントではログインできなくなる。ただし、すでにログインしている場合には、影響は無い。
If you put the machine into permissive mode or disable selinux, you will no longer be able to login as this user. This will not effect a currently logged in user however.

このアカウントはFast User Switchingでも有効だ。ツールバーにUser Switcherのアプレットをインストールして、xguestを選択すればいい。パスワードを入力することもなく、自動的にxguestとしてログインしてしまう。
You can also use Fast User Switching to switch to this user. Just add the User Switcher applet to your tool bar and select xguest. You should switch to this account and be automagically logged in.

このアカウントのセキュリティをより強化したい場合には、xguestユーザによって作られたすべてのファイル、ディレクトリを消去してしまうのも良いだろう。
To add additional security to this account, it would be useful to have all files/directories removed that were created by the xguest user.
そうすれば、xguestを使った新人さんがマシンの環境を荒らす心配はなくなる。そのために、pam_namespaceを使って、xguestが使用したXウィンドウのセッションが終了するたびに、ホームディレクトリと/tmp、/var/tmp を毎回生成し直してやればいい。 すでに示したように /etc/init.d/gdm に pam_namespace.soの項目が追加してあれば問題ない。
So if a new person uses the xguest, he can guarantee a clean environment. So we can setup pam_namespace to generate a new Homedir, /tmp and /var/tmp. Every time the X Windows session ends. You need pam_namespace.so added to /etc/init.d/gdm for this, as shown above.

そして、/etc/security/namespace.conf に以下の行を追加する
Also add these lines to /etc/secuirty/namespace.conf

/tmp tmpfs tmpfs ~xguest
/var/tmp tmpfs tmpfs ~xguest
$HOME tmpfs tmpfs ~xguest

この設定は、xguestがログオンするたびに/tmp, /var/tmp と$HOMEに一時的なファイルシステムを生成して割り当てるという意味だ。
This says to generate three temporary filesystems mounted on /tmp, /var/tmp and $HOME directory for only xguest any time he logs in.

これらの設定をすべてやってくれるRPMパッケージを作った。以下のURLから利用できる。
I have generated an rpm package and spec file that will set this all up for you. You can try this out at

http://people.fedoraproject.org/~dwalsh/xguest/


このキオスクアカウントの設定について3つのbooleanスイッチがある。
There are three booleans that you can set for this account.

getsebool -a | grep xguest
* browser_confine_xguest

これは、xguestのアカウントでxguest_mozilla_tのドメインに遷移できるかどうかを示す。このスイッチをONにすれば、xguestはfirefox/mozillaを使ってwebページを閲覧できる。これがオフだとブラウザが使えない。現実的に、この状態ではこのユーザはインターネットにアクセスできないことになる。
This indicates whether the xguest account will transition to xguest_mozilla_t or not. If you turn this boolean on, xguest will be able to browse the web using firefox/mozilla. If you turn it off the account will only be allowed to run mozilla/firefox locally. You will not have any access to the net.
* browser_write_xguest_data

このスイッチは、firefoxのブラウザが、アカウントのホームディレクトリに自由に書き込みできるかどうかを設定する。
This will determine whether firefox can write to the home directory or not.

このスイッチがオフの場合、firefoxが書き込めるのは、.mozillaと.gnomeディレクトリ以下に限定される。
If this boolean is turned off firefox will only be allowed to write to .mozilla and .gnome in the home directory.
もし、ダウンロード用のディレクトリを追加したい場合には、そのディレクトリのラベルを xguest_mozilla_home_t とすればいい。
If you wanted to add a download directory you could add a file context and label it xguest_mozilla_home_t

# semanage fcontext -a -t xguest_mozilla_home_t /home/xguest/Download(/.*)?
# restorecon -R -v ~/xguest
* allow_xguest_exec_content

このスイッチは、ホームディレクトリまたは/tmpにあるファイルを実行できるかどうかを決める。悪意あるプログラムをダウンロードして攻撃するようなユーザからシステムを守ることができる。
This boolean determines whether the xguest account can execute files in its home directory or /tmp. This can prevent some forms of attack on users.

私が作成したxguest.spec と xguest-1.0.0-1.fc8.noarch.rpmのファイルは、以下のURLに置いてある。
I have created xguest.spec and xguest-1.0.0-1.fc8.noarch.rpm


out on

http://people.fedoraproject.org/~dwalsh/xguest/

このパッケージで、xguestに関するすべてが設定できる。ぜひ使ってみて感想を聞かせて欲しい。
Which will set everything up for you. Try it out and tell me what you think.
タグ

Wiki内検索

メニューバーA

ここは自由に編集できるエリアです。

フリーエリア

編集にはIDが必要です