From: Daniel J Walsh <dwalsh@redhat.com>
To: Eric Paris <eparis@redhat.com>
Cc: Stephen Smalley <sds@tycho.nsa.gov>,
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 17:50:14 -0400 [thread overview]
Message-ID: <4E3B1416.5020504@redhat.com> (raw)
In-Reply-To: <4E3B0AB1.2050707@redhat.com>
[-- Attachment #1: Type: text/plain, Size: 685 bytes --]
On 08/04/2011 05:10 PM, Eric Paris wrote:
> On 08/04/2011 05:06 PM, Daniel J Walsh wrote:
>> On 08/04/2011 05:00 PM, Eric Paris wrote:
>
>>> I also question the use of /sys/fs/selinux/ but I'm not sure we
>>> have a good way to find that in a script..... Do we have one?
>>>
>>
>> grep selinuxfs /proc/self/mountinfo | awk '{ print $5 }'
>
> $ grep selinuxfs /proc/self/mountinfo | awk '{ print $5 }' /selinux
> /chroot/selinux
>
> -- This message was distributed to subscribers of the selinux mailing
> list. If you no longer wish to subscribe, send mail to
> majordomo@tycho.nsa.gov with the words "unsubscribe selinux" without
> quotes as the message.
>
>
Second attempt.
[-- Attachment #2: unlabeled_file.patch --]
[-- Type: text/plain, Size: 2280 bytes --]
diff --git a/policycoreutils/scripts/fixfiles b/policycoreutils/scripts/fixfiles
index 6de710a..899dce2 100755
--- a/policycoreutils/scripts/fixfiles
+++ b/policycoreutils/scripts/fixfiles
@@ -21,6 +21,23 @@
# 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() {
+ SELINUXMNT=`grep selinuxfs /proc/self/mountinfo | head -1 | awk '{ print $5 }'`
+ cat ${SELINUXMNT}/initial_contexts/unlabeled | secon -t
+}
+
+#
+# Get the default label for a file without a label
+#
+get_unlabeled_type() {
+ SELINUXMNT=`grep selinuxfs /proc/self/mountinfo | head -1 | awk '{ print $5 }'`
+ cat $SELINUXMNT/initial_contexts/file | secon -t
+}
+
+#
# Get all mount points that support seclabel
#
get_all_labeled_mounts() {
@@ -200,11 +217,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` || 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 {} \;
exit $?
}
next prev parent reply other threads:[~2011-08-04 21:50 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
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 [this message]
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=4E3B1416.5020504@redhat.com \
--to=dwalsh@redhat.com \
--cc=eparis@parisplace.org \
--cc=eparis@redhat.com \
--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.