Binary files nsapolicycoreutils/restorecon/restorecon and policycoreutils-1.17.6/restorecon/restorecon differ diff --exclude-from=exclude -N -u -r nsapolicycoreutils/restorecon/restorecon.c policycoreutils-1.17.6/restorecon/restorecon.c --- nsapolicycoreutils/restorecon/restorecon.c 2004-10-06 09:47:28.000000000 -0400 +++ policycoreutils-1.17.6/restorecon/restorecon.c 2004-10-21 17:11:08.741450432 -0400 @@ -8,11 +8,14 @@ * to match the specification returned by matchpathcon. * * USAGE: - * restorecon [-Rnv] pathname... + * restorecon [-FRnv] [-f inputfile ] [ -o outputfile ] pathname... * + * -R recurse * -n Do not change any file labels. * -v Show changes in file labels. - * -o filename save list of files with incorrect context + * -o filename save list of files with incorrect context + * -F Restorecon files that have permanant changes + * -f filename to read from for changing filecontext * * pathname... The file(s) to label * @@ -42,11 +45,12 @@ static char *progname; static int errors=0; static int recurse; +static int force=0; void usage(const char * const name) { fprintf(stderr, - "usage: %s [-Rnv] [-f filename | pathname... ]\n", name); + "usage: %s [-FRnv] [-f filename | pathname... ]\n", name); exit(1); } int restore(char *filename) { @@ -54,6 +58,7 @@ int retval=0; security_context_t scontext; security_context_t prev_context; + int perm=0; int len=strlen(filename); struct stat st; char path[PATH_MAX+1]; @@ -109,14 +114,25 @@ return 0; } retcontext=lgetfilecon(filename,&prev_context); - + if (retcontext >= 0 || errno == ENODATA) { if (retcontext < 0 || strcmp(prev_context,scontext) != 0) { - if (outfile) { - fprintf(outfile, "%s\n", filename); - } + lgetfileconperm(filename, &perm); + if (outfile && (!perm || force)) + fprintf(outfile, "%s\n", filename); if (change) { - retval=lsetfilecon(filename,scontext); + if (perm) { + if (force) { + lsetfileconperm(filename, 0); + retval=lsetfilecon(filename,scontext); + } else { + if (verbose) + fprintf(stderr,"%s did not reset context for %s, marked permanent\n", + progname, filename); + } + } else { + retval=lsetfilecon(filename,scontext); + } } if (retval<0) { fprintf(stderr,"%s set context %s->%s failed:'%s'\n", @@ -126,7 +142,7 @@ freecon(scontext); return 1; } else - if (verbose) + if (verbose && (!perm || force)) fprintf(stderr,"%s reset context %s->%s\n", progname, filename, scontext); } @@ -179,7 +195,7 @@ memset(buf,0, sizeof(buf)); - while ((opt = getopt(argc, argv, "Rnvf:o:")) > 0) { + while ((opt = getopt(argc, argv, "FRnvf:o:")) > 0) { switch (opt) { case 'n': change = 0; @@ -187,6 +203,9 @@ case 'R': recurse = 1; break; + case 'F': + force = 1; + break; case 'o': outfile = fopen(optarg,"w"); if (!outfile) { Binary files nsapolicycoreutils/restorecon/restorecon.o and policycoreutils-1.17.6/restorecon/restorecon.o differ diff --exclude-from=exclude -N -u -r nsapolicycoreutils/scripts/fixfiles policycoreutils-1.17.6/scripts/fixfiles --- nsapolicycoreutils/scripts/fixfiles 2004-10-06 09:47:28.000000000 -0400 +++ policycoreutils-1.17.6/scripts/fixfiles 2004-10-18 15:35:41.000000000 -0400 @@ -31,6 +31,8 @@ outfileFlag=0 OUTFILES="" logfileFlag=0 +LOGFILE=/dev/null +SYSLOGFLAG="-l" SETFILES=/usr/sbin/setfiles FILESYSTEMSRW=`mount | grep -v "context=" | egrep -v '\((|.*,)bind(,.*|)\)' | awk '/(ext[23]| xfs | reiserfs ).*\(rw/{print $3}';` FILESYSTEMSRO=`mount | grep -v "context=" | egrep -v '\((|.*,)bind(,.*|)\)' | awk '/(ext[23]| xfs | reiserfs ).*\(ro/{print $3}';` @@ -44,50 +46,54 @@ FC=/etc/security/selinux/file_contexts fi +logit () { +if [ $logfileFlag = 0 ]; then + logger -i $1 +else + echo $1 >> $LOGFILE +fi +} checkLabels () { -echo "logging to $LOGFILE" if [ ! -z "$1" ]; then for i in `echo $1 | sed 's/,/ /g'`; do - rpm -q -l $i | restorecon ${OUTFILES} -n -v -f - 2>&1 > $LOGFILE + rpm -q -l $i | restorecon ${OUTFILES} -n -v -f - 2>&1 >> $LOGFILE done else if [ ! -z "$FILESYSTEMSRO" ]; then - echo "Warning: Skipping the following R/O filesystems:" - echo "$FILESYSTEMSRO" + logit "Warning: Skipping the following R/O filesystems:" + logit "$FILESYSTEMSRO" fi - ${SETFILES} ${OUTFILES} -n -v ${FC} ${FILESYSTEMSRW} 2>&1 > $LOGFILE + ${SETFILES} ${OUTFILES} ${SYSLOGFLAG} -n -v ${FC} ${FILESYSTEMSRW} 2>&1 >> $LOGFILE fi } restoreLabels () { -echo "logging to $LOGFILE" if [ ! -z "$1" ]; then for i in `echo $1 | sed 's/,/ /g'`; do - rpm -q -l $i | restorecon ${OUTFILES} -v -f - 2>&1 > $LOGFILE + rpm -q -l $i | restorecon ${OUTFILES} -v -f - 2>&1 >> $LOGFILE done else if [ ! -z "$FILESYSTEMSRO" ]; then - echo "Warning: Skipping the following R/O filesystems:" - echo "$FILESYSTEMSRO" + logit "Warning: Skipping the following R/O filesystems:" + logit "$FILESYSTEMSRO" fi - ${SETFILES} ${OUTFILES} -v ${FC} ${FILESYSTEMS} 2>&1 > $LOGFILE + ${SETFILES} ${OUTFILES} ${SYSLOGFLAG} -v ${FC} ${FILESYSTEMS} 2>&1 >> $LOGFILE fi } relabel() { -echo "logging to $LOGFILE" -echo "Cleaning out /tmp" +logit "Cleaning out /tmp" rm -rf /tmp/.??* /tmp/* if [ ! -z "$1" ]; then for i in `echo $1 | sed 's/,/ /g'`; do - rpm -q -l $i | restorecon ${OUTFILES} -v -f - 2>&1 > $LOGFILE + rpm -q -l $i | restorecon ${OUTFILES} -v -f - 2>&1 >> $LOGFILE done else if [ ! -z "$FILESYSTEMSRO" ]; then - echo "Warning: Skipping the following R/O filesystems:" - echo "$FILESYSTEMSRO" + logit "Warning: Skipping the following R/O filesystems:" + logit "$FILESYSTEMSRO" fi - ${SETFILES} ${OUTFILES} -v ${FC} ${FILESYSTEMS} 2>&1 > $LOGFILE + ${SETFILES} ${OUTFILES} ${SYSLOGFLAG} -v ${FC} ${FILESYSTEMS} 2>&1 >> $LOGFILE fi } relabelCheck() { @@ -129,6 +135,8 @@ fi if [ $logfileFlag = 2 ]; then LOGFILE="$i" + echo > $LOGFILE + SYSLOGFLAG="" logfileFlag=1 continue fi @@ -165,13 +173,6 @@ exit 1 fi -if [ $logfileFlag = 0 ]; then - LOGFILE=`mktemp /var/tmp/fixfiles.log.XXXXXXXXXX` - if [ ! -w $LOGFILE ] ; then - exit 1 - fi -fi - if [ $checkFlag = 1 ]; then checkLabels $rpmFiles fi diff --exclude-from=exclude -N -u -r nsapolicycoreutils/scripts/fixfiles.cron policycoreutils-1.17.6/scripts/fixfiles.cron --- nsapolicycoreutils/scripts/fixfiles.cron 2004-09-10 11:25:57.000000000 -0400 +++ policycoreutils-1.17.6/scripts/fixfiles.cron 2004-10-18 15:35:41.000000000 -0400 @@ -21,7 +21,8 @@ mail ${CRONMAILTO} -s "Invalid File Contexts" < $OUTFILE rm -f $OUTFILE else - mail ${CRONMAILTO} -s "Invalid File Contexts listed in $OUTFILE" < /dev/null + MESSAGE="Invalid File Contexts listed in $OUTFILE" + mail ${CRONMAILTO} -s "Invalid File Contexts" <<< $MESSAGE fi else rm -f $OUTFILE diff --exclude-from=exclude -N -u -r nsapolicycoreutils/scripts/Makefile policycoreutils-1.17.6/scripts/Makefile --- nsapolicycoreutils/scripts/Makefile 2004-09-10 11:25:57.000000000 -0400 +++ policycoreutils-1.17.6/scripts/Makefile 2004-10-18 15:35:41.000000000 -0400 @@ -12,7 +12,7 @@ -mkdir -p $(BINDIR) install -m 755 $(TARGETS) $(BINDIR) install -m 755 fixfiles $(DESTDIR)/sbin - install -D -m 755 fixfiles.cron $(DESTDIR)/etc/cron.daily/fixfiles.cron + install -D -m 755 fixfiles.cron $(DESTDIR)/etc/cron.weekly/fixfiles.cron -mkdir -p $(MANDIR)/man8 install -m 644 fixfiles.8.gz $(MANDIR)/man8/ Binary files nsapolicycoreutils/setfiles/setfiles and policycoreutils-1.17.6/setfiles/setfiles differ diff --exclude-from=exclude -N -u -r nsapolicycoreutils/setfiles/setfiles.c policycoreutils-1.17.6/setfiles/setfiles.c --- nsapolicycoreutils/setfiles/setfiles.c 2004-10-06 09:47:28.000000000 -0400 +++ policycoreutils-1.17.6/setfiles/setfiles.c 2004-10-21 17:17:30.557405584 -0400 @@ -24,6 +24,7 @@ * -s Use stdin for a list of files instead of searching a partition. * -v Show changes in file labels. * -W Warn about entries that have no matching file. + * -F set file context even those that have permanant changes * -o filename write out file names with wrong context. * * spec_file The specification file. @@ -96,6 +97,7 @@ static int use_stdin = 0; static int verbose = 0; static int log = 0; +static int force = 1; static int warn_no_match = 0; static char *rootpath = NULL; static int rootpathlen = 0; @@ -603,6 +605,7 @@ struct stat my_sb; int i, ret; char *context; + int perm=0; /* Skip the extra slash at the beginning, if present. */ if (file[0] == '/' && file[1] == '/') @@ -675,7 +678,8 @@ return 0; } - if (verbose) { + lgetfileconperm(my_file, &perm); + if (verbose && (!perm || force)) { /* If we're just doing "-v", trim out any relabels where * the user has changed but the role and type are the * same. For "-vv", emit everything. */ @@ -686,13 +690,13 @@ } } - if (log && + if (log && (!perm || force) && !only_changed_user(context, spec_arr[i].context)) { syslog(LOG_INFO, "relabeling %s from %s to %s\n", my_file, context, spec_arr[i].context); } - if (outfile && + if (outfile && (!perm || force) && !only_changed_user(context, spec_arr[i].context)) fprintf(outfile, "%s\n", my_file); @@ -701,7 +705,7 @@ /* * Do not relabel the file if -n was used. */ - if (!change) + if (!change || (perm && !force)) return 0; /* @@ -714,6 +718,7 @@ progname, my_file, spec_arr[i].context); return 0; } + lsetfileconperm(my_file, 0); return 0; } @@ -775,7 +780,7 @@ memset(excludeArray,0, sizeof(excludeArray)); /* Process any options. */ - while ((opt = getopt(argc, argv, "c:dlnqrsvWe:o:")) > 0) { + while ((opt = getopt(argc, argv, "Fc:dlnqrsvWe:o:")) > 0) { switch (opt) { case 'c': { @@ -837,6 +842,9 @@ case 'l': log = 1; break; + case 'F': + force = 1; + break; case 'n': change = 0; break; Binary files nsapolicycoreutils/setfiles/setfiles.o and policycoreutils-1.17.6/setfiles/setfiles.o differ