policycoreutils/policycoreutils-rhat.patch

144 lines
3.6 KiB
Diff
Raw Normal View History

auto-import changelog data from policycoreutils-1.9-12.src.rpm * Tue Mar 23 2004 Dan Walsh <dwalsh@redhat.com> 1.9-12 - Remove setfiles-assoc patch - Fix restorecon to not crash on missing dir * Wed Mar 17 2004 Dan Walsh <dwalsh@redhat.com> 1.9-11 - Eliminate trailing / in restorecon * Wed Mar 17 2004 Dan Walsh <dwalsh@redhat.com> 1.9-10 - Add Verbosity check * Wed Mar 17 2004 Dan Walsh <dwalsh@redhat.com> 1.9-9 - Change restorecon to not follow symlinks. It is too difficult and confusing - to figure out the file context for the file pointed to by a symlink. * Wed Mar 17 2004 Dan Walsh <dwalsh@redhat.com> 1.9-8 - Fix restorecon * Wed Mar 17 2004 Dan Walsh <dwalsh@redhat.com> 1.9-7 - Read restorecon patch * Wed Mar 17 2004 Dan Walsh <dwalsh@redhat.com> 1.9-6 - Change genhomedircon to take POLICYSOURCEDIR from command line * Wed Mar 17 2004 Dan Walsh <dwalsh@redhat.com> 1.9-5 - Add checkselinux - move fixfiles and restorecon to /sbin * Wed Mar 17 2004 Dan Walsh <dwalsh@redhat.com> 1.9-4 - Restore patch of genhomedircon * Mon Mar 15 2004 Dan Walsh <dwalsh@redhat.com> 1.9-3 - Add setfiles-assoc patch to try to freeup memory use * Mon Mar 15 2004 Dan Walsh <dwalsh@redhat.com> 1.9-2 - Add fixlabels * Mon Mar 15 2004 Dan Walsh <dwalsh@redhat.com> 1.9-1 - Update to latest from NSA * Wed Mar 10 2004 Dan Walsh <dwalsh@redhat.com> 1.6-8 - Increase the size of buffer accepted by setfiles to BUFSIZ. * Tue Mar 09 2004 Dan Walsh <dwalsh@redhat.com> 1.6-7 - genhomedircon should complete even if it can't read /etc/default/useradd * Tue Mar 09 2004 Dan Walsh <dwalsh@redhat.com> 1.6-6 - fix restorecon to relabel unlabled files. * Fri Mar 05 2004 Dan Walsh <dwalsh@redhat.com> 1.6-5 - Add genhomedircon from tresys - Fixed patch for restorecon * Thu Feb 26 2004 Dan Walsh <dwalsh@redhat.com> 1.6-4 - exit out when selinux is not enabled * Thu Feb 26 2004 Dan Walsh <dwalsh@redhat.com> 1.6-3 - Fix minor bugs in restorecon * Thu Feb 26 2004 Dan Walsh <dwalsh@redhat.com> 1.6-2 - Add restorecon c program * Tue Feb 24 2004 Dan Walsh <dwalsh@redhat.com> 1.6-1 - Update to latest tarball from NSA * Thu Feb 19 2004 Dan Walsh <dwalsh@redhat.com> 1.4-9 - Add sort patch * Fri Feb 13 2004 Elliot Lee <sopwith@redhat.com> - rebuilt
2004-09-09 10:34:14 +00:00
--- policycoreutils-1.9/restorecon/restorecon.c.rhat 2004-03-15 12:04:20.000000000 -0500
+++ policycoreutils-1.9/restorecon/restorecon.c 2004-03-23 11:51:08.438569904 -0500
@@ -25,13 +25,15 @@
#include <errno.h>
#include <string.h>
#include <stdlib.h>
+#include <unistd.h>
+#include <limits.h>
#include <selinux/selinux.h>
#include <getopt.h>
void usage(const char * const name)
{
fprintf(stderr,
- "usage: %s [-hnv] pathname...\n", name);
+ "usage: %s [-nv] pathname...\n", name);
exit(1);
}
@@ -39,15 +41,18 @@
security_context_t scontext;
security_context_t prev_context;
int i=0;
+ int retcontext=0;
int retval=0;
int errors=0;
- int links=0;
int change=1;
int verbose=0;
char opt;
char *progname=argv[0];
- while ((opt = getopt(argc, argv, "hnv")) > 0) {
+ if (is_selinux_enabled() <= 0 )
+ exit(0);
+
+ while ((opt = getopt(argc, argv, "nv")) > 0) {
switch (opt) {
case 'n':
change = 0;
@@ -55,50 +60,49 @@
case 'v':
verbose = 1;
break;
- case 'h':
- links = 1;
- break;
case '?':
usage(argv[0]);
}
}
for (i=optind; i< argc; i++) {
- retval = matchpathcon(argv[i], 0, &scontext);
+ char *filename=argv[i];
+ int len=strlen(filename);
+ /*
+ Eliminate trailing /
+ */
+ if (filename[len-1]=='/' && (strcmp(filename,"/") != 0)) {
+ filename[len-1]=NULL;
+ }
+ retval = matchpathcon(filename, 0, &scontext);
if (retval < 0) {
- fprintf(stderr,"matchpathcon(%s) failed\n", argv[i]);
+ fprintf(stderr,"matchpathcon(%s) failed\n", filename);
errors++;
continue;
}
- if (links)
- retval=lgetfilecon(argv[i],&prev_context);
- else
- retval=getfilecon(argv[i],&prev_context);
-
- if (retval > 0) {
- if (strcmp(prev_context,scontext) != 0) {
-
+ retcontext=lgetfilecon(filename,&prev_context);
+
+ if (retcontext >= 0 || errno == ENODATA) {
+ if (retcontext < 0 || strcmp(prev_context,scontext) != 0) {
if (change) {
- if ( links )
- retval=lsetfilecon(argv[i],scontext);
- else
- retval=setfilecon(argv[i],scontext);
+ retval=lsetfilecon(filename,scontext);
}
if (retval<0)
fprintf(stderr,"%s set context %s->%s failed:'%s'\n",
- progname, argv[i], scontext, strerror(errno));
+ progname, filename, scontext, strerror(errno));
else
if (verbose)
fprintf(stderr,"%s set context %s->%s\n",
- progname, argv[i], scontext);
- }
+ progname, filename, scontext);
+ }
+ if (retcontext >= 0)
+ free(prev_context);
}
else {
if (verbose)
fprintf(stderr,"%s get context on %s failed: '%s'\n",
- progname, argv[i], strerror(errno));
+ progname, filename, strerror(errno));
}
free(scontext);
- free(prev_context);
}
return errors;
}
--- policycoreutils-1.9/restorecon/restorecon.8.rhat 2004-03-15 12:04:20.000000000 -0500
+++ policycoreutils-1.9/restorecon/restorecon.8 2004-03-18 10:04:44.000000000 -0500
@@ -4,7 +4,7 @@
.SH "SYNOPSIS"
.B restorecon
-.I [\-h] [\-n] [\-v] pathname...
+.I [\-n] [\-v] pathname...
.SH "DESCRIPTION"
This manual page describes the
@@ -20,9 +20,6 @@
.SH "OPTIONS"
.TP
-.B \-h
-change symbolic links rather then the files they point at
-.TP
.B \-n
don't change any file labels.
.TP
--- policycoreutils-1.9/restorecon/Makefile.rhat 2004-03-15 12:04:20.000000000 -0500
+++ policycoreutils-1.9/restorecon/Makefile 2004-03-18 10:04:44.000000000 -0500
@@ -1,6 +1,6 @@
# Installation directories.
PREFIX ?= ${DESTDIR}/usr
-SBINDIR ?= $(PREFIX)/sbin
+SBINDIR ?= $(DESTDIR)/sbin
MANDIR = $(PREFIX)/share/man
CFLAGS = -Wall