Skip to contentSkip to conversation

Change fixfiles to use file_context.local if it exists.

PATCH Daniel J Walsh 2 participants 4 messages Jan 24, 2005 – Jan 25, 2005 SELinux security module

lore
Share & tools
lore
#0 lore raw
scripts/fixfiles +9 -1
diff --exclude-from=exclude -N -u -r nsapolicycoreutils/scripts/fixfiles policycoreutils-1.21.1/scripts/fixfiles
@@ -37,11 +37,19 @@
 SELINUXTYPE="targeted"
 if [ -e /etc/selinux/config ]; then
     . /etc/selinux/config
-    FC=/etc/selinux/${SELINUXTYPE}/contexts/files/file_contexts
+    FC=`mktemp /var/tmp/file_contexts.XXXXXX`
+    cat /etc/selinux/${SELINUXTYPE}/contexts/files/file_contexts /etc/selinux/${SELINUXTYPE}/contexts/files/file_contexts.local > $FC 2> /dev/null
 else
     FC=/etc/security/selinux/file_contexts
 fi
 
+cleanup() {
+    if [ -e /etc/selinux/config -a -f "$FC" ]; then
+	rm -f $FC
+    fi
+}
+trap "cleanup" 0 1 2 3 13 15
+
 #
 # Log to either syslog or a LOGFILE
 #
#1 lore raw

scripts/fixfiles line 41

Quoted 10 lines · Daniel J Walsh

diff --exclude-from=exclude -N -u -r nsapolicycoreutils/scripts/fixfiles policycoreutils-1.21.1/scripts/fixfiles

scripts/fixfiles +2 -1
@@ -37,11 +37,19 @@
 SELINUXTYPE="targeted"
 if [ -e /etc/selinux/config ]; then
     . /etc/selinux/config
-    FC=/etc/selinux/${SELINUXTYPE}/contexts/files/file_contexts
+    FC=`mktemp /var/tmp/file_contexts.XXXXXX`
+    cat /etc/selinux/${SELINUXTYPE}/contexts/files/file_contexts /etc/selinux/${SELINUXTYPE}/contexts/files/file_contexts.local > $FC 2> /dev/null

Rather than using a temporary file in /var/tmp, I'd recommend creating it in the same parent directory as the existing file_contexts configuration (i.e. /etc/selinux/${SELINUXTYPE}/contexts/files). setfiles_t cannot read temporary files, and we don't especially want to allow it to do so (to protect against low integrity input).

Signature · 8 lines
Stephen Smalley <[email protected]>
National Security Agency


--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to [email protected] with
the words "unsubscribe selinux" without quotes as the message.
#2 lore raw
Quoted 12 lines · Stephen Smalley
Quoted 9 lines · Daniel J Walsh

diff --exclude-from=exclude -N -u -r nsapolicycoreutils/scripts/fixfiles policycoreutils-1.21.1/scripts/fixfiles

scripts/fixfiles +0 -0
@@ -37,11 +37,19 @@

SELINUXTYPE="targeted"
if [ -e /etc/selinux/config ]; then
. /etc/selinux/config

scripts/fixfiles +1 -1
-    FC=/etc/selinux/${SELINUXTYPE}/contexts/files/file_contexts
+    FC=`mktemp /var/tmp/file_contexts.XXXXXX`
Quoted 11 lines
Quoted 3 lines

+ cat /etc/selinux/${SELINUXTYPE}/contexts/files/file_contexts /etc/selinux/${SELINUXTYPE}/contexts/files/file_contexts.local > $FC 2> /dev/null

Rather than using a temporary file in /var/tmp, I'd recommend creating
it in the same parent directory as the existing file_contexts
configuration (i.e. /etc/selinux/${SELINUXTYPE}/contexts/files). setfiles_t cannot read temporary files, and we don't especially want to allow it to do so (to protect against low integrity input).

Ah good point, change to

/etc/selinux/${SELINUXTYPE}/contexts/files

scripts/fixfiles +9 -1
diff --exclude-from=exclude -N -u -r nsapolicycoreutils/scripts/fixfiles policycoreutils-1.21.1/scripts/fixfiles
@@ -37,11 +37,19 @@
 SELINUXTYPE="targeted"
 if [ -e /etc/selinux/config ]; then
     . /etc/selinux/config
-    FC=/etc/selinux/${SELINUXTYPE}/contexts/files/file_contexts
+    FC=`mktemp /etc/selinux/${SELINUXTYPE}/contexts/files/file_context.XXXXXX`
+    cat /etc/selinux/${SELINUXTYPE}/contexts/files/file_contexts /etc/selinux/${SELINUXTYPE}/contexts/files/file_contexts.local > $FC 2> /dev/null
 else
     FC=/etc/security/selinux/file_contexts
 fi
 
+cleanup() {
+    if [ -e /etc/selinux/config -a -f "$FC" ]; then
+	rm -f $FC
+    fi
+}
+trap "cleanup" 0 1 2 3 13 15
+
 #
 # Log to either syslog or a LOGFILE
 #
#3 lore raw
Quoted 3 lines · Daniel J Walsh

Ah good point, change to

/etc/selinux/${SELINUXTYPE}/contexts/files

Thanks, merged into sourceforge CVS as of policycoreutils 1.21.4.

Signature · 8 lines
Stephen Smalley <[email protected]>
National Security Agency


--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to [email protected] with
the words "unsubscribe selinux" without quotes as the message.