From Fedora Project Wiki

(initial creation)
 
(→‎IRC Log: added irc log for the session)
 
Line 7: Line 7:
=== IRC Log ===
=== IRC Log ===


{|
|- id="t12:59"
! style="background-color: #407a40" |  dwalsh
| style="color: #407a40" | This is going to be the session on "What is SELinux trying to tell me?"
|| [[#t12:59|12:59]]
|- id="t12:59"
! style="background-color: #407a40" |  dwalsh
| style="color: #407a40" | My name is Dan Walsh.  I am in the Boston area.
|| [[#t12:59|12:59]]
|- id="t13:00"
! style="background-color: #407a40" |  dwalsh
| style="color: #407a40" | I put together some slides for this presentation
|| [[#t13:00|13:00]]
|- id="t13:00"
! style="background-color: #407a40" |  dwalsh
| style="color: #407a40" | http://people.fedoraproject.org/~dwalsh/SELinux/selinux4things.odp
|| [[#t13:00|13:00]]
|- id="t13:01"
! style="background-color: #407a40" |  dwalsh
| style="color: #407a40" | Where is everyone else?  It is 9 AM here.
|| [[#t13:01|13:01]]
|- id="t13:01"
| colspan="2" | * ianweller waves
|| [[#t13:01|13:01]]
|- id="t13:01"
! style="background-color: #42427e" |  dgrift_
| style="color: #42427e" | Rotterdam Netherlands 15:00
|| [[#t13:01|13:01]]
|- id="t13:01"
! style="background-color: #818144" |  maximus007
| style="color: #818144" | florida
|| [[#t13:01|13:01]]
|- id="t13:01"
! style="background-color: #854685" |  ianweller
| style="color: #854685" | kansas, 8am
|| [[#t13:01|13:01]]
|- id="t13:01"
! style="background-color: #488888" |  nihed
| style="color: #488888" | Tunisia
|| [[#t13:01|13:01]]
|- id="t13:01"
! style="background-color: #8c4a4a" |  pluvo
| style="color: #8c4a4a" | Germany, 15:00
|| [[#t13:01|13:01]]
|- id="t13:01"
! style="background-color: #488888" |  nihed
| style="color: #488888" | Tunisia, 14:00
|| [[#t13:01|13:01]]
|- id="t13:02"
! style="background-color: #4b904b" |  linuxguru
| style="color: #4b904b" | india  , 18:30
|| [[#t13:02|13:02]]
|- id="t13:02"
! style="background-color: #407a40" |  dwalsh
| style="color: #407a40" | Cool.
|| [[#t13:02|13:02]]
|- id="t13:03"
! style="background-color: #407a40" |  dwalsh
| style="color: #407a40" | I have been working on and off with the Fedora Infrastructure team on implementing SELinux and learned quite a bit.
|| [[#t13:03|13:03]]
|- id="t13:03"
! style="background-color: #407a40" |  dwalsh
| style="color: #407a40" | A few months ago I wrote a blog on it called
|| [[#t13:03|13:03]]
|- id="t13:03"
! style="background-color: #407a40" |  dwalsh
| style="color: #407a40" | Top three things to understand in fixing SELinux problems.
|| [[#t13:03|13:03]]
|- id="t13:03"
! style="background-color: #407a40" |  dwalsh
| style="color: #407a40" | http://danwalsh.livejournal.com/22347.html
|| [[#t13:03|13:03]]
|- id="t13:04"
! style="background-color: #407a40" |  dwalsh
| style="color: #407a40" | What I found is just about every machine we went on required a little bit of massaging
|| [[#t13:04|13:04]]
|- id="t13:04"
! style="background-color: #407a40" |  dwalsh
| style="color: #407a40" | So I came up with this list.
|| [[#t13:04|13:04]]
|- id="t13:05"
! style="background-color: #407a40" |  dwalsh
| style="color: #407a40" | I plan on writing a paper on Securing Fedora Infrastructure and explaining everything we did for Red Hat Magazine.  And presenting on it at Red Hat Summit in September.
|| [[#t13:05|13:05]]
|- id="t13:05"
! style="background-color: #407a40" |  dwalsh
| style="color: #407a40" | Anyways lets start.
|| [[#t13:05|13:05]]
|- id="t13:06"
! style="background-color: #407a40" |  dwalsh
| style="color: #407a40" | The #1 thing I try to explain to people about SELinux is LABELING.
|| [[#t13:06|13:06]]
|- id="t13:06"
! style="background-color: #407a40" |  dwalsh
| style="color: #407a40" | SELinux is all about labeling.  Every process has a label, every file has a label.
|| [[#t13:06|13:06]]
|- id="t13:06"
! style="background-color: #407a40" |  dwalsh
| style="color: #407a40" | If the labels are wrong, SELinux breaks down.
|| [[#t13:06|13:06]]
|- id="t13:06"
! style="background-color: #407a40" |  dwalsh
| style="color: #407a40" | So when a problem happens in SELinux the first thing to check is the labeling.
|| [[#t13:06|13:06]]
|- id="t13:07"
! style="background-color: #407a40" |  dwalsh
| style="color: #407a40" | One example of labeling getting screwed up is in the vmware package.
|| [[#t13:07|13:07]]
|- id="t13:07"
! style="background-color: #407a40" |  dwalsh
| style="color: #407a40" | In the RPM spec, they decided to edit the /etc/services file.
|| [[#t13:07|13:07]]
|- id="t13:08"
! style="background-color: #407a40" |  dwalsh
| style="color: #407a40" | They did this by copying it to /tmp and adding a port number and then moving it back to /etc
|| [[#t13:08|13:08]]
|- id="t13:08"
! style="background-color: #407a40" |  dwalsh
| style="color: #407a40" | Well in SELinux if you cp /etc/services to /tmp; the tmp file gets labeled rpm_script_tmp_t
|| [[#t13:08|13:08]]
|- id="t13:09"
! style="background-color: #407a40" |  dwalsh
| style="color: #407a40" | But the mv command maintains context, so mv moves the file back to /etc and the file is still labeled rpm_script_tmp_t.
|| [[#t13:09|13:09]]
|- id="t13:09"
! style="background-color: #407a40" |  dwalsh
| style="color: #407a40" | Now every confined domain that tries to read /etc/services is going to blow up because the label is wrong.
|| [[#t13:09|13:09]]
|- id="t13:09"
! style="background-color: #407a40" |  dwalsh
| style="color: #407a40" | Fixing the problem is as simple as restorecon /etc/services.
|| [[#t13:09|13:09]]
|- id="t13:10"
! style="background-color: #407a40" |  dwalsh
| style="color: #407a40" | But SELinux generates nasty avc's saying apache process tried to read rpm_script_tmp_t.
|| [[#t13:10|13:10]]
|- id="t13:10"
! style="background-color: #407a40" |  dwalsh
| style="color: #407a40" | BTW if anyone has questions, feel free to ask at any time.
|| [[#t13:10|13:10]]
|- id="t13:11"
! style="background-color: #407a40" |  dwalsh
| style="color: #407a40" | When we did the Fedora infrastructure, the admins decided they wanted apache content served out of /srv/web.
|| [[#t13:11|13:11]]
|- id="t13:11"
! style="background-color: #4d4d93" |  icarus-c
| style="color: #4d4d93" | dwalsh: are you meaning that sometimes avc throws "wrong" message?
|| [[#t13:11|13:11]]
|- id="t13:11"
! style="background-color: #407a40" |  dwalsh
| style="color: #407a40" | No it throws the correct message, but the message is caused by bad labeling.
|| [[#t13:11|13:11]]
|- id="t13:12"
! style="background-color: #407a40" |  dwalsh
| style="color: #407a40" | The /srv/web context on a RHEL5 box was var_t
|| [[#t13:12|13:12]]
|- id="t13:13"
! style="background-color: #407a40" |  dwalsh
| style="color: #407a40" | But apache policy does not allow httpd_t to read/write var_t. so we needed to change the labeling.
|| [[#t13:13|13:13]]
|- id="t13:13"
! style="background-color: #407a40" |  dwalsh
| style="color: #407a40" | We could use chcon to change the labels.
|| [[#t13:13|13:13]]
|- id="t13:14"
! style="background-color: #407a40" |  dwalsh
| style="color: #407a40" | chcon -R -t http_sys_content_t /srv/web
|| [[#t13:14|13:14]]
|- id="t13:14"
! style="background-color: #407a40" |  dwalsh
| style="color: #407a40" | But this does not survive a relabel.
|| [[#t13:14|13:14]]
|- id="t13:14"
! style="background-color: #407a40" |  dwalsh
| style="color: #407a40" | You need to TELL selinux about the change from default labeling.
|| [[#t13:14|13:14]]
|- id="t13:14"
! style="background-color: #407a40" |  dwalsh
| style="color: #407a40" | So you use the semanage command
|| [[#t13:14|13:14]]
|- id="t13:15"
! style="background-color: #407a40" |  dwalsh
| style="color: #407a40" | semanage fcontext -a -t http_sys_content_t '/srv/web(/.*)?'
|| [[#t13:15|13:15]]
|- id="t13:15"
! style="background-color: #407a40" |  dwalsh
| style="color: #407a40" | This tells SELinux to label all files/directories under /srv/web as apache content.
|| [[#t13:15|13:15]]
|- id="t13:15"
! style="background-color: #407a40" |  dwalsh
| style="color: #407a40" | semanage fcontext -a -t httpd_sys_content_t '/srv/web(/.*)?'
|| [[#t13:15|13:15]]
|- id="t13:15"
! style="background-color: #407a40" |  dwalsh
| style="color: #407a40" | Should have been httpd_sys_content_t
|| [[#t13:15|13:15]]
|- id="t13:16"
! style="background-color: #407a40" |  dwalsh
| style="color: #407a40" | In SELinux we use regular expressions to figure out the labeling.  So that is why we have the weird file expression.
|| [[#t13:16|13:16]]
|- id="t13:16"
! style="background-color: #407a40" |  dwalsh
| style="color: #407a40" | After you tell SELinux about the labeling, you need to change the actual files on disk
|| [[#t13:16|13:16]]
|- id="t13:16"
! style="background-color: #407a40" |  dwalsh
| style="color: #407a40" | restorecon -R -v /srv/web
|| [[#t13:16|13:16]]
|- id="t13:17"
! style="background-color: #407a40" |  dwalsh
| style="color: #407a40" | Now your httpd daemon is able to read the files.
|| [[#t13:17|13:17]]
|- id="t13:17"
! style="background-color: #407a40" |  dwalsh
| style="color: #407a40" | If you wanted to be able to write the files you could have set the labels to
|| [[#t13:17|13:17]]
|- id="t13:17"
! style="background-color: #407a40" |  dwalsh
| style="color: #407a40" | httpd_sys_content_rw_t.
|| [[#t13:17|13:17]]
|- id="t13:17"
! style="background-color: #407a40" |  dwalsh
| style="color: #407a40" | Questions?
|| [[#t13:17|13:17]]
|- id="t13:18"
! style="background-color: #97974f" |  moixs
| style="color: #97974f" | One :)
|| [[#t13:18|13:18]]
|- id="t13:18"
! style="background-color: #9b519b" |  BounceCat
| style="color: #9b519b" | dwalsh: if you want us to follow along in your slides, please say when to change slides. thanks.
|| [[#t13:18|13:18]]
|- id="t13:18"
! style="background-color: #407a40" |  dwalsh
| style="color: #407a40" | Ok, This is slide 3
|| [[#t13:18|13:18]]
|- id="t13:18"
! style="background-color: #407a40" |  dwalsh
| style="color: #407a40" | SELinux == Labeling.
|| [[#t13:18|13:18]]
|- id="t13:18"
! style="background-color: #4b904b" |  linuxguru
| style="color: #4b904b" | Sometimes it still doesn't work i mean setting up context to httpd_sys_content_rw_t in case of a typical dokuwiki installation in /var/www/html/ i faced this situation.
|| [[#t13:18|13:18]]
|- id="t13:18"
! style="background-color: #97974f" |  moixs
| style="color: #97974f" | When you make these changes, can you save them and replicate them easily on another system?
|| [[#t13:18|13:18]]
|- id="t13:18"
! style="background-color: #9b519b" |  BounceCat
| style="color: #9b519b" | ok
|| [[#t13:18|13:18]]
|- id="t13:18"
! style="background-color: #407a40" |  dwalsh
| style="color: #407a40" | The notes section has decent content also
|| [[#t13:18|13:18]]
|- id="t13:19"
! style="background-color: #407a40" |  dwalsh
| style="color: #407a40" | moixs, In Fedora infrastructure we are using puppet to basically execute the semanage commands on a large group of machines.
|| [[#t13:19|13:19]]
|- id="t13:20"
! style="background-color: #407a40" |  dwalsh
| style="color: #407a40" | We plan on using IPA also for this in RHEL6 time frame.
|| [[#t13:20|13:20]]
|- id="t13:20"
! style="background-color: #407a40" |  dwalsh
| style="color: #407a40" | linuxguru, Please explain?
|| [[#t13:20|13:20]]
|- id="t13:20"
! style="background-color: #97974f" |  moixs
| style="color: #97974f" | Ok, seems reasonable
|| [[#t13:20|13:20]]
|- id="t13:20"
! style="background-color: #42427e" |  dgrift_
| style="color: #42427e" | one can also use a policy package to distribute file contexts across systems
|| [[#t13:20|13:20]]
|- id="t13:20"
! style="background-color: #407a40" |  dwalsh
| style="color: #407a40" | The commands are pemanent.
|| [[#t13:20|13:20]]
|- id="t13:20"
! style="background-color: #4b904b" |  linuxguru
| style="color: #4b904b" | dwalsh, it said me to enable a boolean , httpd_unified
|| [[#t13:20|13:20]]
|- id="t13:20"
! style="background-color: #407a40" |  dwalsh
| style="color: #407a40" | linuxguru, Yes that is a bug in httpd_unified, in F10.
|| [[#t13:20|13:20]]
|- id="t13:21"
! style="background-color: #4b904b" |  linuxguru
| style="color: #4b904b" | okay
|| [[#t13:21|13:21]]
|- id="t13:21"
! style="background-color: #407a40" |  dwalsh
| style="color: #407a40" | linuxguru, I will cover the boolean in the next section.
|| [[#t13:21|13:21]]
|- id="t13:21"
! style="background-color: #4b904b" |  linuxguru
| style="color: #4b904b" | dwalsh, okay sir
|| [[#t13:21|13:21]]
|- id="t13:21"
! style="background-color: #407a40" |  dwalsh
| style="color: #407a40" | In this case it is more secure to leave httpd_unified off and set the context to httpd_sys_content_rw_t.
|| [[#t13:21|13:21]]
|- id="t13:21"
! style="background-color: #407a40" |  dwalsh
| style="color: #407a40" | A couple more comments on labeling.
|| [[#t13:21|13:21]]
|- id="t13:22"
! style="background-color: #4b904b" |  linuxguru
| style="color: #4b904b" | yeah. i had to do that for every file it complained off.
|| [[#t13:22|13:22]]
|- id="t13:22"
! style="background-color: #4b904b" |  linuxguru
| style="color: #4b904b" | in random directories sometimes. so not sure if should apply on directory or not
|| [[#t13:22|13:22]]
|- id="t13:22"
! style="background-color: #407a40" |  dwalsh
| style="color: #407a40" | SELinux handles labels at the directory level better then individual files.
|| [[#t13:22|13:22]]
|- id="t13:23"
! style="background-color: #407a40" |  dwalsh
| style="color: #407a40" | So if you can label the directory and all its contents with a single label, SELinux becomes more managable.
|| [[#t13:23|13:23]]
|- id="t13:23"
! style="background-color: #407a40" |  dwalsh
| style="color: #407a40" | For example, If I have a confined domain that wants to manage files in /etc.
|| [[#t13:23|13:23]]
|- id="t13:24"
! style="background-color: #407a40" |  dwalsh
| style="color: #407a40" | It would be better to have the app manage /etc/myapp/*
|| [[#t13:24|13:24]]
|- id="t13:24"
! style="background-color: #407a40" |  dwalsh
| style="color: #407a40" | And label /etc/myapp as myapp_etc_rw_t
|| [[#t13:24|13:24]]
|- id="t13:24"
! style="background-color: #407a40" |  dwalsh
| style="color: #407a40" | That way by default all files created in /etc/myapp will be created as myapp_etc_rw_t
|| [[#t13:24|13:24]]
|- id="t13:25"
! style="background-color: #407a40" |  dwalsh
| style="color: #407a40" | If I just put the files in /etc. they would default to etc_t and then I would have to rely on the administrator maintaining the label.
|| [[#t13:25|13:25]]
|- id="t13:25"
! style="background-color: #407a40" |  dwalsh
| style="color: #407a40" | If an administrator decides to create his own top level directory under /
|| [[#t13:25|13:25]]
|- id="t13:25"
! style="background-color: #407a40" |  dwalsh
| style="color: #407a40" | The label will be labeled default_t.
|| [[#t13:25|13:25]]
|- id="t13:26"
! style="background-color: #407a40" |  dwalsh
| style="color: #407a40" | NO confined apps are allowed to use default_t for that reason.
|| [[#t13:26|13:26]]
|- id="t13:26"
! style="background-color: #407a40" |  dwalsh
| style="color: #407a40" | We expect the admin might be putting the secrets to the "Lost Arch" there so we don't want the untrusted domains to be able to read it.
|| [[#t13:26|13:26]]
|- id="t13:27"
! style="background-color: #407a40" |  dwalsh
| style="color: #407a40" | So if you create a directory for use by a service, you need to change the label to the correct context.
|| [[#t13:27|13:27]]
|- id="t13:27"
! style="background-color: #407a40" |  dwalsh
| style="color: #407a40" | A  good command to look for context that a domain can write, is sesearch
|| [[#t13:27|13:27]]
|- id="t13:27"
! style="background-color: #407a40" |  dwalsh
| style="color: #407a40" | sesearch --allow -s httpd_t -c file -p write
|| [[#t13:27|13:27]]
|- id="t13:28"
! style="background-color: #407a40" |  dwalsh
| style="color: #407a40" | This should show you all the context that the httpd_t label can write
|| [[#t13:28|13:28]]
|- id="t13:28"
! style="background-color: #407a40" |  dwalsh
| style="color: #407a40" | That is one method to find the correct context.
|| [[#t13:28|13:28]]
|- id="t13:29"
! style="background-color: #407a40" |  dwalsh
| style="color: #407a40" | We also have man httpd_selinux and a few other man pages.
|| [[#t13:29|13:29]]
|- id="t13:29"
! style="background-color: #407a40" |  dwalsh
| style="color: #407a40" | Red Hat is developing a guide in Fedora for managing confined services.
|| [[#t13:29|13:29]]
|- id="t13:30"
! style="background-color: #407a40" |  dwalsh
| style="color: #407a40" | Which I can not find the link for now.  But it is out there.
|| [[#t13:30|13:30]]
|- id="t13:30"
! style="background-color: #407a40" |  dwalsh
| style="color: #407a40" | One special context type you will see out there is "file_t"
|| [[#t13:30|13:30]]
|- id="t13:30"
! style="background-color: #42427e" |  dgrift_
| style="color: #42427e" |  http://sradvan.fedorapeople.org/SELinux_Managing_Co
|| [[#t13:30|13:30]]
|- id="t13:31"
! style="background-color: #407a40" |  dwalsh
| style="color: #407a40" | THis type indicates the file has no label at all on it.
|| [[#t13:31|13:31]]
|- id="t13:31"
! style="background-color: #407a40" |  dwalsh
| style="color: #407a40" | It should have been called unlabeled_t if I could use a wayback machine I would go back to 2002 and change it.
|| [[#t13:31|13:31]]
|- id="t13:31"
! style="background-color: #42427e" |  dgrift_
| style="color: #42427e" | proper url: http://sradvan.fedorapeople.org/SELinux_Managing_Confined_Services/en-US/html-single/
|| [[#t13:31|13:31]]
|- id="t13:31"
! style="background-color: #407a40" |  dwalsh
| style="color: #407a40" | If you see this label is usually means you have a very badly mislabeled machine, and you need to trigger a full relabel
|| [[#t13:31|13:31]]
|- id="t13:32"
! style="background-color: #407a40" |  dwalsh
| style="color: #407a40" | touch /.autorelabel; reboot
|| [[#t13:32|13:32]]
|- id="t13:32"
! style="background-color: #407a40" |  dwalsh
| style="color: #407a40" | Or Just run fixfiles restore.
|| [[#t13:32|13:32]]
|- id="t13:32"
! style="background-color: #407a40" |  dwalsh
| style="color: #407a40" | But you usually do not need to do this...
|| [[#t13:32|13:32]]
|- id="t13:32"
! style="background-color: #407a40" |  dwalsh
| style="color: #407a40" | One other time I see file_t showing up, might be related to usb sticks.
|| [[#t13:32|13:32]]
|- id="t13:33"
! style="background-color: #407a40" |  dwalsh
| style="color: #407a40" | Someone moving a file off of usb stick. Although that is only a theory of mine, I have not been able to prove it.
|| [[#t13:33|13:33]]
|- id="t13:34"
! style="background-color: #407a40" |  dwalsh
| style="color: #407a40" | File labeling also comes into play, when selecting the label to run a process as
|| [[#t13:34|13:34]]
|- id="t13:34"
! style="background-color: #407a40" |  dwalsh
| style="color: #407a40" | What I mean by this is SELinux defines "Transitions"
|| [[#t13:34|13:34]]
|- id="t13:35"
! style="background-color: #407a40" |  dwalsh
| style="color: #407a40" | When an SELinux system boots, it starts out running the kernel with no context, then the initrd loads the policy.
|| [[#t13:35|13:35]]
|- id="t13:35"
! style="background-color: #407a40" |  dwalsh
| style="color: #407a40" | The policy says to run the system as kernel_t
|| [[#t13:35|13:35]]
|- id="t13:35"
! style="background-color: #407a40" |  dwalsh
| style="color: #407a40" | It also defines a transition from kernel_t.
|| [[#t13:35|13:35]]
|- id="t13:36"
! style="background-color: #407a40" |  dwalsh
| style="color: #407a40" | When kernel_t runs an executable labeled init_exec_t it will transition to init_t
|| [[#t13:36|13:36]]
|- id="t13:36"
! style="background-color: #407a40" |  dwalsh
| style="color: #407a40" | So this is how upstart or init gets labeled init_t.
|| [[#t13:36|13:36]]
|- id="t13:36"
! style="background-color: #407a40" |  dwalsh
| style="color: #407a40" | Other transtions also happen
|| [[#t13:36|13:36]]
|- id="t13:36"
! style="background-color: #407a40" |  dwalsh
| style="color: #407a40" | init_t->initrc_exec_t->initrc_t
|| [[#t13:36|13:36]]
|- id="t13:37"
! style="background-color: #407a40" |  dwalsh
| style="color: #407a40" | So all init scripts are labeled initrc_exec_t by default.
|| [[#t13:37|13:37]]
|- id="t13:37"
! style="background-color: #407a40" |  dwalsh
| style="color: #407a40" | Or some varient,
|| [[#t13:37|13:37]]
|- id="t13:37"
! style="background-color: #407a40" |  dwalsh
| style="color: #407a40" | Then a transition rule is written that says
|| [[#t13:37|13:37]]
|- id="t13:37"
! style="background-color: #407a40" |  dwalsh
| style="color: #407a40" | initrc_t->httpd_exec_t->httpd_t
|| [[#t13:37|13:37]]
|- id="t13:37"
! style="background-color: #407a40" |  dwalsh
| style="color: #407a40" | And finally
|| [[#t13:37|13:37]]
|- id="t13:37"
! style="background-color: #407a40" |  dwalsh
| style="color: #407a40" | httpd_t->httpd_sys_script_exec_t->httpd_sys_script_t
|| [[#t13:37|13:37]]
|- id="t13:38"
! style="background-color: #407a40" |  dwalsh
| style="color: #407a40" | So if ANY labeling is wrong the transitions will fail and the app will end up running under the wrong context.
|| [[#t13:38|13:38]]
|- id="t13:38"
! style="background-color: #407a40" |  dwalsh
| style="color: #407a40" | So Always check you labeling.
|| [[#t13:38|13:38]]
|- id="t13:38"
! style="background-color: #407a40" |  dwalsh
| style="color: #407a40" | Slide 4
|| [[#t13:38|13:38]]
|- id="t13:38"
! style="background-color: #9b519b" |  BounceCat
| style="color: #9b519b" | If I want to see what domain a particular executable is labelled as, can you give a cli example how to see that? (apart from reading selinux errror message)
|| [[#t13:38|13:38]]
|- id="t13:39"
! style="background-color: #407a40" |  dwalsh
| style="color: #407a40" | Well you can check the label on disk
|| [[#t13:39|13:39]]
|- id="t13:39"
! style="background-color: #407a40" |  dwalsh
| style="color: #407a40" | ls -lZ /usr/sbin/httpd
|| [[#t13:39|13:39]]
|- id="t13:39"
! style="background-color: #407a40" |  dwalsh
| style="color: #407a40" | This will show you the current label
|| [[#t13:39|13:39]]
|- id="t13:39"
! style="background-color: #407a40" |  dwalsh
| style="color: #407a40" | You can ask the machine what the label should be
|| [[#t13:39|13:39]]
|- id="t13:39"
! style="background-color: #407a40" |  dwalsh
| style="color: #407a40" | matchpathcon /usr/sbin/httpd
|| [[#t13:39|13:39]]
|- id="t13:40"
! style="background-color: #407a40" |  dwalsh
| style="color: #407a40" | If they are different you can make it write
|| [[#t13:40|13:40]]
|- id="t13:40"
! style="background-color: #407a40" |  dwalsh
| style="color: #407a40" | restorecon /usr/sbin/httpd
|| [[#t13:40|13:40]]
|- id="t13:40"
! style="background-color: #9b519b" |  BounceCat
| style="color: #9b519b" | great thanks.
|| [[#t13:40|13:40]]
|- id="t13:40"
! style="background-color: #407a40" |  dwalsh
| style="color: #407a40" | But say you have another app that works just like httpd.  Has the same security domain.
|| [[#t13:40|13:40]]
|- id="t13:40"
! style="background-color: #407a40" |  dwalsh
| style="color: #407a40" | /usr/sbin/myhttpd
|| [[#t13:40|13:40]]
|- id="t13:41"
! style="background-color: #407a40" |  dwalsh
| style="color: #407a40" | You would want this to be labeled like httpd
|| [[#t13:41|13:41]]
|- id="t13:41"
! style="background-color: #407a40" |  dwalsh
| style="color: #407a40" | semanage fcontext -a -t httpd_exec_t /usr/sbin/httpd
|| [[#t13:41|13:41]]
|- id="t13:41"
! style="background-color: #407a40" |  dwalsh
| style="color: #407a40" | Slide 4 shows you system-config-selinux, which allows you to set the file context
|| [[#t13:41|13:41]]
|- id="t13:41"
! style="background-color: #407a40" |  dwalsh
| style="color: #407a40" | Via a GUI, if you are so inclined.
|| [[#t13:41|13:41]]
|- id="t13:42"
! style="background-color: #407a40" |  dwalsh
| style="color: #407a40" | One interesting addition to F11 is the idea of equivalence.
|| [[#t13:42|13:42]]
|- id="t13:42"
! style="background-color: #407a40" |  dwalsh
| style="color: #407a40" | What I was looking for here was a way to say /srv/web should be labeled just like /var/www/
|| [[#t13:42|13:42]]
|- id="t13:43"
! style="background-color: #407a40" |  dwalsh
| style="color: #407a40" | I want to copy all file context that match the directory /srv/web and substiture /var/www
|| [[#t13:43|13:43]]
|- id="t13:43"
! style="background-color: #407a40" |  dwalsh
| style="color: #407a40" | So with semanage I can execute
|| [[#t13:43|13:43]]
|- id="t13:43"
! style="background-color: #407a40" |  dwalsh
| style="color: #407a40" | semanage fcontext -a -e /var/www /srv/web
|| [[#t13:43|13:43]]
|- id="t13:43"
! style="background-color: #407a40" |  dwalsh
| style="color: #407a40" | Which is a pretty powerfull concept.
|| [[#t13:43|13:43]]
|- id="t13:44"
! style="background-color: #407a40" |  dwalsh
| style="color: #407a40" | Another example would be setting up an alternate location for home dirs.
|| [[#t13:44|13:44]]
|- id="t13:44"
! style="background-color: #407a40" |  dwalsh
| style="color: #407a40" | Ok I got to get moving...
|| [[#t13:44|13:44]]
|- id="t13:44"
! style="background-color: #407a40" |  dwalsh
| style="color: #407a40" | Slike 5
|| [[#t13:44|13:44]]
|- id="t13:45"
! style="background-color: #407a40" |  dwalsh
| style="color: #407a40" | Covers the semange equivalence and genhomedircon
|| [[#t13:45|13:45]]
|- id="t13:45"
! style="background-color: #407a40" |  dwalsh
| style="color: #407a40" | Lets move onto Slide 6
|| [[#t13:45|13:45]]
|- id="t13:45"
! style="background-color: #407a40" |  dwalsh
| style="color: #407a40" | SELinux needs to KNOW.
|| [[#t13:45|13:45]]
|- id="t13:45"
! style="background-color: #407a40" |  dwalsh
| style="color: #407a40" | The idea here is that confined apps can be configured to run in different ways.
|| [[#t13:45|13:45]]
|- id="t13:46"
! style="background-color: #407a40" |  dwalsh
| style="color: #407a40" | So you need to tell SELinux how you are going to run the apps.
|| [[#t13:46|13:46]]
|- id="t13:47"
! style="background-color: #407a40" |  dwalsh
| style="color: #407a40" | I am often asked why don't the writers of APPS write their own policy.
|| [[#t13:47|13:47]]
|- id="t13:47"
! style="background-color: #407a40" |  dwalsh
| style="color: #407a40" | I think it would be a good idea but it also could be a bad idea.
|| [[#t13:47|13:47]]
|- id="t13:48"
! style="background-color: #97974f" |  moixs
| style="color: #97974f" | (good question, who in Fedora actually does this?)
|| [[#t13:48|13:48]]
|- id="t13:48"
! style="background-color: #407a40" |  dwalsh
| style="color: #407a40" | As an example, if I asked the writer of vsftpd to define their policy
|| [[#t13:48|13:48]]
|- id="t13:48"
! style="background-color: #407a40" |  dwalsh
| style="color: #407a40" | They would say that ftp sometimes needs to read any file on disk,
|| [[#t13:48|13:48]]
|- id="t13:48"
! style="background-color: #407a40" |  dwalsh
| style="color: #407a40" | Sometimes needs to write any file on disk.
|| [[#t13:48|13:48]]
|- id="t13:48"
! style="background-color: #407a40" |  dwalsh
| style="color: #407a40" | So policy should allow ftp to read/write everything.
|| [[#t13:48|13:48]]
|- id="t13:49"
| colspan="2" | * maximus007 cringes
|| [[#t13:49|13:49]]
|- id="t13:49"
! style="background-color: #407a40" |  dwalsh
| style="color: #407a40" | Except that 99% of all users of ftp just use it to share a very small directori
|| [[#t13:49|13:49]]
|- id="t13:49"
! style="background-color: #407a40" |  dwalsh
| style="color: #407a40" | /var/ftp
|| [[#t13:49|13:49]]
|- id="t13:49"
! style="background-color: #407a40" |  dwalsh
| style="color: #407a40" | So A better solution would to have rules built into policy for an admin to tell SELInux how he uses frp
|| [[#t13:49|13:49]]
|- id="t13:49"
! style="background-color: #407a40" |  dwalsh
| style="color: #407a40" | ftp
|| [[#t13:49|13:49]]
|- id="t13:50"
! style="background-color: #407a40" |  dwalsh
| style="color: #407a40" | These are called booleans
|| [[#t13:50|13:50]]
|- id="t13:50"
! style="background-color: #407a40" |  dwalsh
| style="color: #407a40" | In the case of we have several booleans
|| [[#t13:50|13:50]]
|- id="t13:51"
! style="background-color: #407a40" |  dwalsh
| style="color: #407a40" | # semanage boolean -l | grep ftp
|| [[#t13:51|13:51]]
|- id="t13:51"
! style="background-color: #407a40" |  dwalsh
| style="color: #407a40" | ftp_home_dir                  -> off  Allow ftp to read and write files in the user home directories
|| [[#t13:51|13:51]]
|- id="t13:51"
! style="background-color: #407a40" |  dwalsh
| style="color: #407a40" | allow_ftpd_full_access        -> off  Allow ftp servers to login to local users and read/write all files on the system, governed by DAC.
|| [[#t13:51|13:51]]
|- id="t13:51"
! style="background-color: #407a40" |  dwalsh
| style="color: #407a40" | allow_ftpd_use_nfs            -> off  Allow ftp servers to use nfs for public file transfer services.
|| [[#t13:51|13:51]]
|- id="t13:51"
! style="background-color: #407a40" |  dwalsh
| style="color: #407a40" | allow_ftpd_anon_write          -> off  Allow ftp servers to upload files,  used for public file transfer services. Directories must be labeled public_content_rw_t.
|| [[#t13:51|13:51]]
|- id="t13:51"
! style="background-color: #407a40" |  dwalsh
| style="color: #407a40" | tftp_anon_write                -> off  Allow tftp to modify public files used for public file transfer services.
|| [[#t13:51|13:51]]
|- id="t13:51"
! style="background-color: #407a40" |  dwalsh
| style="color: #407a40" | ftpd_connect_db                -> off  Allow ftp servers to use connect to mysql database
|| [[#t13:51|13:51]]
|- id="t13:51"
! style="background-color: #407a40" |  dwalsh
| style="color: #407a40" | allow_ftpd_use_cifs            -> off  Allow ftp servers to use cifs for public file transfer services.
|| [[#t13:51|13:51]]
|- id="t13:51"
! style="background-color: #407a40" |  dwalsh
| style="color: #407a40" | httpd_enable_ftp_server        -> off  Allow httpd to act as a FTP server by listening on the ftp port.
|| [[#t13:51|13:51]]
|- id="t13:51"
! style="background-color: #407a40" |  dwalsh
| style="color: #407a40" | By default ftp is setup to only allow access to /var/ftp directory but you can alter these booleans to allow additional access.
|| [[#t13:51|13:51]]
|- id="t13:52"
! style="background-color: #407a40" |  dwalsh
| style="color: #407a40" | Fedora 11 has about 127 booleans now.
|| [[#t13:52|13:52]]
|- id="t13:53"
! style="background-color: #407a40" |  dwalsh
| style="color: #407a40" | Slide 7 and Slide 8 show you two different GUI tools used to manipulate booleans
|| [[#t13:53|13:53]]
|- id="t13:53"
! style="background-color: #407a40" |  dwalsh
| style="color: #407a40" | You can also use audit2allow -w (audit2why) to look at an AVC and see if a boolean would have allowed the access
|| [[#t13:53|13:53]]
|- id="t13:54"
! style="background-color: #407a40" |  dwalsh
| style="color: #407a40" | setroubleshoot uses this functionality to try to figure out if a boolean is ok
|| [[#t13:54|13:54]]
|- id="t13:54"
! style="background-color: #407a40" |  dwalsh
| style="color: #407a40" | The tool is actually attempting all possible booleans to see if any one would allow the access.
|| [[#t13:54|13:54]]
|- id="t13:54"
! style="background-color: #407a40" |  dwalsh
| style="color: #407a40" | In some cases multiple booleans are required to be turned on to allow access.
|| [[#t13:54|13:54]]
|- id="t13:55"
! style="background-color: #407a40" |  dwalsh
| style="color: #407a40" | For example allowing httpd scripts to be executed in a users home directory requires two or three booleans.
|| [[#t13:55|13:55]]
|- id="t13:55"
! style="background-color: #407a40" |  dwalsh
| style="color: #407a40" | Sadly audit2allow -w is not smart enough to figure this out.
|| [[#t13:55|13:55]]
|- id="t13:56"
! style="background-color: #407a40" |  dwalsh
| style="color: #407a40" | Again the management guide and other tools are helpful in figuring this out.
|| [[#t13:56|13:56]]
|- id="t13:56"
! style="background-color: #407a40" |  dwalsh
| style="color: #407a40" | Sline 9
|| [[#t13:56|13:56]]
|- id="t13:56"
! style="background-color: #407a40" |  dwalsh
| style="color: #407a40" | Slide 9
|| [[#t13:56|13:56]]
|- id="t13:56"
! style="background-color: #407a40" |  dwalsh
| style="color: #407a40" | Sadly SELINux Policy has bugs.
|| [[#t13:56|13:56]]
|- id="t13:56"
! style="background-color: #407a40" |  dwalsh
| style="color: #407a40" | Apps have bugs also
|| [[#t13:56|13:56]]
|- id="t13:56"
! style="background-color: #407a40" |  dwalsh
| style="color: #407a40" | Sometimes we release an app that causes new SELinux errors.
|| [[#t13:56|13:56]]
|- id="t13:57"
! style="background-color: #407a40" |  dwalsh
| style="color: #407a40" | We try not to do this but Fedora is an active community.
|| [[#t13:57|13:57]]
|- id="t13:57"
! style="background-color: #407a40" |  dwalsh
| style="color: #407a40" | I try not to add new confinement within a release.
|| [[#t13:57|13:57]]
|- id="t13:57"
! style="background-color: #407a40" |  dwalsh
| style="color: #407a40" | Once Fedora 11 is released, we tend to only loosen the policy.  Add new allow rules, but not implement new confinement.
|| [[#t13:57|13:57]]
|- id="t13:58"
! style="background-color: #407a40" |  dwalsh
| style="color: #407a40" | And on RHEL releases we really frown on this.
|| [[#t13:58|13:58]]
|- id="t13:58"
! style="background-color: #407a40" |  dwalsh
| style="color: #407a40" | But What does an administrator do if SELinux or an APP are just broken.
|| [[#t13:58|13:58]]
|- id="t13:58"
! style="background-color: #407a40" |  dwalsh
| style="color: #407a40" | They labeling is correct.
|| [[#t13:58|13:58]]
|- id="t13:58"
! style="background-color: #407a40" |  dwalsh
| style="color: #407a40" | No Boolean allows the access?
|| [[#t13:58|13:58]]
|- id="t13:58"
! style="background-color: #407a40" |  dwalsh
| style="color: #407a40" | In this case the admin can fairly easily ad a custom policy module using audit2allow
|| [[#t13:58|13:58]]
|- id="t13:59"
! style="background-color: #407a40" |  dwalsh
| style="color: #407a40" | grep avc /var/log/audit/audit.log | audit2allow -M mypol
|| [[#t13:59|13:59]]
|- id="t13:59"
! style="background-color: #407a40" |  dwalsh
| style="color: #407a40" | This create a file called mypol.pp
|| [[#t13:59|13:59]]
|- id="t13:59"
! style="background-color: #407a40" |  dwalsh
| style="color: #407a40" | which can then be installed via semodule
|| [[#t13:59|13:59]]
|- id="t13:59"
! style="background-color: #407a40" |  dwalsh
| style="color: #407a40" | semodule -i mypol.pp
|| [[#t13:59|13:59]]
|- id="t14:00"
! style="background-color: #407a40" |  dwalsh
| style="color: #407a40" | mypol.te also gets created,
|| [[#t14:00|14:00]]
|- id="t14:00"
! style="background-color: #407a40" |  dwalsh
| style="color: #407a40" | You should really examine what this file is allowing, since it could be a security problem.
|| [[#t14:00|14:00]]
|- id="t14:00"
! style="background-color: #407a40" |  dwalsh
| style="color: #407a40" | For example allowing a confined app to write to etc_t is not a good idea since the app would be allowed to overwrite /etc/passwd
|| [[#t14:00|14:00]]
|- id="t14:01"
! style="background-color: #407a40" |  dwalsh
| style="color: #407a40" | But this method will allow you to customize policy to make the app just work.
|| [[#t14:01|14:01]]
|- id="t14:01"
! style="background-color: #407a40" |  dwalsh
| style="color: #407a40" | When you generate a policy using this method it creates a policy called mypol. if you execute the command later with different avcs but use the same name, you will override the first rules and replace them with new rules.
|| [[#t14:01|14:01]]
|- id="t14:02"
! style="background-color: #407a40" |  dwalsh
| style="color: #407a40" | So be carefull.
|| [[#t14:02|14:02]]
|- id="t14:02"
! style="background-color: #407a40" |  dwalsh
| style="color: #407a40" | Questions?
|| [[#t14:02|14:02]]
|- id="t14:02"
! style="background-color: #9b519b" |  BounceCat
| style="color: #9b519b" | "Slide 7 and Slide 8 show you two different GUI tools used to manipulate booleans" .. please name these tools
|| [[#t14:02|14:02]]
|- id="t14:02"
! style="background-color: #97974f" |  moixs
| style="color: #97974f" | Maybe a more general one
|| [[#t14:02|14:02]]
|- id="t14:02"
! style="background-color: #97974f" |  moixs
| style="color: #97974f" | How do you manage applications from external repositories, like RPM Fusion? Is the packager from RPM Fusion supposed to communicate with Fedora about SELinux policies? Does RPM Fusion maintain its own set of SELinux policies?
|| [[#t14:02|14:02]]
|- id="t14:03"
! style="background-color: #407a40" |  dwalsh
| style="color: #407a40" | BounceCat, system-config-selinux launces both.
|| [[#t14:03|14:03]]
|- id="t14:03"
! style="background-color: #9b519b" |  BounceCat
| style="color: #9b519b" | ok
|| [[#t14:03|14:03]]
|- id="t14:03"
! style="background-color: #407a40" |  dwalsh
| style="color: #407a40" | One is the default view, the second is created by going to the booleans screen and hitting lockdown.
|| [[#t14:03|14:03]]
|- id="t14:03"
! style="background-color: #9b519b" |  BounceCat
| style="color: #9b519b" | thx
|| [[#t14:03|14:03]]
|- id="t14:04"
! style="background-color: #407a40" |  dwalsh
| style="color: #407a40" | moixs, These apps may or maynot have policy defined for them.
|| [[#t14:04|14:04]]
|- id="t14:04"
! style="background-color: #407a40" |  dwalsh
| style="color: #407a40" | But they should all be able to run on a Fedora 11 box.
|| [[#t14:04|14:04]]
|- id="t14:04"
! style="background-color: #97974f" |  moixs
| style="color: #97974f" | So it's the packager's responsibility do do that?
|| [[#t14:04|14:04]]
|- id="t14:05"
! style="background-color: #407a40" |  dwalsh
| style="color: #407a40" | As I stated in an internal list, I think we can get the biggest piece of crap software to be able to run with SELinux in enforing mode.
|| [[#t14:05|14:05]]
|- id="t14:05"
! style="background-color: #97974f" |  moixs
| style="color: #97974f" | ok :p
|| [[#t14:05|14:05]]
|- id="t14:05"
! style="background-color: #407a40" |  dwalsh
| style="color: #407a40" | Of course this does not mean that the app will be secure...
|| [[#t14:05|14:05]]
|- id="t14:05"
! style="background-color: #407a40" |  dwalsh
| style="color: #407a40" | moixs, I will open a bugzilla or whatever with any app that is struggling with SELinux, or tell the bugreporter to do that
|| [[#t14:05|14:05]]
|- id="t14:06"
! style="background-color: #407a40" |  dwalsh
| style="color: #407a40" | Most problems with these software apps is badly built shared libraries.
|| [[#t14:06|14:06]]
|- id="t14:06"
! style="background-color: #407a40" |  dwalsh
| style="color: #407a40" | Which causes execmod violations.
|| [[#t14:06|14:06]]
|- id="t14:06"
! style="background-color: #407a40" |  dwalsh
| style="color: #407a40" | So we end up having to label them textrel_shlib_t w
|| [[#t14:06|14:06]]
|- id="t14:06"
! style="background-color: #97974f" |  moixs
| style="color: #97974f" | So you, in Fedora, will implement a "workaraound" even for an "external" application?
|| [[#t14:06|14:06]]
|- id="t14:06"
! style="background-color: #407a40" |  dwalsh
| style="color: #407a40" | which tells SELinux to now worry about a library being hacked,
|| [[#t14:06|14:06]]
|- id="t14:07"
! style="background-color: #407a40" |  dwalsh
| style="color: #407a40" | moixs, Yes, My goal is not to stop you from running you app.
|| [[#t14:07|14:07]]
|- id="t14:07"
! style="background-color: #97974f" |  moixs
| style="color: #97974f" | okay
|| [[#t14:07|14:07]]
|- id="t14:07"
! style="background-color: #407a40" |  dwalsh
| style="color: #407a40" | Otherwise you will dump us for some other unnamed distro.
|| [[#t14:07|14:07]]
|- id="t14:07"
! style="background-color: #407a40" |  dwalsh
| style="color: #407a40" | :^)
|| [[#t14:07|14:07]]
|- id="t14:07"
! style="background-color: #97974f" |  moixs
| style="color: #97974f" | It's more that I package an daemonized application in RPM Fusion and never cared about SELinux :p
|| [[#t14:07|14:07]]
|- id="t14:07"
! style="background-color: #407a40" |  dwalsh
| style="color: #407a40" | So in RHEL and Fedora by default apps run as an unconfined domain, and should be able to run unconstrained by SELinux
|| [[#t14:07|14:07]]
|- id="t14:08"
! style="background-color: #407a40" |  dwalsh
| style="color: #407a40" | moixs, Fine,  It should run.
|| [[#t14:08|14:08]]
|- id="t14:08"
! style="background-color: #407a40" |  dwalsh
| style="color: #407a40" | Well let me complete the talk since I got to go to a Baseball tryout in 15 minutes.  Not mine  :^(
|| [[#t14:08|14:08]]
|- id="t14:08"
! style="background-color: #4b904b" |  linuxguru
| style="color: #4b904b" | oh. hehe
|| [[#t14:08|14:08]]
|- id="t14:08"
! style="background-color: #539e9e" |  underscores
| style="color: #539e9e" | lol
|| [[#t14:08|14:08]]
|- id="t14:08"
! style="background-color: #407a40" |  dwalsh
| style="color: #407a40" | When I originally wrote the blog, I talked about fixing SELinux problems. but ignored the most important thing about SELinux
|| [[#t14:08|14:08]]
|- id="t14:09"
! style="background-color: #407a40" |  dwalsh
| style="color: #407a40" | How do I tell if I my machine was cracked.
|| [[#t14:09|14:09]]
|- id="t14:09"
! style="background-color: #407a40" |  dwalsh
| style="color: #407a40" | Well Sadly we have not done a good job of that, and I hope to make strides on this in F12.
|| [[#t14:09|14:09]]
|- id="t14:10"
! style="background-color: #407a40" |  dwalsh
| style="color: #407a40" | setroubleshoot is a tool that shows you selinux reported a problem.  And it tries to give you a remedy of a solution.
|| [[#t14:10|14:10]]
|- id="t14:10"
! style="background-color: #407a40" |  dwalsh
| style="color: #407a40" | We want to build some plugins that look for obvious breakins.
|| [[#t14:10|14:10]]
|- id="t14:10"
! style="background-color: #407a40" |  dwalsh
| style="color: #407a40" | For example, no confined application on an SELinux box is allowed to turn off SELinux.
|| [[#t14:10|14:10]]
|- id="t14:11"
! style="background-color: #407a40" |  dwalsh
| style="color: #407a40" | So it would be real nice to ring alarms if httpd_t tries to setenforce
|| [[#t14:11|14:11]]
|- id="t14:11"
! style="background-color: #407a40" |  dwalsh
| style="color: #407a40" | If I was breaking into an SELInux system, the first thing I would try is to turn it off.
|| [[#t14:11|14:11]]
|- id="t14:11"
! style="background-color: #818144" |  maximus007
| style="color: #818144" | well if anything but uid 0 tries it i think we have a problem and maybe even then
|| [[#t14:11|14:11]]
|- id="t14:11"
! style="background-color: #407a40" |  dwalsh
| style="color: #407a40" | Similarly loading kernel modules, writeing to security directories/files
|| [[#t14:11|14:11]]
|- id="t14:12"
! style="background-color: #407a40" |  dwalsh
| style="color: #407a40" | /etc/shadow
|| [[#t14:12|14:12]]
|- id="t14:12"
! style="background-color: #407a40" |  dwalsh
| style="color: #407a40" | /etc/selinux/*
|| [[#t14:12|14:12]]
|- id="t14:12"
! style="background-color: #407a40" |  dwalsh
| style="color: #407a40" | Kernel directories ...
|| [[#t14:12|14:12]]
|- id="t14:12"
! style="background-color: #818144" |  maximus007
| style="color: #818144" | my question is how to prevent even root from turning it off, will i have to directly modify the policy?
|| [[#t14:12|14:12]]
|- id="t14:13"
! style="background-color: #407a40" |  dwalsh
| style="color: #407a40" | So we need to change setroubleshoot to give a clearer indication that we believe the machine is compromised, and take action.
|| [[#t14:13|14:13]]
|- id="t14:13"
! style="background-color: #407a40" |  dwalsh
| style="color: #407a40" | But you can try to read the AVCs or look at the rules generated by audit2allow to figure out if something very strange is going on.
|| [[#t14:13|14:13]]
|- id="t14:14"
! style="background-color: #407a40" |  dwalsh
| style="color: #407a40" | That is the end of the formal presentation I can stay for about 5 more minutes.
|| [[#t14:14|14:14]]
|- id="t14:14"
! style="background-color: #407a40" |  dwalsh
| style="color: #407a40" | Any other questions?
|| [[#t14:14|14:14]]
|- id="t14:14"
! style="background-color: #407a40" |  dwalsh
| style="color: #407a40" | Or did I miss any?
|| [[#t14:14|14:14]]
|- id="t14:14"
! style="background-color: #407a40" |  dwalsh
| style="color: #407a40" | Was this useful?
|| [[#t14:14|14:14]]
|- id="t14:14"
! style="background-color: #42427e" |  dgrift_
| style="color: #42427e" | yes
|| [[#t14:14|14:14]]
|- id="t14:14"
! style="background-color: #a25555" |  mamurdian
| style="color: #a25555" | it would be nice if you could provide more such lessons
|| [[#t14:14|14:14]]
|- id="t14:15"
! style="background-color: #4b904b" |  linuxguru
| style="color: #4b904b" | sure it was dwalsh , very useful. got to know about some of the new stuff in selinux planned for f11.
|| [[#t14:15|14:15]]
|- id="t14:15"
! style="background-color: #539e9e" |  underscores
| style="color: #539e9e" | yes :)
|| [[#t14:15|14:15]]
|- id="t14:15"
! style="background-color: #9b519b" |  BounceCat
| style="color: #9b519b" | It was great Dan, thanks. I have 1 more question, but others can go first.
|| [[#t14:15|14:15]]
|- id="t14:15"
! style="background-color: #407a40" |  dwalsh
| style="color: #407a40" | Ok Maybe next month I will cover svirt.
|| [[#t14:15|14:15]]
|- id="t14:15"
! style="background-color: #8c4a4a" |  pluvo
| style="color: #8c4a4a" | Thanks dwalsh!
|| [[#t14:15|14:15]]
|- id="t14:15"
! style="background-color: #818144" |  maximus007
| style="color: #818144" | how do i keep root from turning off selinux? I can confine root but root can unconfine himself can he not? so i think i have to modify policy directly
|| [[#t14:15|14:15]]
|- id="t14:16"
! style="background-color: #97974f" |  moixs
| style="color: #97974f" | Yep, thank you :)
|| [[#t14:16|14:16]]
|- id="t14:16"
! style="background-color: #a25555" |  mamurdian
| style="color: #a25555" | maximus007> i think you can give root another role
|| [[#t14:16|14:16]]
|- id="t14:16"
! style="background-color: #407a40" |  dwalsh
| style="color: #407a40" | maximus007, Read my blog about confined users/administrators.
|| [[#t14:16|14:16]]
|- id="t14:16"
! style="background-color: #407a40" |  dwalsh
| style="color: #407a40" | THe simple answer is you define a confined admin
|| [[#t14:16|14:16]]
|- id="t14:16"
! style="background-color: #407a40" |  dwalsh
| style="color: #407a40" | Another talk.
|| [[#t14:16|14:16]]
|- id="t14:16"
! style="background-color: #818144" |  maximus007
| style="color: #818144" | ok thanks for the class, well done
|| [[#t14:16|14:16]]
|- id="t14:16"
! style="background-color: #57a657" |  Bighusky
| style="color: #57a657" | we had to install a newer package (rsync) on rhel5. Rsync and Rsyncd were not able to function properly, so we ended up using audit2allow -M to write a custom policy for this package. Was that the right approach or should we have used other means?
|| [[#t14:16|14:16]]
|- id="t14:16"
! style="background-color: #4b904b" |  linuxguru
| style="color: #4b904b" | maximus007, i don't think that requires changing the policy directly. semanage is your friend.
|| [[#t14:16|14:16]]
|- id="t14:16"
! style="background-color: #407a40" |  dwalsh
| style="color: #407a40" | Bighusky, yes
|| [[#t14:16|14:16]]
|- id="t14:17"
! style="background-color: #42427e" |  dgrift_
| style="color: #42427e" | Bighusky didyou read man rsync_selinux first?
|| [[#t14:17|14:17]]
|- id="t14:17"
! style="background-color: #407a40" |  dwalsh
| style="color: #407a40" | Bighusky, Although send me your changes dwalsh@redhat.com And I will see about getting them upstream
|| [[#t14:17|14:17]]
|- id="t14:17"
! style="background-color: #407a40" |  dwalsh
| style="color: #407a40" | Bighusky, dgrift_ Is write that a boolean might have helped you
|| [[#t14:17|14:17]]
|- id="t14:17"
! style="background-color: #818144" |  maximus007
| style="color: #818144" | linuxguru : yes but root is root and can generally run unconfined, so i'd have to remove the unconfined role i think but i will try it and see
|| [[#t14:17|14:17]]
|- id="t14:17"
! style="background-color: #5959a9" |  DiscordianUK
| style="color: #5959a9" | Thanks very much dwalsh
|| [[#t14:17|14:17]]
|- id="t14:18"
! style="background-color: #407a40" |  dwalsh
| style="color: #407a40" | rsync booleans in F11
|| [[#t14:18|14:18]]
|- id="t14:18"
! style="background-color: #407a40" |  dwalsh
| style="color: #407a40" | semanage boolean -l | grep rsync
|| [[#t14:18|14:18]]
|- id="t14:18"
! style="background-color: #407a40" |  dwalsh
| style="color: #407a40" | rsync_client                  -> off  Allow rsync to run as a client
|| [[#t14:18|14:18]]
|- id="t14:18"
! style="background-color: #407a40" |  dwalsh
| style="color: #407a40" | rsync_export_all_ro            -> off  Allow rsync to export any files/directories read only.
|| [[#t14:18|14:18]]
|- id="t14:18"
! style="background-color: #407a40" |  dwalsh
| style="color: #407a40" | allow_rsync_anon_write        -> off  Allow rsync to modify public files used for public file transfer services.  Files/Directories must be labeled public_content_rw_t.
|| [[#t14:18|14:18]]
|- id="t14:18"
! style="background-color: #407a40" |  dwalsh
| style="color: #407a40" | maximus007, You need to define an admin role and then don't give the admin the root password
|| [[#t14:18|14:18]]
|- id="t14:19"
! style="background-color: #42427e" |  dgrift_
| style="color: #42427e" | BounceCat questions?
|| [[#t14:19|14:19]]
|- id="t14:19"
! style="background-color: #57a657" |  Bighusky
| style="color: #57a657" | dwalsh, dgrift, thanks very much, I have to admit that I didn't read man rsync_selinux. I will go back and give these suggestions a try.
|| [[#t14:19|14:19]]
|- id="t14:19"
! style="background-color: #9b519b" |  BounceCat
| style="color: #9b519b" | Subdirectories I've created in my home dir are either unconfined_u, system_u, or user_u, apparently at random. What has caused that and does it matter ?
|| [[#t14:19|14:19]]
|- id="t14:19"
! style="background-color: #407a40" |  dwalsh
| style="color: #407a40" | This confined admin would then log in as a confined user and use sudo to become root.
|| [[#t14:19|14:19]]
|- id="t14:19"
! style="background-color: #407a40" |  dwalsh
| style="color: #407a40" | By default all files are created and relabeled to system_u
|| [[#t14:19|14:19]]
|- id="t14:20"
! style="background-color: #407a40" |  dwalsh
| style="color: #407a40" | If you log onto a box as a particular user type
|| [[#t14:20|14:20]]
|- id="t14:20"
! style="background-color: #407a40" |  dwalsh
| style="color: #407a40" | user_u or confined_u
|| [[#t14:20|14:20]]
|- id="t14:20"
! style="background-color: #407a40" |  dwalsh
| style="color: #407a40" | user_u or uconfined_u
|| [[#t14:20|14:20]]
|- id="t14:20"
! style="background-color: #407a40" |  dwalsh
| style="color: #407a40" | Files created by you will end up using that user type
|| [[#t14:20|14:20]]
|- id="t14:20"
! style="background-color: #407a40" |  dwalsh
| style="color: #407a40" | user_u
|| [[#t14:20|14:20]]
|- id="t14:20"
! style="background-color: #818144" |  maximus007
| style="color: #818144" | dwalsh, ok and thanks again excellent talk I have to get going myself but i will be sure to pester you about it in fedora-selinux :^)
|| [[#t14:20|14:20]]
|- id="t14:20"
! style="background-color: #407a40" |  dwalsh
| style="color: #407a40" | So user_u:user_r:user_t creates /home/dwalsh/foo
|| [[#t14:20|14:20]]
|- id="t14:21"
! style="background-color: #407a40" |  dwalsh
| style="color: #407a40" | will get created as user_u:object_r:user_home_t
|| [[#t14:21|14:21]]
|- id="t14:21"
! style="background-color: #407a40" |  dwalsh
| style="color: #407a40" | But the user componant of the file type is seldom used for denials.
|| [[#t14:21|14:21]]
|- id="t14:21"
! style="background-color: #407a40" |  dwalsh
| style="color: #407a40" | Bye.
|| [[#t14:21|14:21]]
|- id="t14:21"
! style="background-color: #42427e" |  dgrift_
| style="color: #42427e" | thanks
|| [[#t14:21|14:21]]
|- id="t14:21"
! style="background-color: #9b519b" |  BounceCat
| style="color: #9b519b" | thank you
|| [[#t14:21|14:21]]
|- id="t14:22"
! style="background-color: #42427e" |  dgrift_
| style="color: #42427e" | anyone have any questions feel free to join #fedora-selinux
|| [[#t14:22|14:22]]
|- id="t14:22"
! style="background-color: #4b904b" |  linuxguru
| style="color: #4b904b" | yes. over and out to #fedora-selinux
|| [[#t14:22|14:22]]
|- id="t14:22"
! style="background-color: #42427e" |  dgrift_
| style="color: #42427e" | we might not be available right aways but we are glad if we can help
|| [[#t14:22|14:22]]
|- id="t14:23"
! style="background-color: #57a657" |  Bighusky
| style="color: #57a657" | than you very much and have a good sunday
|| [[#t14:23|14:23]]
|}


[[Cetegory:Classroom]]
Generated by irclog2html.py 2.7 by [mailto:marius@pov.lt Marius Gedminas] - find it at [http://mg.pov.lt/irclog2html mg.pov.lt]!
 
[[Category:Classroom]]

Latest revision as of 18:25, 3 May 2009

Given by Dan Walsh (irc: dwalsh)

Slides

OpenOffice Slides

IRC Log

dwalsh This is going to be the session on "What is SELinux trying to tell me?" 12:59
dwalsh My name is Dan Walsh. I am in the Boston area. 12:59
dwalsh I put together some slides for this presentation 13:00
dwalsh http://people.fedoraproject.org/~dwalsh/SELinux/selinux4things.odp 13:00
dwalsh Where is everyone else? It is 9 AM here. 13:01
* ianweller waves 13:01
dgrift_ Rotterdam Netherlands 15:00 13:01
maximus007 florida 13:01
ianweller kansas, 8am 13:01
nihed Tunisia 13:01
pluvo Germany, 15:00 13:01
nihed Tunisia, 14:00 13:01
linuxguru india , 18:30 13:02
dwalsh Cool. 13:02
dwalsh I have been working on and off with the Fedora Infrastructure team on implementing SELinux and learned quite a bit. 13:03
dwalsh A few months ago I wrote a blog on it called 13:03
dwalsh Top three things to understand in fixing SELinux problems. 13:03
dwalsh http://danwalsh.livejournal.com/22347.html 13:03
dwalsh What I found is just about every machine we went on required a little bit of massaging 13:04
dwalsh So I came up with this list. 13:04
dwalsh I plan on writing a paper on Securing Fedora Infrastructure and explaining everything we did for Red Hat Magazine. And presenting on it at Red Hat Summit in September. 13:05
dwalsh Anyways lets start. 13:05
dwalsh The #1 thing I try to explain to people about SELinux is LABELING. 13:06
dwalsh SELinux is all about labeling. Every process has a label, every file has a label. 13:06
dwalsh If the labels are wrong, SELinux breaks down. 13:06
dwalsh So when a problem happens in SELinux the first thing to check is the labeling. 13:06
dwalsh One example of labeling getting screwed up is in the vmware package. 13:07
dwalsh In the RPM spec, they decided to edit the /etc/services file. 13:07
dwalsh They did this by copying it to /tmp and adding a port number and then moving it back to /etc 13:08
dwalsh Well in SELinux if you cp /etc/services to /tmp; the tmp file gets labeled rpm_script_tmp_t 13:08
dwalsh But the mv command maintains context, so mv moves the file back to /etc and the file is still labeled rpm_script_tmp_t. 13:09
dwalsh Now every confined domain that tries to read /etc/services is going to blow up because the label is wrong. 13:09
dwalsh Fixing the problem is as simple as restorecon /etc/services. 13:09
dwalsh But SELinux generates nasty avc's saying apache process tried to read rpm_script_tmp_t. 13:10
dwalsh BTW if anyone has questions, feel free to ask at any time. 13:10
dwalsh When we did the Fedora infrastructure, the admins decided they wanted apache content served out of /srv/web. 13:11
icarus-c dwalsh: are you meaning that sometimes avc throws "wrong" message? 13:11
dwalsh No it throws the correct message, but the message is caused by bad labeling. 13:11
dwalsh The /srv/web context on a RHEL5 box was var_t 13:12
dwalsh But apache policy does not allow httpd_t to read/write var_t. so we needed to change the labeling. 13:13
dwalsh We could use chcon to change the labels. 13:13
dwalsh chcon -R -t http_sys_content_t /srv/web 13:14
dwalsh But this does not survive a relabel. 13:14
dwalsh You need to TELL selinux about the change from default labeling. 13:14
dwalsh So you use the semanage command 13:14
dwalsh semanage fcontext -a -t http_sys_content_t '/srv/web(/.*)?' 13:15
dwalsh This tells SELinux to label all files/directories under /srv/web as apache content. 13:15
dwalsh semanage fcontext -a -t httpd_sys_content_t '/srv/web(/.*)?' 13:15
dwalsh Should have been httpd_sys_content_t 13:15
dwalsh In SELinux we use regular expressions to figure out the labeling. So that is why we have the weird file expression. 13:16
dwalsh After you tell SELinux about the labeling, you need to change the actual files on disk 13:16
dwalsh restorecon -R -v /srv/web 13:16
dwalsh Now your httpd daemon is able to read the files. 13:17
dwalsh If you wanted to be able to write the files you could have set the labels to 13:17
dwalsh httpd_sys_content_rw_t. 13:17
dwalsh Questions? 13:17
moixs One :) 13:18
BounceCat dwalsh: if you want us to follow along in your slides, please say when to change slides. thanks. 13:18
dwalsh Ok, This is slide 3 13:18
dwalsh SELinux == Labeling. 13:18
linuxguru Sometimes it still doesn't work i mean setting up context to httpd_sys_content_rw_t in case of a typical dokuwiki installation in /var/www/html/ i faced this situation. 13:18
moixs When you make these changes, can you save them and replicate them easily on another system? 13:18
BounceCat ok 13:18
dwalsh The notes section has decent content also 13:18
dwalsh moixs, In Fedora infrastructure we are using puppet to basically execute the semanage commands on a large group of machines. 13:19
dwalsh We plan on using IPA also for this in RHEL6 time frame. 13:20
dwalsh linuxguru, Please explain? 13:20
moixs Ok, seems reasonable 13:20
dgrift_ one can also use a policy package to distribute file contexts across systems 13:20
dwalsh The commands are pemanent. 13:20
linuxguru dwalsh, it said me to enable a boolean , httpd_unified 13:20
dwalsh linuxguru, Yes that is a bug in httpd_unified, in F10. 13:20
linuxguru okay 13:21
dwalsh linuxguru, I will cover the boolean in the next section. 13:21
linuxguru dwalsh, okay sir 13:21
dwalsh In this case it is more secure to leave httpd_unified off and set the context to httpd_sys_content_rw_t. 13:21
dwalsh A couple more comments on labeling. 13:21
linuxguru yeah. i had to do that for every file it complained off. 13:22
linuxguru in random directories sometimes. so not sure if should apply on directory or not 13:22
dwalsh SELinux handles labels at the directory level better then individual files. 13:22
dwalsh So if you can label the directory and all its contents with a single label, SELinux becomes more managable. 13:23
dwalsh For example, If I have a confined domain that wants to manage files in /etc. 13:23
dwalsh It would be better to have the app manage /etc/myapp/* 13:24
dwalsh And label /etc/myapp as myapp_etc_rw_t 13:24
dwalsh That way by default all files created in /etc/myapp will be created as myapp_etc_rw_t 13:24
dwalsh If I just put the files in /etc. they would default to etc_t and then I would have to rely on the administrator maintaining the label. 13:25
dwalsh If an administrator decides to create his own top level directory under / 13:25
dwalsh The label will be labeled default_t. 13:25
dwalsh NO confined apps are allowed to use default_t for that reason. 13:26
dwalsh We expect the admin might be putting the secrets to the "Lost Arch" there so we don't want the untrusted domains to be able to read it. 13:26
dwalsh So if you create a directory for use by a service, you need to change the label to the correct context. 13:27
dwalsh A good command to look for context that a domain can write, is sesearch 13:27
dwalsh sesearch --allow -s httpd_t -c file -p write 13:27
dwalsh This should show you all the context that the httpd_t label can write 13:28
dwalsh That is one method to find the correct context. 13:28
dwalsh We also have man httpd_selinux and a few other man pages. 13:29
dwalsh Red Hat is developing a guide in Fedora for managing confined services. 13:29
dwalsh Which I can not find the link for now. But it is out there. 13:30
dwalsh One special context type you will see out there is "file_t" 13:30
dgrift_ http://sradvan.fedorapeople.org/SELinux_Managing_Co 13:30
dwalsh THis type indicates the file has no label at all on it. 13:31
dwalsh It should have been called unlabeled_t if I could use a wayback machine I would go back to 2002 and change it. 13:31
dgrift_ proper url: http://sradvan.fedorapeople.org/SELinux_Managing_Confined_Services/en-US/html-single/ 13:31
dwalsh If you see this label is usually means you have a very badly mislabeled machine, and you need to trigger a full relabel 13:31
dwalsh touch /.autorelabel; reboot 13:32
dwalsh Or Just run fixfiles restore. 13:32
dwalsh But you usually do not need to do this... 13:32
dwalsh One other time I see file_t showing up, might be related to usb sticks. 13:32
dwalsh Someone moving a file off of usb stick. Although that is only a theory of mine, I have not been able to prove it. 13:33
dwalsh File labeling also comes into play, when selecting the label to run a process as 13:34
dwalsh What I mean by this is SELinux defines "Transitions" 13:34
dwalsh When an SELinux system boots, it starts out running the kernel with no context, then the initrd loads the policy. 13:35
dwalsh The policy says to run the system as kernel_t 13:35
dwalsh It also defines a transition from kernel_t. 13:35
dwalsh When kernel_t runs an executable labeled init_exec_t it will transition to init_t 13:36
dwalsh So this is how upstart or init gets labeled init_t. 13:36
dwalsh Other transtions also happen 13:36
dwalsh init_t->initrc_exec_t->initrc_t 13:36
dwalsh So all init scripts are labeled initrc_exec_t by default. 13:37
dwalsh Or some varient, 13:37
dwalsh Then a transition rule is written that says 13:37
dwalsh initrc_t->httpd_exec_t->httpd_t 13:37
dwalsh And finally 13:37
dwalsh httpd_t->httpd_sys_script_exec_t->httpd_sys_script_t 13:37
dwalsh So if ANY labeling is wrong the transitions will fail and the app will end up running under the wrong context. 13:38
dwalsh So Always check you labeling. 13:38
dwalsh Slide 4 13:38
BounceCat If I want to see what domain a particular executable is labelled as, can you give a cli example how to see that? (apart from reading selinux errror message) 13:38
dwalsh Well you can check the label on disk 13:39
dwalsh ls -lZ /usr/sbin/httpd 13:39
dwalsh This will show you the current label 13:39
dwalsh You can ask the machine what the label should be 13:39
dwalsh matchpathcon /usr/sbin/httpd 13:39
dwalsh If they are different you can make it write 13:40
dwalsh restorecon /usr/sbin/httpd 13:40
BounceCat great thanks. 13:40
dwalsh But say you have another app that works just like httpd. Has the same security domain. 13:40
dwalsh /usr/sbin/myhttpd 13:40
dwalsh You would want this to be labeled like httpd 13:41
dwalsh semanage fcontext -a -t httpd_exec_t /usr/sbin/httpd 13:41
dwalsh Slide 4 shows you system-config-selinux, which allows you to set the file context 13:41
dwalsh Via a GUI, if you are so inclined. 13:41
dwalsh One interesting addition to F11 is the idea of equivalence. 13:42
dwalsh What I was looking for here was a way to say /srv/web should be labeled just like /var/www/ 13:42
dwalsh I want to copy all file context that match the directory /srv/web and substiture /var/www 13:43
dwalsh So with semanage I can execute 13:43
dwalsh semanage fcontext -a -e /var/www /srv/web 13:43
dwalsh Which is a pretty powerfull concept. 13:43
dwalsh Another example would be setting up an alternate location for home dirs. 13:44
dwalsh Ok I got to get moving... 13:44
dwalsh Slike 5 13:44
dwalsh Covers the semange equivalence and genhomedircon 13:45
dwalsh Lets move onto Slide 6 13:45
dwalsh SELinux needs to KNOW. 13:45
dwalsh The idea here is that confined apps can be configured to run in different ways. 13:45
dwalsh So you need to tell SELinux how you are going to run the apps. 13:46
dwalsh I am often asked why don't the writers of APPS write their own policy. 13:47
dwalsh I think it would be a good idea but it also could be a bad idea. 13:47
moixs (good question, who in Fedora actually does this?) 13:48
dwalsh As an example, if I asked the writer of vsftpd to define their policy 13:48
dwalsh They would say that ftp sometimes needs to read any file on disk, 13:48
dwalsh Sometimes needs to write any file on disk. 13:48
dwalsh So policy should allow ftp to read/write everything. 13:48
* maximus007 cringes 13:49
dwalsh Except that 99% of all users of ftp just use it to share a very small directori 13:49
dwalsh /var/ftp 13:49
dwalsh So A better solution would to have rules built into policy for an admin to tell SELInux how he uses frp 13:49
dwalsh ftp 13:49
dwalsh These are called booleans 13:50
dwalsh In the case of we have several booleans 13:50
dwalsh # semanage boolean -l | grep ftp 13:51
dwalsh ftp_home_dir -> off Allow ftp to read and write files in the user home directories 13:51
dwalsh allow_ftpd_full_access -> off Allow ftp servers to login to local users and read/write all files on the system, governed by DAC. 13:51
dwalsh allow_ftpd_use_nfs -> off Allow ftp servers to use nfs for public file transfer services. 13:51
dwalsh allow_ftpd_anon_write -> off Allow ftp servers to upload files, used for public file transfer services. Directories must be labeled public_content_rw_t. 13:51
dwalsh tftp_anon_write -> off Allow tftp to modify public files used for public file transfer services. 13:51
dwalsh ftpd_connect_db -> off Allow ftp servers to use connect to mysql database 13:51
dwalsh allow_ftpd_use_cifs -> off Allow ftp servers to use cifs for public file transfer services. 13:51
dwalsh httpd_enable_ftp_server -> off Allow httpd to act as a FTP server by listening on the ftp port. 13:51
dwalsh By default ftp is setup to only allow access to /var/ftp directory but you can alter these booleans to allow additional access. 13:51
dwalsh Fedora 11 has about 127 booleans now. 13:52
dwalsh Slide 7 and Slide 8 show you two different GUI tools used to manipulate booleans 13:53
dwalsh You can also use audit2allow -w (audit2why) to look at an AVC and see if a boolean would have allowed the access 13:53
dwalsh setroubleshoot uses this functionality to try to figure out if a boolean is ok 13:54
dwalsh The tool is actually attempting all possible booleans to see if any one would allow the access. 13:54
dwalsh In some cases multiple booleans are required to be turned on to allow access. 13:54
dwalsh For example allowing httpd scripts to be executed in a users home directory requires two or three booleans. 13:55
dwalsh Sadly audit2allow -w is not smart enough to figure this out. 13:55
dwalsh Again the management guide and other tools are helpful in figuring this out. 13:56
dwalsh Sline 9 13:56
dwalsh Slide 9 13:56
dwalsh Sadly SELINux Policy has bugs. 13:56
dwalsh Apps have bugs also 13:56
dwalsh Sometimes we release an app that causes new SELinux errors. 13:56
dwalsh We try not to do this but Fedora is an active community. 13:57
dwalsh I try not to add new confinement within a release. 13:57
dwalsh Once Fedora 11 is released, we tend to only loosen the policy. Add new allow rules, but not implement new confinement. 13:57
dwalsh And on RHEL releases we really frown on this. 13:58
dwalsh But What does an administrator do if SELinux or an APP are just broken. 13:58
dwalsh They labeling is correct. 13:58
dwalsh No Boolean allows the access? 13:58
dwalsh In this case the admin can fairly easily ad a custom policy module using audit2allow 13:58
dwalsh grep avc /var/log/audit/audit.log | audit2allow -M mypol 13:59
dwalsh This create a file called mypol.pp 13:59
dwalsh which can then be installed via semodule 13:59
dwalsh semodule -i mypol.pp 13:59
dwalsh mypol.te also gets created, 14:00
dwalsh You should really examine what this file is allowing, since it could be a security problem. 14:00
dwalsh For example allowing a confined app to write to etc_t is not a good idea since the app would be allowed to overwrite /etc/passwd 14:00
dwalsh But this method will allow you to customize policy to make the app just work. 14:01
dwalsh When you generate a policy using this method it creates a policy called mypol. if you execute the command later with different avcs but use the same name, you will override the first rules and replace them with new rules. 14:01
dwalsh So be carefull. 14:02
dwalsh Questions? 14:02
BounceCat "Slide 7 and Slide 8 show you two different GUI tools used to manipulate booleans" .. please name these tools 14:02
moixs Maybe a more general one 14:02
moixs How do you manage applications from external repositories, like RPM Fusion? Is the packager from RPM Fusion supposed to communicate with Fedora about SELinux policies? Does RPM Fusion maintain its own set of SELinux policies? 14:02
dwalsh BounceCat, system-config-selinux launces both. 14:03
BounceCat ok 14:03
dwalsh One is the default view, the second is created by going to the booleans screen and hitting lockdown. 14:03
BounceCat thx 14:03
dwalsh moixs, These apps may or maynot have policy defined for them. 14:04
dwalsh But they should all be able to run on a Fedora 11 box. 14:04
moixs So it's the packager's responsibility do do that? 14:04
dwalsh As I stated in an internal list, I think we can get the biggest piece of crap software to be able to run with SELinux in enforing mode. 14:05
moixs ok :p 14:05
dwalsh Of course this does not mean that the app will be secure... 14:05
dwalsh moixs, I will open a bugzilla or whatever with any app that is struggling with SELinux, or tell the bugreporter to do that 14:05
dwalsh Most problems with these software apps is badly built shared libraries. 14:06
dwalsh Which causes execmod violations. 14:06
dwalsh So we end up having to label them textrel_shlib_t w 14:06
moixs So you, in Fedora, will implement a "workaraound" even for an "external" application? 14:06
dwalsh which tells SELinux to now worry about a library being hacked, 14:06
dwalsh moixs, Yes, My goal is not to stop you from running you app. 14:07
moixs okay 14:07
dwalsh Otherwise you will dump us for some other unnamed distro. 14:07
dwalsh :^) 14:07
moixs It's more that I package an daemonized application in RPM Fusion and never cared about SELinux :p 14:07
dwalsh So in RHEL and Fedora by default apps run as an unconfined domain, and should be able to run unconstrained by SELinux 14:07
dwalsh moixs, Fine, It should run. 14:08
dwalsh Well let me complete the talk since I got to go to a Baseball tryout in 15 minutes. Not mine  :^( 14:08
linuxguru oh. hehe 14:08
underscores lol 14:08
dwalsh When I originally wrote the blog, I talked about fixing SELinux problems. but ignored the most important thing about SELinux 14:08
dwalsh How do I tell if I my machine was cracked. 14:09
dwalsh Well Sadly we have not done a good job of that, and I hope to make strides on this in F12. 14:09
dwalsh setroubleshoot is a tool that shows you selinux reported a problem. And it tries to give you a remedy of a solution. 14:10
dwalsh We want to build some plugins that look for obvious breakins. 14:10
dwalsh For example, no confined application on an SELinux box is allowed to turn off SELinux. 14:10
dwalsh So it would be real nice to ring alarms if httpd_t tries to setenforce 14:11
dwalsh If I was breaking into an SELInux system, the first thing I would try is to turn it off. 14:11
maximus007 well if anything but uid 0 tries it i think we have a problem and maybe even then 14:11
dwalsh Similarly loading kernel modules, writeing to security directories/files 14:11
dwalsh /etc/shadow 14:12
dwalsh /etc/selinux/* 14:12
dwalsh Kernel directories ... 14:12
maximus007 my question is how to prevent even root from turning it off, will i have to directly modify the policy? 14:12
dwalsh So we need to change setroubleshoot to give a clearer indication that we believe the machine is compromised, and take action. 14:13
dwalsh But you can try to read the AVCs or look at the rules generated by audit2allow to figure out if something very strange is going on. 14:13
dwalsh That is the end of the formal presentation I can stay for about 5 more minutes. 14:14
dwalsh Any other questions? 14:14
dwalsh Or did I miss any? 14:14
dwalsh Was this useful? 14:14
dgrift_ yes 14:14
mamurdian it would be nice if you could provide more such lessons 14:14
linuxguru sure it was dwalsh , very useful. got to know about some of the new stuff in selinux planned for f11. 14:15
underscores yes :) 14:15
BounceCat It was great Dan, thanks. I have 1 more question, but others can go first. 14:15
dwalsh Ok Maybe next month I will cover svirt. 14:15
pluvo Thanks dwalsh! 14:15
maximus007 how do i keep root from turning off selinux? I can confine root but root can unconfine himself can he not? so i think i have to modify policy directly 14:15
moixs Yep, thank you :) 14:16
mamurdian maximus007> i think you can give root another role 14:16
dwalsh maximus007, Read my blog about confined users/administrators. 14:16
dwalsh THe simple answer is you define a confined admin 14:16
dwalsh Another talk. 14:16
maximus007 ok thanks for the class, well done 14:16
Bighusky we had to install a newer package (rsync) on rhel5. Rsync and Rsyncd were not able to function properly, so we ended up using audit2allow -M to write a custom policy for this package. Was that the right approach or should we have used other means? 14:16
linuxguru maximus007, i don't think that requires changing the policy directly. semanage is your friend. 14:16
dwalsh Bighusky, yes 14:16
dgrift_ Bighusky didyou read man rsync_selinux first? 14:17
dwalsh Bighusky, Although send me your changes dwalsh@redhat.com And I will see about getting them upstream 14:17
dwalsh Bighusky, dgrift_ Is write that a boolean might have helped you 14:17
maximus007 linuxguru : yes but root is root and can generally run unconfined, so i'd have to remove the unconfined role i think but i will try it and see 14:17
DiscordianUK Thanks very much dwalsh 14:17
dwalsh rsync booleans in F11 14:18
dwalsh semanage boolean -l | grep rsync 14:18
dwalsh rsync_client -> off Allow rsync to run as a client 14:18
dwalsh rsync_export_all_ro -> off Allow rsync to export any files/directories read only. 14:18
dwalsh allow_rsync_anon_write -> off Allow rsync to modify public files used for public file transfer services. Files/Directories must be labeled public_content_rw_t. 14:18
dwalsh maximus007, You need to define an admin role and then don't give the admin the root password 14:18
dgrift_ BounceCat questions? 14:19
Bighusky dwalsh, dgrift, thanks very much, I have to admit that I didn't read man rsync_selinux. I will go back and give these suggestions a try. 14:19
BounceCat Subdirectories I've created in my home dir are either unconfined_u, system_u, or user_u, apparently at random. What has caused that and does it matter ? 14:19
dwalsh This confined admin would then log in as a confined user and use sudo to become root. 14:19
dwalsh By default all files are created and relabeled to system_u 14:19
dwalsh If you log onto a box as a particular user type 14:20
dwalsh user_u or confined_u 14:20
dwalsh user_u or uconfined_u 14:20
dwalsh Files created by you will end up using that user type 14:20
dwalsh user_u 14:20
maximus007 dwalsh, ok and thanks again excellent talk I have to get going myself but i will be sure to pester you about it in fedora-selinux :^) 14:20
dwalsh So user_u:user_r:user_t creates /home/dwalsh/foo 14:20
dwalsh will get created as user_u:object_r:user_home_t 14:21
dwalsh But the user componant of the file type is seldom used for denials. 14:21
dwalsh Bye. 14:21
dgrift_ thanks 14:21
BounceCat thank you 14:21
dgrift_ anyone have any questions feel free to join #fedora-selinux 14:22
linuxguru yes. over and out to #fedora-selinux 14:22
dgrift_ we might not be available right aways but we are glad if we can help 14:22
Bighusky than you very much and have a good sunday 14:23

Generated by irclog2html.py 2.7 by Marius Gedminas - find it at mg.pov.lt!