Bug 904279 - Patch to allow passing of -F from /.autorelabel to fixfiles restore to force relabeling of the entire system.
Summary: Patch to allow passing of -F from /.autorelabel to fixfiles restore to force ...
Keywords:
Status: CLOSED RAWHIDE
Alias: None
Product: Fedora
Classification: Fedora
Component: initscripts
Version: rawhide
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Bill Nottingham
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2013-01-25 22:50 UTC by Daniel Walsh
Modified: 2014-03-17 03:33 UTC (History)
7 users (show)

Fixed In Version: initscripts-9.45-1.fc19
Clone Of:
Environment:
Last Closed: 2013-03-15 14:41:22 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)
This patch implements the change. (628 bytes, patch)
2013-01-25 22:51 UTC, Daniel Walsh
no flags Details | Diff
autorelabel=-F in cmdline (596 bytes, patch)
2013-01-30 14:04 UTC, Václav Pavlín
no flags Details | Diff
Updated patch to handle command line options from the kernel. (900 bytes, patch)
2013-01-30 16:05 UTC, Daniel Walsh
no flags Details | Diff
Another pass using Bill's fix but also need to watch for "autorelabel" without the = (805 bytes, patch)
2013-02-01 14:49 UTC, Daniel Walsh
no flags Details | Diff
This patch goes along with the other patch to run "fixfiles -B onboot" instead of touch /.autorelabel (328 bytes, patch)
2013-02-01 14:59 UTC, Daniel Walsh
no flags Details | Diff
Fixed patch with Bill's suggested approach (846 bytes, patch)
2013-02-04 13:41 UTC, Václav Pavlín
no flags Details | Diff

Description Daniel Walsh 2013-01-25 22:50:36 UTC
The default relabeling of the system only effects the Type Field in targeted policy.  If you switch from targeted to MLS we want the user to pass the -F flag to the relabel.

I am changin fixfiles onboot to record the options passed in, into the /.autorelabel command.  I need fedora-autorelabel to pass them onto fixfiles restore.

Comment 1 Daniel Walsh 2013-01-25 22:51:24 UTC
Created attachment 687739 [details]
This patch implements the change.

We need this to get into RHEL7.

Comment 2 Václav Pavlín 2013-01-28 08:56:45 UTC
Patch commited to upstream -> http://git.fedorahosted.org/cgit/initscripts.git/commit/?id=a572110dfafc51e5b5eee8fcfd1e0ca59f94202c -> post

Comment 3 Bill Nottingham 2013-01-28 16:50:02 UTC
This doesn't handle autorelabeling based on the kernel commandline - how should we do this?

Comment 4 Daniel Walsh 2013-01-28 17:18:48 UTC
I guess we could do autorelabel=-F, and then have the scripts handle this.

Comment 5 Bill Nottingham 2013-01-28 19:09:19 UTC
-F isn't the default because it touches everything, making it a much more time-consuming operation, correct?

Comment 6 Daniel Walsh 2013-01-28 19:24:50 UTC
No it is more about hamering MCS/MLS Separation.  For example running -F on an openshift machine would force all of the geers to have the same MCS Label, not something we want. Similarly as we move forward with more and more MCS Separation, sandbox, Security Containers, OpenShift, VMs we want to preserve these labels if at all possible.

Comment 7 Václav Pavlín 2013-01-30 14:04:24 UTC
Created attachment 690391 [details]
autorelabel=-F in cmdline

So if we want to have an option to pass the -F argument from the kernel cmdline, I would like to propose this patch. What do you think?

Comment 8 Daniel Walsh 2013-01-30 15:49:59 UTC
I am working on a little more elaborate patch.

I think you take whatever the value is and stick it in options.

if strstr "$cmdline" 'autorelabel'  ; then
   for i in $cmdline; do 
       if strstr $i autorelabel; then OPTIONS=$i; fi
   done; 
else
    OPTIONS=`cat /.autorelabel`
fi

/sbin/fixfiles $OPTIONS restore > /dev/null 2>&1

Comment 9 Daniel Walsh 2013-01-30 16:05:27 UTC
Created attachment 690477 [details]
Updated patch to handle command line options from the kernel.

I believe this patch will pass any options passed on the command line to autorelabel to the fixfiles restore command.

autorelabel
autorelabel=-F
autorelabel=-B

Should all work.

Comment 10 Lukáš Nykrýn 2013-01-31 10:02:58 UTC
Since there is an eval in your patch, don't you think it can be used to execute some additional command through autorelabel option?

Comment 11 Daniel Walsh 2013-01-31 15:49:23 UTC
Bill is that a concern?  IE If I can get to the kernel boot prompt, I can basically take the machine over.

If this is not allowed, then we I can change it to specify individual commands.

Comment 12 Bill Nottingham 2013-01-31 19:34:17 UTC
I'd just do it via shell commands other than eval i.e.:

for item in $(cat /proc/cmdline ) ; do
  [ ${item} != ${item##autorelabel} ] && autorelabel=${item##autorelabel}
done

Or something along those lines.

Comment 13 Daniel Walsh 2013-02-01 14:49:40 UTC
Created attachment 691605 [details]
Another pass using Bill's fix but also need to watch for "autorelabel" without the =

Comment 14 Daniel Walsh 2013-02-01 14:59:43 UTC
Created attachment 691606 [details]
This patch goes along with the other patch to run "fixfiles -B onboot" instead of touch /.autorelabel

fixfiles -B onboot 

Will record the date that the command was executed in the .autorelabel file.

# fixfiles -B onboot
# cat /.autorelabel 
-N 2013-02-01

Then when the system boots with SELinux enabled, the fixfiles script will search for all files created since this date. (inclusive).

Comment 15 Václav Pavlín 2013-02-04 13:41:14 UTC
Created attachment 692721 [details]
Fixed patch with Bill's suggested approach

Your patch looks sane, however the for cycle was there twice. I removed the outer one, so it should be ok now.


Note You need to log in before you can comment on or make changes to this bug.