policycoreutils/policycoreutils-rhat.patch

214 lines
5.4 KiB
Diff
Raw Normal View History

--- policycoreutils-1.13.3/setfiles/setfiles.c.rhat 2004-06-23 09:21:44.000000000 -0400
+++ policycoreutils-1.13.3/setfiles/setfiles.c 2004-06-23 09:49:12.009189088 -0400
@@ -12,7 +12,7 @@
* the user. The program does not cross file system boundaries.
*
* USAGE:
- * setfiles [-dnpqsvW] spec_file pathname...
+ * setfiles [-dnpqsvW] [-o filename ] spec_file pathname...
*
* -d Show what specification matched each file.
* -n Do not change any file labels.
@@ -21,6 +21,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.
+ * -o filename write out file names with wrong context.
*
* spec_file The specification file.
* pathname... The file systems to label (omit if using -s).
@@ -68,6 +69,7 @@
#include <selinux/selinux.h>
static int add_assoc = 1;
+static FILE *outfile=NULL;
/*
* Command-line options.
@@ -480,8 +482,8 @@
void usage(const char * const name)
{
fprintf(stderr,
- "usage: %s [-dnqvW] spec_file pathname...\n"
- "usage: %s -s [-dnqvW] spec_file\n", name, name);
+ "usage: %s [-dnqvW] [-o filename] spec_file pathname...\n"
+ "usage: %s -s [-dnqvW] [-o filename ] spec_file\n", name, name);
exit(1);
}
@@ -652,6 +654,9 @@
freecon(context);
+ if (outfile)
+ fprintf(outfile, "%s\n", my_file);
+
/*
* Do not relabel the file if -n was used.
*/
@@ -705,7 +710,7 @@
spec_t *spec_copy;
/* Process any options. */
- while ((opt = getopt(argc, argv, "dnqrsvW")) > 0) {
+ while ((opt = getopt(argc, argv, "dnqrsvWo:")) > 0) {
switch (opt) {
case 'd':
debug = 1;
@@ -713,6 +718,15 @@
case 'n':
change = 0;
break;
+ case 'o':
+ outfile = fopen(optarg,"w");
+ if (!outfile) {
+ fprintf(stderr, "Error opening %s: %s\n",
+ optarg, strerror(errno));
+
+ usage(argv[0]);
+ }
+ break;
case 'q':
quiet = 1;
break;
@@ -1039,6 +1053,8 @@
}
}
}
+ if (outfile)
+ fclose(outfile);
QPRINTF("%s: Done.\n", argv[0]);
--- policycoreutils-1.13.3/setfiles/setfiles.8.rhat 2004-06-23 09:21:44.000000000 -0400
+++ policycoreutils-1.13.3/setfiles/setfiles.8 2004-06-23 09:46:15.975950208 -0400
@@ -4,8 +4,7 @@
.SH "SYNOPSIS"
.B setfiles
-.I [\-d] [\-n] [\-q] [\-s] [\-v] [\-vv] [\-W] spec_file pathname...
-
+.I [\-d] [\-n] [\-o filename ] [\-q] [\-s] [\-v] [\-vv] [\-W] spec_file pathname...
.SH "DESCRIPTION"
This manual page describes the
.BR setfiles
@@ -30,6 +29,9 @@
.B \-q
suppress non-error output.
.TP
+.B \-o filename
+save list of files with incorrect context in filename.
+.TP
.B \-s
take a list of files from standard input instead of using a pathname on the
command line.
--- policycoreutils-1.13.3/restorecon/restorecon.8.rhat 2004-06-23 09:21:44.000000000 -0400
+++ policycoreutils-1.13.3/restorecon/restorecon.8 2004-06-23 09:46:48.081069488 -0400
@@ -4,7 +4,10 @@
.SH "SYNOPSIS"
.B restorecon
-.I [\-n] [\-v] pathname...
+.I [\-o outfilename ] [\-n] [\-v] pathname...
+.P
+.B restorecon
+.I \-f infilename [\-o outfilename ] [\-n] [\-v]
.SH "DESCRIPTION"
This manual page describes the
@@ -20,9 +23,15 @@
.SH "OPTIONS"
.TP
+.B \-f infilename
+infilename contains a list of files to be processed by application. Use \- for stdin.
+.TP
.B \-n
don't change any file labels.
.TP
+.B \-o outfilename
+save list of files with incorrect context in outfilename.
+.TP
.B \-v
show changes in file labels.
.TP
--- policycoreutils-1.13.3/restorecon/restorecon.c.rhat 2004-06-23 09:21:44.000000000 -0400
+++ policycoreutils-1.13.3/restorecon/restorecon.c 2004-06-23 09:48:44.411384592 -0400
@@ -12,6 +12,7 @@
*
* -n Do not change any file labels.
* -v Show changes in file labels.
+ * -o filename save list of files with incorrect context
*
* pathname... The file(s) to label
*
@@ -41,7 +42,7 @@
"usage: %s [-nv] [-f filename | pathname... ]\n", name);
exit(1);
}
-int restore(char *filename, int change, int verbose) {
+int restore(char *filename, int change, int verbose, FILE *outfile) {
int retcontext=0;
int retval=0;
int errors=0;
@@ -72,6 +73,9 @@
if (retcontext >= 0 || errno == ENODATA) {
if (retcontext < 0 || strcmp(prev_context,scontext) != 0) {
+ if (outfile) {
+ fprintf(outfile, "%s\n", filename);
+ }
if (change) {
retval=lsetfilecon(filename,scontext);
}
@@ -106,6 +110,7 @@
int verbose=0;
int file=0;
char opt;
+ FILE *outfile=NULL;
char buf[PATH_MAX];
progname=argv[0];
@@ -114,11 +119,19 @@
memset(buf,0, sizeof(buf));
- while ((opt = getopt(argc, argv, "nvf:")) > 0) {
+ while ((opt = getopt(argc, argv, "nvf:o:")) > 0) {
switch (opt) {
case 'n':
change = 0;
break;
+ case 'o':
+ outfile = fopen(optarg,"w");
+ if (!outfile) {
+ fprintf(stderr, "Error opening %s: %s\n",
+ optarg, strerror(errno));
+ usage(argv[0]);
+ }
+ break;
case 'v':
verbose = 1;
break;
@@ -141,15 +154,18 @@
}
while(fgets(buf,PATH_MAX,f)) {
buf[strlen(buf)-1]=0;
- errors=errors+restore(buf,change, verbose);
+ errors=errors+restore(buf, change, verbose, outfile);
}
if (strcmp(file_name,"-")!=0)
fclose(f);
}
else {
for (i=optind; i< argc; i++) {
- errors=errors+restore(argv[i],change, verbose);
+ errors=errors+restore(argv[i], change, verbose, outfile);
}
}
+ if (outfile)
+ fclose(outfile);
+
return errors;
}