Skip to contentSkip to conversation

policycoreutils/fixfiles: do not dereference link files in tmp

PATCH Applied Vit Mojzis 2 participants 2 messages Jun 16, 2017 SELinux security module

lore
Share & tools
lore

Vit Mojzis

author
#0 lore raw

PATCH 1/1 policycoreutils/fixfiles: do not dereference link files in tmp

Files in /tmp, /var/tmp, /var/run and /var/lib/debug labeled as unlabeled_t or undefined_t are relabeled to match corresponding directory label. Stop dereferencing link files in these folders in order not to accidentally change label of other files in the system.

---
 policycoreutils/scripts/fixfiles | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
policycoreutils/scripts/fixfiles +4 -4
index 0eeeea4..1aa330f 100755
@@ -255,10 +255,10 @@ case "$RESTORE_MODE" in
 	UNDEFINED=`get_undefined_type` || exit $?
 	UNLABELED=`get_unlabeled_type` || exit $?
 	find /tmp \( -context "*:${UNLABELED}*" -o -context "*:${UNDEFINED}*" \) \( -type s -o -type p \) -delete
-	find /tmp \( -context "*:${UNLABELED}*" -o -context "*:${UNDEFINED}*" \) -exec chcon --reference /tmp {} \;
-	find /var/tmp \( -context "*:${UNLABELED}*" -o -context "*:${UNDEFINED}*" \) -exec chcon --reference /var/tmp {} \;
-	find /var/run \( -context "*:${UNLABELED}*" -o -context "*:${UNDEFINED}*" \) -exec chcon --reference /var/run {} \;
-	[ ! -e /var/lib/debug ] || find /var/lib/debug \( -context "*:${UNLABELED}*" -o -context "*:${UNDEFINED}*" \) -exec chcon --reference /lib {} \;
+	find /tmp \( -context "*:${UNLABELED}*" -o -context "*:${UNDEFINED}*" \) -exec chcon --no-dereference --reference /tmp {} \;
+	find /var/tmp \( -context "*:${UNLABELED}*" -o -context "*:${UNDEFINED}*" \) -exec chcon --no-dereference --reference /var/tmp {} \;
+	find /var/run \( -context "*:${UNLABELED}*" -o -context "*:${UNDEFINED}*" \) -exec chcon --no-dereference --reference /var/run {} \;
+	[ ! -e /var/lib/debug ] || find /var/lib/debug \( -context "*:${UNLABELED}*" -o -context "*:${UNDEFINED}*" \) -exec chcon --no-dereference --reference /lib {} \;
     ;;
 esac
 }
Signature · 1 line
2.9.4
#1 lore raw
Quoted 9 lines · Vit Mojzis

Files in /tmp, /var/tmp, /var/run and /var/lib/debug labeled as unlabeled_t or undefined_t are relabeled to match corresponding directory label. Stop dereferencing link files in these folders in order not to accidentally change label of other files in the system.

Thanks, applied.

Quoted 38 lines

---
 policycoreutils/scripts/fixfiles | 8 ++++----

 1 file changed, 4 insertions(+), 4 deletions(-)
policycoreutils/scripts/fixfiles +0 -0
index 0eeeea4..1aa330f 100755
@@ -255,10 +255,10 @@ case "$RESTORE_MODE" in
 	UNDEFINED=`get_undefined_type` || exit $?
 	UNLABELED=`get_unlabeled_type` || exit $?

  find /tmp \( -context "*:${UNLABELED}*" -o -context "*:${UNDEFINED}*" \) \( -type s -o -type p \) -delete

policycoreutils/scripts/fixfiles +0 -1
-	find /tmp \( -context "*:${UNLABELED}*" -o -context

"*:${UNDEFINED}*" \) -exec chcon --reference /tmp {} \;

policycoreutils/scripts/fixfiles +0 -1
-	find /var/tmp \( -context "*:${UNLABELED}*" -o -context

"*:${UNDEFINED}*" \) -exec chcon --reference /var/tmp {} \;

policycoreutils/scripts/fixfiles +0 -1
-	find /var/run \( -context "*:${UNLABELED}*" -o -context

"*:${UNDEFINED}*" \) -exec chcon --reference /var/run {} \;

policycoreutils/scripts/fixfiles +0 -1
-	[ ! -e /var/lib/debug ] || find /var/lib/debug \( -context

"*:${UNLABELED}*" -o -context "*:${UNDEFINED}*" \) -exec chcon -- reference /lib {} \;

policycoreutils/scripts/fixfiles +1 -0
+	find /tmp \( -context "*:${UNLABELED}*" -o -context

"*:${UNDEFINED}*" \) -exec chcon --no-dereference --reference /tmp {} \;

policycoreutils/scripts/fixfiles +1 -0
+	find /var/tmp \( -context "*:${UNLABELED}*" -o -context

"*:${UNDEFINED}*" \) -exec chcon --no-dereference --reference /var/tmp {} \;

policycoreutils/scripts/fixfiles +1 -0
+	find /var/run \( -context "*:${UNLABELED}*" -o -context

"*:${UNDEFINED}*" \) -exec chcon --no-dereference --reference /var/run {} \;

policycoreutils/scripts/fixfiles +1 -0
+	[ ! -e /var/lib/debug ] || find /var/lib/debug \( -context

"*:${UNLABELED}*" -o -context "*:${UNDEFINED}*" \) -exec chcon --no- dereference --reference /lib {} \;
     ;;
 esac
 }