diff --git a/policycoreutils-rhat.patch b/policycoreutils-rhat.patch index beef9b9..e8a8ba6 100644 --- a/policycoreutils-rhat.patch +++ b/policycoreutils-rhat.patch @@ -1,5 +1,144 @@ +--- policycoreutils-1.17.5/restorecon/restorecon.c.rhat 2004-08-30 11:46:46.000000000 -0400 ++++ policycoreutils-1.17.5/restorecon/restorecon.c 2004-09-24 19:14:23.515031544 -0400 +@@ -8,7 +8,7 @@ + * to match the specification returned by matchpathcon. + * + * USAGE: +- * restorecon [-nv] pathname... ++ * restorecon [-Rnv] pathname... + * + * -n Do not change any file labels. + * -v Show changes in file labels. +@@ -33,19 +33,25 @@ + #include + #include + #include ++#define __USE_XOPEN_EXTENDED 1 /* nftw */ ++#include + +-char *progname; ++static int change=1; ++static int verbose=0; ++static FILE *outfile=NULL; ++static char *progname; ++static int errors=0; ++static int recurse; + + void usage(const char * const name) + { + fprintf(stderr, +- "usage: %s [-nv] [-f filename | pathname... ]\n", name); ++ "usage: %s [-Rnv] [-f filename | pathname... ]\n", name); + exit(1); + } +-int restore(char *filename, int change, int verbose, FILE *outfile) { ++int restore(char *filename) { + int retcontext=0; + int retval=0; +- int errors=0; + security_context_t scontext; + security_context_t prev_context; + int len=strlen(filename); +@@ -135,15 +141,36 @@ + freecon(scontext); + return errors; + } ++static int apply_spec(const char *file, ++ const struct stat *sb_unused, int flag, struct FTW *s_unused) ++{ ++ if (flag == FTW_DNR) { ++ fprintf(stderr, "%s: unable to read directory %s\n", ++ progname, file); ++ return 0; ++ } ++ errors=errors+restore((char *)file); ++ return 0; ++} ++void process(char *buf) { ++ if (recurse) { ++ if (nftw ++ (buf, apply_spec, 1024, FTW_PHYS | FTW_MOUNT)) { ++ fprintf(stderr, ++ "%s: error while labeling files under %s\n", ++ progname, buf); ++ exit(1); ++ } ++ } ++ else ++ errors=errors+restore(buf); ++} + int main(int argc, char **argv) { + int i=0; + char *file_name=NULL; + int errors=0; +- int change=1; +- int verbose=0; + int file=0; + int opt; +- FILE *outfile=NULL; + char buf[PATH_MAX]; + + progname=argv[0]; +@@ -152,11 +179,14 @@ + + memset(buf,0, sizeof(buf)); + +- while ((opt = getopt(argc, argv, "nvf:o:")) > 0) { ++ while ((opt = getopt(argc, argv, "Rnvf:o:")) > 0) { + switch (opt) { + case 'n': + change = 0; + break; ++ case 'R': ++ recurse = 1; ++ break; + case 'o': + outfile = fopen(optarg,"w"); + if (!outfile) { +@@ -187,14 +217,14 @@ + } + while(fgets(buf,PATH_MAX,f)) { + buf[strlen(buf)-1]=0; +- errors=errors+restore(buf, change, verbose, outfile); ++ process(buf); + } + if (strcmp(file_name,"-")!=0) + fclose(f); + } + else { + for (i=optind; i< argc; i++) { +- errors=errors+restore(argv[i], change, verbose, outfile); ++ process(argv[i]); + } + } + if (outfile) +--- policycoreutils-1.17.5/restorecon/restorecon.8.rhat 2004-08-30 11:46:46.000000000 -0400 ++++ policycoreutils-1.17.5/restorecon/restorecon.8 2004-09-24 19:23:38.235701184 -0400 +@@ -4,10 +4,10 @@ + + .SH "SYNOPSIS" + .B restorecon +-.I [\-o outfilename ] [\-n] [\-v] pathname... ++.I [\-o outfilename ] [\-R] [\-n] [\-v] pathname... + .P + .B restorecon +-.I \-f infilename [\-o outfilename ] [\-n] [\-v] ++.I \-f infilename [\-o outfilename ] [\-R] [\-n] [\-v] + + .SH "DESCRIPTION" + This manual page describes the +@@ -26,6 +26,9 @@ + .B \-f infilename + infilename contains a list of files to be processed by application. Use \- for stdin. + .TP ++.B \-R ++change files and directories file labels recursively ++.TP + .B \-n + don't change any file labels. + .TP --- policycoreutils-1.17.5/scripts/fixfiles.rhat 2004-08-30 11:46:47.000000000 -0400 -+++ policycoreutils-1.17.5/scripts/fixfiles 2004-09-23 12:37:51.805467493 -0400 ++++ policycoreutils-1.17.5/scripts/fixfiles 2004-09-24 18:46:15.672622592 -0400 @@ -36,6 +36,8 @@ FILESYSTEMSRO=`mount | grep -v "context=" | egrep -v '\((|.*,)bind(,.*|)\)' | awk '/(ext[23]| xfs | reiserfs ).*\(ro/{print $3}';` FILESYSTEMS="$FILESYSTEMSRW $FILESYSTEMSRO" diff --git a/policycoreutils.spec b/policycoreutils.spec index d1d38a6..054fca7 100644 --- a/policycoreutils.spec +++ b/policycoreutils.spec @@ -1,7 +1,7 @@ Summary: SELinux policy core utilities. Name: policycoreutils Version: 1.17.5 -Release: 4 +Release: 5 License: GPL Group: System Environment/Base Source: http://www.nsa.gov/selinux/archives/policycoreutils-%{version}.tgz @@ -77,6 +77,9 @@ rm -rf ${RPM_BUILD_ROOT} %changelog +* Fri Sep 24 2004 Dan Walsh 1.17.5-5 +- Add -R (recursive) switch to restorecon. + * Thu Sep 23 2004 Dan Walsh 1.17.5-4 - Change to only display to terminal if tty is specified