All of lore.kernel.org
 help / color / mirror / Atom feed
From: Daniel J Walsh <dwalsh@redhat.com>
To: Stephen Smalley <sds@tycho.nsa.gov>,
	SE Linux <selinux@tycho.nsa.gov>,
	benny+bugzilla@amorsen.dk
Subject: patch to setfiles/fixfiles to handle file names with special characters in them.
Date: Wed, 23 Jan 2008 17:40:48 -0500	[thread overview]
Message-ID: <4797C270.9000202@redhat.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 485 bytes --]

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Benny Amorsen Provided the patch added -0 option.

Also added support to fixfiles for ext4 ext4dev and gfs2

Fixes quoting in fixfiles also.

Cleaned up description in man page.

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.8 (GNU/Linux)
Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org

iEYEARECAAYFAkeXwm8ACgkQrlYvE4MpobPTHgCfXoMY6qmBuOSBPXcCszFpkRfA
WuoAn1Dw9NWg1gUJmZbyPF1IoXdyuL7D
=pglo
-----END PGP SIGNATURE-----

[-- Attachment #2: fixfiles.patch --]
[-- Type: text/plain, Size: 4865 bytes --]

--- nsapolicycoreutils/scripts/fixfiles	2008-01-23 14:36:28.000000000 -0500
+++ policycoreutils-2.0.37/scripts/fixfiles	2008-01-23 17:13:45.000000000 -0500
@@ -36,8 +36,8 @@
 LOGGER=/usr/sbin/logger
 SETFILES=/sbin/setfiles
 RESTORECON=/sbin/restorecon
-FILESYSTEMSRW=`mount | grep -v "context=" | egrep -v '\((|.*,)bind(,.*|)\)' | awk '/(ext[23]| xfs | jfs ).*\(rw/{print $3}';`
-FILESYSTEMSRO=`mount | grep -v "context=" | egrep -v '\((|.*,)bind(,.*|)\)' | awk '/(ext[23]| xfs | jfs ).*\(ro/{print $3}';`
+FILESYSTEMSRW=`mount | grep -v "context=" | egrep -v '\((|.*,)bind(,.*|)\)' | awk '/(ext[234]| ext4dev | gfs2 | xfs | jfs ).*\(rw/{print $3}';`
+FILESYSTEMSRO=`mount | grep -v "context=" | egrep -v '\((|.*,)bind(,.*|)\)' | awk '/(ext[234]| ext4dev | gfs2 | xfs | jfs ).*\(ro/{print $3}';`
 FILESYSTEMS="$FILESYSTEMSRW $FILESYSTEMSRO"
 SELINUXTYPE="targeted"
 if [ -e /etc/selinux/config ]; then
@@ -88,11 +88,11 @@
                   esac; \
                fi; \
             done | \
-	while read pattern ; do sh -c "find $pattern" \
-		      ! \( -fstype ext2 -o -fstype ext3 -o -fstype jfs -o -fstype xfs \) -prune  -o \
-		      \( -wholename /home -o -wholename /root -o -wholename /tmp -wholename /dev \) -prune -o -print; \
+	while read pattern ; do sh -c "find $pattern \
+		      ! \( -fstype ext2 -o -fstype ext3 -o -fstype ext4 -o -fstype ext4dev  -o -fstype gfs2 -o -fstype jfs -o -fstype xfs \) -prune  -o \
+		      \( -wholename /home -o -wholename /root -o -wholename /tmp -wholename /dev \) -prune -o -print0"; \
 		      done 2> /dev/null | \
-	 ${RESTORECON} $2 -f - 
+	 ${RESTORECON} $2 -0 -f - 
 	rm -f ${TEMPFILE} ${PREFCTEMPFILE}
 fi
 }
@@ -129,8 +129,8 @@
 if [ ! -z "$FILEPATH" ]; then
     if [ -x /usr/bin/find ]; then
 	/usr/bin/find "$FILEPATH" \
-	    ! \( -fstype ext2 -o -fstype ext3 -o -fstype jfs -o -fstype xfs \) -prune  -o -print | \
-	    ${RESTORECON} ${OUTFILES} ${FORCEFLAG} $* -f - 2>&1 >> $LOGFILE
+	    ! \( -fstype ext2 -o -fstype ext3 -o -fstype ext4 -o -fstype ext4dev -o -fstype gfs2 -o -fstype jfs -o -fstype xfs \) -prune  -o -print0 | \
+	    ${RESTORECON} ${OUTFILES} ${FORCEFLAG} $* -0 -f - 2>&1 >> $LOGFILE
     else
 	${RESTORECON} ${OUTFILES} ${FORCEFLAG} -R $* $FILEPATH 2>&1 >> $LOGFILE
     fi
--- nsapolicycoreutils/scripts/fixfiles.8	2007-07-16 14:20:41.000000000 -0400
+++ policycoreutils-2.0.37/scripts/fixfiles.8	2008-01-23 17:13:45.000000000 -0500
@@ -35,7 +35,7 @@
 
 .TP 
 .B -f
-Don't prompt for removal of /tmp directory.
+Clear /tmp directory with out prompt for removal.
 
 .TP 
 .B -R rpmpackagename[,rpmpackagename...]
--- nsapolicycoreutils/setfiles/setfiles.8	2007-07-16 14:20:43.000000000 -0400
+++ policycoreutils-2.0.37/setfiles/setfiles.8	2008-01-23 17:13:45.000000000 -0500
@@ -59,6 +59,9 @@
 .TP 
 .B \-W
 display warnings about entries that had no matching files.
+.TP 
+.B \-0
+Input items are terminated by a null character instead of by whitespace,  and the quotes and backslash are not special (every character is taken literally).  Disables the end of file string, which  is  treated  like  any other argument.  Useful when input items might contain white space, quote  marks,  or  backslashes.The  GNU  find  -print0  option produces input suitable for this mode.
 
 .SH "ARGUMENTS"
 .B spec_file
--- nsapolicycoreutils/setfiles/setfiles.c	2008-01-11 10:52:37.000000000 -0500
+++ policycoreutils-2.0.37/setfiles/setfiles.c	2008-01-23 17:13:45.000000000 -0500
@@ -55,6 +55,7 @@
 static int verbose = 0;
 static int logging = 0;
 static int warn_no_match = 0;
+static int null_terminated = 0;
 static char *rootpath = NULL;
 static int rootpathlen = 0;
 static int recurse; /* Recursive descent. */
@@ -384,7 +385,7 @@
 {
 	if (iamrestorecon) {
 		fprintf(stderr,
-			"usage:  %s [-iFnrRv] [-e excludedir ] [-o filename ] [-f filename | pathname... ]\n",
+			"usage:  %s [-iFnrRv0] [-e excludedir ] [-o filename ] [-f filename | pathname... ]\n",
 			name);
 	} else {
 		fprintf(stderr,
@@ -805,7 +806,7 @@
 	}
 
 	/* Process any options. */
-	while ((opt = getopt(argc, argv, "c:de:f:ilnpqrsvo:FRW")) > 0) {
+	while ((opt = getopt(argc, argv, "c:de:f:ilnpqrsvo:FRW0")) > 0) {
 		switch (opt) {
 		case 'c':
 			{
@@ -927,6 +928,9 @@
 		case 'W':
 			warn_no_match = 1;
 			break;
+		case '0':
+			null_terminated = 1;
+			break;
 		case '?':
 			usage(argv[0]);
 		}
@@ -983,6 +987,7 @@
 	if (use_input_file) {
 		FILE *f = stdin;
 		ssize_t len;
+		int delim;
 		if (strcmp(input_filename, "-") != 0)
 			f = fopen(input_filename, "r");
 		if (f == NULL) {
@@ -991,7 +996,9 @@
 			usage(argv[0]);
 		}
 		__fsetlocking(f, FSETLOCKING_BYCALLER);
-		while ((len = getline(&buf, &buf_len, f)) > 0) {
+
+		delim = (null_terminated != 0) ? '\0' : '\n';
+		while ((len = getdelim(&buf, &buf_len, delim, f)) > 0) {
 			buf[len - 1] = 0;
 			errors |= process_one(buf);
 		}

[-- Attachment #3: fixfiles.patch.sig --]
[-- Type: application/octet-stream, Size: 72 bytes --]

             reply	other threads:[~2008-01-23 22:40 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-01-23 22:40 Daniel J Walsh [this message]
2008-01-24 19:31 ` patch to setfiles/fixfiles to handle file names with special characters in them Stephen Smalley

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=4797C270.9000202@redhat.com \
    --to=dwalsh@redhat.com \
    --cc=benny+bugzilla@amorsen.dk \
    --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.