144 lines
3.6 KiB
Diff
144 lines
3.6 KiB
Diff
|
--- 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
|