~ubuntu-branches/ubuntu/precise/policycoreutils/precise

« back to all changes in this revision

Viewing changes to scripts/fixfiles

  • Committer: Bazaar Package Importer
  • Author(s): Bhavani Shankar
  • Date: 2009-08-20 19:55:18 UTC
  • mfrom: (3.2.4 sid)
  • Revision ID: james.westby@ubuntu.com-20090820195518-smvvensnl2ir4d0k
Tags: 2.0.69-2ubuntu1
* Merge from debian unstable, remaining changes: LP: #400111
  - load_policy/Makefile, debian/local.mk: move load_policy to /sbin
    ensuring it is available during early boot.
  - restorecond/restorecond.conf: adding more files from the /var/run
    pseudo fs.
  - debian/postinst: move restorecon to a higher startup level.

Show diffs side-by-side

added added

removed removed

Lines of Context:
3
3
#
4
4
# Script to restore labels on a SELinux box
5
5
#
6
 
# Copyright (C) 2004 Red Hat, Inc.
 
6
# Copyright (C) 2004-2009 Red Hat, Inc.
7
7
# Authors: Dan Walsh <dwalsh@redhat.com>
8
8
#
9
9
# This program is free software; you can redistribute it and/or modify
36
36
LOGGER=/usr/sbin/logger
37
37
SETFILES=/sbin/setfiles
38
38
RESTORECON=/sbin/restorecon
39
 
FILESYSTEMSRW=`mount | grep -v "context=" | egrep -v '\((|.*,)bind(,.*|)\)' | awk '/(ext[234]| ext4dev | gfs2 | xfs | jfs ).*\(rw/{print $3}';`
40
 
FILESYSTEMSRO=`mount | grep -v "context=" | egrep -v '\((|.*,)bind(,.*|)\)' | awk '/(ext[234]| ext4dev | gfs2 | xfs | jfs ).*\(ro/{print $3}';`
 
39
FILESYSTEMSRW=`mount | grep -v "context=" | egrep -v '\((|.*,)bind(,.*|)\)' | awk '/(ext[234]| ext4dev | gfs2 | xfs | jfs | btrfs ).*\(rw/{print $3}';`
 
40
FILESYSTEMSRO=`mount | grep -v "context=" | egrep -v '\((|.*,)bind(,.*|)\)' | awk '/(ext[234]| ext4dev | gfs2 | xfs | jfs | btrfs ).*\(ro/{print $3}';`
41
41
FILESYSTEMS="$FILESYSTEMSRW $FILESYSTEMSRO"
42
42
SELINUXTYPE="targeted"
43
43
if [ -e /etc/selinux/config ]; then
89
89
               fi; \
90
90
            done | \
91
91
        while read pattern ; do sh -c "find $pattern \
92
 
                      ! \( -fstype ext2 -o -fstype ext3 -o -fstype ext4 -o -fstype ext4dev  -o -fstype gfs2 -o -fstype jfs -o -fstype xfs \) -prune  -o \
 
92
                      ! \( -fstype ext2 -o -fstype ext3 -o -fstype ext4 -o -fstype ext4dev  -o -fstype gfs2 -o -fstype jfs -o -fstype xfs -o -fstype btrfs \) -prune  -o \
93
93
                      \( -wholename /home -o -wholename /root -o -wholename /tmp -wholename /dev \) -prune -o -print0"; \
94
94
                      done 2> /dev/null | \
95
95
         ${RESTORECON} $* -0 -f - 
122
122
fi
123
123
if [ ! -z "$RPMFILES" ]; then
124
124
    for i in `echo "$RPMFILES" | sed 's/,/ /g'`; do
125
 
        rpmlist $i | ${RESTORECON} ${OUTFILES} ${FORCEFLAG} $* -i -f - 2>&1 >> $LOGFILE
 
125
        rpmlist $i | ${RESTORECON} ${OUTFILES} ${FORCEFLAG} $* -R -i -f - 2>&1 >> $LOGFILE
126
126
    done
127
127
    exit $?
128
128
fi
129
129
if [ ! -z "$FILEPATH" ]; then
130
130
    if [ -x /usr/bin/find ]; then
131
131
        /usr/bin/find "$FILEPATH" \
132
 
            ! \( -fstype ext2 -o -fstype ext3 -o -fstype ext4 -o -fstype ext4dev -o -fstype gfs2 -o -fstype jfs -o -fstype xfs \) -prune  -o -print0 | \
 
132
            ! \( -fstype ext2 -o -fstype ext3 -o -fstype ext4 -o -fstype ext4dev -o -fstype gfs2 -o -fstype jfs -o -fstype xfs -o -fstype btrfs \) -prune  -o -print0 | \
133
133
            ${RESTORECON} ${OUTFILES} ${FORCEFLAG} $* -0 -f - 2>&1 >> $LOGFILE
134
134
    else
135
135
        ${RESTORECON} ${OUTFILES} ${FORCEFLAG} -R $* $FILEPATH 2>&1 >> $LOGFILE
144
144
    echo >&2 "fixfiles: No suitable file systems found"
145
145
fi
146
146
rm -rf /tmp/gconfd-* /tmp/pulse-* /tmp/orbit-*
147
 
find /tmp -context "*:file_t*" -exec chcon -t tmp_t {} \;
148
 
find /var/tmp -context "*:file_t*" -exec chcon -t tmp_t {} \;
 
147
find /tmp \( -context "*:file_t*" -o -context "*:unlabeled_t*" \) -exec chcon -t tmp_t {} \; || true
 
148
find /var/tmp \( -context "*:file_t*" -o -context "*:unlabeled_t*" \) -exec chcon -t tmp_t {} \; || true
149
149
exit $?
150
150
}
151
151
 
152
152
fullrelabel() {
153
153
    logit "Cleaning out /tmp"
154
 
    rm -rf /tmp/.??* /tmp/*
 
154
    find /tmp/ -mindepth 1 -print0 | xargs -0 /bin/rm -f
155
155
    LogReadOnly
156
156
    restore
157
157
}