policycoreutils/policycoreutils-rhat.patch
Daniel J Walsh 9fb0a29c97 * Mon Jan 3 2005 Dan Walsh <dwalsh@redhat.com> 1.19.3-1
- Update to latest from NSA
	* Merged fixfiles and restorecon patches from Dan Walsh.
	* Don't display change if only user part changed.
2005-01-05 20:17:09 +00:00

39 lines
1.2 KiB
Diff

diff --exclude-from=exclude -N -u -r nsapolicycoreutils/restorecon/restorecon.c policycoreutils-1.19.2/restorecon/restorecon.c
--- nsapolicycoreutils/restorecon/restorecon.c 2005-01-05 15:12:59.569516712 -0500
+++ policycoreutils-1.19.2/restorecon/restorecon.c 2005-01-05 15:11:14.994550830 -0500
@@ -43,6 +43,20 @@
static int errors=0;
static int recurse;
+/* Compare two contexts to see if their differences are "significant",
+ * or whether the only difference is in the user. */
+static int only_changed_user(const char *a, const char *b)
+{
+ char *rest_a, *rest_b; /* Rest of the context after the user */
+ rest_a = strchr(a, ':');
+ rest_b = strchr(b, ':');
+ if (!rest_a || !rest_b)
+ return 0;
+ if (strcmp(rest_a, rest_b) == 0)
+ return 1;
+ return 0;
+}
+
void usage(const char * const name)
{
fprintf(stderr,
@@ -129,9 +143,10 @@
freecon(scontext);
return 1;
} else
- if (verbose)
- fprintf(stderr,"%s reset context %s:%s->%s\n",
- progname, filename, prev_context, scontext);
+ if (verbose > 1 ||
+ !only_changed_user(scontext, prev_context))
+ fprintf(stderr,"%s reset context %s:%s->%s\n",
+ progname, filename, prev_context, scontext);
}
if (retcontext >= 0)
freecon(prev_context);