Bug 904279

Summary: Patch to allow passing of -F from /.autorelabel to fixfiles restore to force relabeling of the entire system.
Product: [Fedora] Fedora Reporter: Daniel Walsh <dwalsh>
Component: initscriptsAssignee: Bill Nottingham <notting>
Status: CLOSED RAWHIDE QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: rawhideCC: iarlyy, jonathan, lnykryn, notting, plautrba, rvokal, vpavlin
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: initscripts-9.45-1.fc19 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2013-03-15 14:41:22 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
This patch implements the change.
none
autorelabel=-F in cmdline
none
Updated patch to handle command line options from the kernel.
none
Another pass using Bill's fix but also need to watch for "autorelabel" without the =
none
This patch goes along with the other patch to run "fixfiles -B onboot" instead of touch /.autorelabel
none
Fixed patch with Bill's suggested approach none

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.