From: Daniel J Walsh <dwalsh@redhat.com>
To: Stephen Smalley <sds@tycho.nsa.gov>
Cc: Eric Paris <eparis@parisplace.org>, selinux@tycho.nsa.gov
Subject: Re: [PATCH 029/155] policycoreutils: fixfiles clean up /var/run and
Date: Thu, 04 Aug 2011 16:26:35 -0400 [thread overview]
Message-ID: <4E3B007B.1020502@redhat.com> (raw)
In-Reply-To: <1312486409.20973.66.camel@moss-pluto>
[-- Attachment #1: Type: text/plain, Size: 401 bytes --]
On 08/04/2011 03:33 PM, Stephen Smalley wrote:
> On Thu, 2011-08-04 at 13:59 -0400, Eric Paris wrote:
>> well I guess [selinuxfs]/initial_contexts/unlabeled works for the
>> first part, but how to come up with the lib_t/var_t I don't
>> know.... more initial sids :)
>
> chcon --reference=/lib ... chcon --reference=/var ...
>
> Or: chcon `matchpathcon /lib` ...
>
>
How about this patch...
[-- Attachment #2: unlabeled_file.patch --]
[-- Type: text/plain, Size: 2412 bytes --]
diff --git a/policycoreutils/scripts/fixfiles b/policycoreutils/scripts/fixfiles
index 6de710a..9c1e6dd 100755
--- a/policycoreutils/scripts/fixfiles
+++ b/policycoreutils/scripts/fixfiles
@@ -21,6 +21,31 @@
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
+# Get the default label returned from the kernel for a file with a lable the
+# kernel does not understand
+#
+get_undefined_type() {
+ if [ -e /sys/fs/selinux/initial_contexts/unlabeled ]; then
+ UNKNOWN_LABEL=`cat /sys/fs/selinux/initial_contexts/unlabeled`
+ else
+ UNKNOWN_LABEL=`cat /selinux/initial_contexts/unlabeled`
+ fi
+ secon -t $UNKNOWN_LABEL
+}
+
+#
+# Get the default label for a file without a label
+#
+get_unlabeled_type() {
+ if [ -e /sys/fs/selinux/initial_contexts/unlabeled ]; then
+ NOLABEL=`cat /sys/fs/selinux/initial_contexts/file`
+ else
+ NOLABEL=`cat /selinux/initial_contexts/file`
+ fi
+ secon -t $NOLABEL
+}
+
+#
# Get all mount points that support seclabel
#
get_all_labeled_mounts() {
@@ -200,11 +225,13 @@ fi
${SETFILES} -q ${SYSLOGFLAG} ${FORCEFLAG} $* ${FC} ${FILESYSTEMSRW} 2>&1 | cat >> $LOGFILE
rm -rf /tmp/gconfd-* /tmp/pulse-* /tmp/orbit-* $TEMPFCFILE
-find /tmp \( -context "*:file_t*" -o -context "*:unlabeled_t*" \) \( -type s -o -type p \) -delete
-find /tmp \( -context "*:file_t*" -o -context "*:unlabeled_t*" \) -exec chcon -t tmp_t {} \;
-find /var/tmp \( -context "*:file_t*" -o -context "*:unlabeled_t*" \) -exec chcon -t tmp_t {} \;
-find /var/run \( -context "*:file_t*" -o -context "*:unlabeled_t*" \) -exec chcon -t var_run_t {} \;
-[ -e /var/lib/debug ] && find /var/lib/debug \( -context "*:file_t*" -o -context "*:unlabeled_t*" \) -exec chcon -t lib_t {} \;
+undefined=`get_undefined_type`
+unlabeled=`get_unlabeled_type`
+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 {} \;
exit $?
}
next prev parent reply other threads:[~2011-08-04 20:26 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-08-03 20:56 [PATCH 029/155] policycoreutils: fixfiles clean up /var/run and Daniel J Walsh
2011-08-04 14:56 ` Stephen Smalley
2011-08-04 16:42 ` Daniel J Walsh
2011-08-04 17:33 ` Eric Paris
2011-08-04 19:16 ` Christopher J. PeBenito
[not found] ` <CACLa4puk2gO=aV=oNj-Kmj=eSmYmquX0skKoCxso6o9tWcf_Ng@mail.gmail.com>
2011-08-04 19:33 ` Stephen Smalley
2011-08-04 20:26 ` Daniel J Walsh [this message]
2011-08-04 21:00 ` Eric Paris
2011-08-04 21:06 ` Daniel J Walsh
2011-08-04 21:10 ` Eric Paris
2011-08-04 21:50 ` Daniel J Walsh
2011-08-05 14:18 ` Stephen Smalley
2011-08-05 14:45 ` Daniel J Walsh
2011-08-05 15:10 ` Eric Paris
2011-08-05 15:34 ` Daniel J Walsh
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4E3B007B.1020502@redhat.com \
--to=dwalsh@redhat.com \
--cc=eparis@parisplace.org \
--cc=sds@tycho.nsa.gov \
--cc=selinux@tycho.nsa.gov \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.