* Thu Jun 22 2006 Dan Walsh <dwalsh@redhat.com> 1.30.14-5

- Add progress indicator on fixfiles/setfiles/restorecon
This commit is contained in:
Daniel J Walsh 2006-06-22 18:37:08 +00:00
parent ec4979fbb1
commit e414038b9a
2 changed files with 201 additions and 9 deletions

View File

@ -895,8 +895,43 @@ diff --exclude-from=exclude -N -u -r nsapolicycoreutils/po/ms.po policycoreutils
+ +
diff --exclude-from=exclude -N -u -r nsapolicycoreutils/restorecon/restorecon.c policycoreutils-1.30.14/restorecon/restorecon.c diff --exclude-from=exclude -N -u -r nsapolicycoreutils/restorecon/restorecon.c policycoreutils-1.30.14/restorecon/restorecon.c
--- nsapolicycoreutils/restorecon/restorecon.c 2006-05-15 09:42:56.000000000 -0400 --- nsapolicycoreutils/restorecon/restorecon.c 2006-05-15 09:42:56.000000000 -0400
+++ policycoreutils-1.30.14/restorecon/restorecon.c 2006-06-21 15:51:43.000000000 -0400 +++ policycoreutils-1.30.14/restorecon/restorecon.c 2006-06-22 14:07:15.000000000 -0400
@@ -185,7 +185,7 @@ @@ -42,6 +42,7 @@
static int change=1;
static int verbose=0;
+static int progress=0;
static FILE *outfile=NULL;
static char *progname;
static int errors=0;
@@ -49,6 +50,7 @@
static int force=0;
#define STAT_BLOCK_SIZE 1
static int pipe_fds[2] = { -1, -1 };
+static unsigned long long count=0;
#define MAX_EXCLUDES 100
static int excludeCtr=0;
@@ -126,6 +128,18 @@
security_context_t prev_context=NULL;
struct stat st;
char path[PATH_MAX+1];
+
+ if (progress) {
+ count++;
+ if (count % 80000 == 0) {
+ fprintf(stdout, "\n");
+ fflush(stdout);
+ }
+ if (count % 1000 == 0) {
+ fprintf(stdout, "*");
+ fflush(stdout);
+ }
+ }
if (excludeCtr > 0 && exclude(filename)) {
return 0;
@@ -185,7 +199,7 @@
fprintf(stderr,"matchpathcon(%s) failed %s\n", filename,strerror(errno)); fprintf(stderr,"matchpathcon(%s) failed %s\n", filename,strerror(errno));
return 1; return 1;
} }
@ -905,14 +940,38 @@ diff --exclude-from=exclude -N -u -r nsapolicycoreutils/restorecon/restorecon.c
if (retcontext >= 0 || errno == ENODATA) { if (retcontext >= 0 || errno == ENODATA) {
int customizable=0; int customizable=0;
@@ -306,6 +306,7 @@ @@ -306,8 +320,9 @@
progname=argv[0]; progname=argv[0];
if (is_selinux_enabled() <= 0 ) if (is_selinux_enabled() <= 0 )
exit(0); exit(0);
+ set_matchpathcon_flags(MATCHPATHCON_NOTRANS); + set_matchpathcon_flags(MATCHPATHCON_NOTRANS);
while ((opt = getopt(argc, argv, "FrRnvf:o:e:")) > 0) { - while ((opt = getopt(argc, argv, "FrRnvf:o:e:")) > 0) {
+ while ((opt = getopt(argc, argv, "pFrRnvf:o:e:")) > 0) {
switch (opt) { switch (opt) {
case 'n':
change = 0;
@@ -332,8 +347,20 @@
__fsetlocking(outfile, FSETLOCKING_BYCALLER);
break;
case 'v':
+ if (progress) {
+ fprintf(stderr, "Progress and Verbose mutually exclusive\n");
+ usage(argv[0]);
+ }
+
verbose++;
break;
+ case 'p':
+ if (verbose) {
+ fprintf(stderr, "Progress and Verbose mutually exclusive\n");
+ usage(argv[0]);
+ }
+ progress = 1;
+ break;
case 'f':
file = 1;
file_name=optarg;
diff --exclude-from=exclude -N -u -r nsapolicycoreutils/restorecond/restorecond.c policycoreutils-1.30.14/restorecond/restorecond.c diff --exclude-from=exclude -N -u -r nsapolicycoreutils/restorecond/restorecond.c policycoreutils-1.30.14/restorecond/restorecond.c
--- nsapolicycoreutils/restorecond/restorecond.c 2006-05-15 09:42:57.000000000 -0400 --- nsapolicycoreutils/restorecond/restorecond.c 2006-05-15 09:42:57.000000000 -0400
+++ policycoreutils-1.30.14/restorecond/restorecond.c 2006-06-21 15:56:15.000000000 -0400 +++ policycoreutils-1.30.14/restorecond/restorecond.c 2006-06-21 15:56:15.000000000 -0400
@ -934,10 +993,107 @@ diff --exclude-from=exclude -N -u -r nsapolicycoreutils/restorecond/restorecond.
master_fd = inotify_init (); master_fd = inotify_init ();
if (master_fd < 0) if (master_fd < 0)
exitApp("inotify_init"); exitApp("inotify_init");
diff --exclude-from=exclude -N -u -r nsapolicycoreutils/scripts/fixfiles policycoreutils-1.30.14/scripts/fixfiles
--- nsapolicycoreutils/scripts/fixfiles 2006-06-16 15:08:24.000000000 -0400
+++ policycoreutils-1.30.14/scripts/fixfiles 2006-06-22 14:21:55.000000000 -0400
@@ -28,7 +28,7 @@
DIRS=""
RPMILES=""
OUTFILES=""
-LOGFILE=/dev/null
+LOGFILE=`tty`
SYSLOGFLAG="-l"
LOGGER=/usr/sbin/logger
SETFILES=/sbin/setfiles
@@ -118,7 +118,7 @@
fi
if [ ! -z "$RPMFILES" ]; then
for i in `echo $RPMFILES | sed 's/,/ /g'`; do
- rpmlist $i | ${RESTORECON} ${OUTFILES} ${FORCEFLAG} -R $1 -v -f - 2>&1 >> $LOGFILE
+ rpmlist $i | ${RESTORECON} ${OUTFILES} ${FORCEFLAG} -R $* -f - 2>&1 >> $LOGFILE
done
exit $?
fi
@@ -126,16 +126,16 @@
if [ -x /usr/bin/find ]; then
for d in ${DIRS} ; do find $d \
! \( -fstype ext2 -o -fstype ext3 -o -fstype jfs -o -fstype xfs \) -prune -o -print | \
- ${RESTORECON} ${OUTFILES} ${FORCEFLAG} $1 -v -f - 2>&1 >> $LOGFILE
+ ${RESTORECON} ${OUTFILES} ${FORCEFLAG} $* -f - 2>&1 >> $LOGFILE
done
else
- ${RESTORECON} ${OUTFILES} ${FORCEFLAG} -R $1 -v $DIRS 2>&1 >> $LOGFILE
+ ${RESTORECON} ${OUTFILES} ${FORCEFLAG} -R $* $DIRS 2>&1 >> $LOGFILE
fi
exit $?
fi
LogReadOnly
-${SETFILES} ${OUTFILES} ${SYSLOGFLAG} ${FORCEFLAG} $1 -v ${FC} ${FILESYSTEMSRW} 2>&1 >> $LOGFILE
+${SETFILES} ${OUTFILES} ${SYSLOGFLAG} ${FORCEFLAG} $* ${FC} ${FILESYSTEMSRW} 2>&1 >> $LOGFILE
exit $?
}
@@ -234,8 +234,8 @@
# Make sure they specified one of the three valid commands
#
case "$command" in
- restore) restore ;;
- check) restore -n ;;
+ restore) restore -p -q ;;
+ check) restore -n -v ;;
relabel) relabel;;
*)
usage
diff --exclude-from=exclude -N -u -r nsapolicycoreutils/setfiles/setfiles.c policycoreutils-1.30.14/setfiles/setfiles.c diff --exclude-from=exclude -N -u -r nsapolicycoreutils/setfiles/setfiles.c policycoreutils-1.30.14/setfiles/setfiles.c
--- nsapolicycoreutils/setfiles/setfiles.c 2006-06-16 15:08:24.000000000 -0400 --- nsapolicycoreutils/setfiles/setfiles.c 2006-06-16 15:08:24.000000000 -0400
+++ policycoreutils-1.30.14/setfiles/setfiles.c 2006-06-21 15:54:16.000000000 -0400 +++ policycoreutils-1.30.14/setfiles/setfiles.c 2006-06-22 14:32:43.000000000 -0400
@@ -301,7 +301,7 @@ @@ -20,6 +20,7 @@
* -d Show what specification matched each file.
* -l Log changes in files labels to syslog.
* -n Do not change any file labels.
+ * -p Show progress. Prints * for every 1000 files
* -q Be quiet (suppress non-error output).
* -r Use an alternate root path
* -s Use stdin for a list of files instead of searching a partition.
@@ -88,6 +89,8 @@
static int force=0;
#define STAT_BLOCK_SIZE 1
static int pipe_fds[2] = { -1, -1 };
+static int progress=0;
+static unsigned long long count=0;
#define MAX_EXCLUDES 100
static int excludeCtr=0;
@@ -208,7 +211,7 @@
void usage(const char * const name)
{
fprintf(stderr,
- "usage: %s [-dnqvW] [-o filename] [-r alt_root_path ] spec_file pathname...\n"
+ "usage: %s [-dnpqvW] [-o filename] [-r alt_root_path ] spec_file pathname...\n"
"usage: %s -c policyfile spec_file\n"
"usage: %s -s [-dnqvW] [-o filename ] spec_file\n", name, name, name);
exit(1);
@@ -278,6 +281,18 @@
/* No matching specification. */
return 0;
+ if (progress) {
+ count++;
+ if (count % 80000 == 0) {
+ fprintf(stdout, "\n");
+ fflush(stdout);
+ }
+ if (count % 1000 == 0) {
+ fprintf(stdout, "*");
+ fflush(stdout);
+ }
+ }
+
/*
* Try to add an association between this inode and
* this specification. If there is already an association
@@ -301,7 +316,7 @@
} }
/* Get the current context of the file. */ /* Get the current context of the file. */
@ -946,7 +1102,16 @@ diff --exclude-from=exclude -N -u -r nsapolicycoreutils/setfiles/setfiles.c poli
if (ret < 0) { if (ret < 0) {
if (errno == ENODATA) { if (errno == ENODATA) {
context = NULL; context = NULL;
@@ -485,7 +485,7 @@ @@ -414,7 +429,7 @@
if (policyfile) {
valid = (sepol_check_context (context) >= 0);
- } else if (security_canonicalize_context(context, &tmpcon) < 0) {
+ } else if (security_canonicalize_context_raw(context, &tmpcon) < 0) {
if (errno != ENOENT) {
valid = 0;
inc_err();
@@ -485,10 +500,10 @@
memset(excludeArray,0, sizeof(excludeArray)); memset(excludeArray,0, sizeof(excludeArray));
/* Validate all file contexts during matchpathcon_init. */ /* Validate all file contexts during matchpathcon_init. */
@ -954,7 +1119,31 @@ diff --exclude-from=exclude -N -u -r nsapolicycoreutils/setfiles/setfiles.c poli
+ set_matchpathcon_flags(MATCHPATHCON_VALIDATE | MATCHPATHCON_NOTRANS); + set_matchpathcon_flags(MATCHPATHCON_VALIDATE | MATCHPATHCON_NOTRANS);
/* Process any options. */ /* Process any options. */
while ((opt = getopt(argc, argv, "Fc:dlnqrsvWe:o:")) > 0) { - while ((opt = getopt(argc, argv, "Fc:dlnqrsvWe:o:")) > 0) {
+ while ((opt = getopt(argc, argv, "Fc:dlnpqrsvWe:o:")) > 0) {
switch (opt) {
case 'c':
{
@@ -566,8 +581,19 @@
add_assoc = 0;
break;
case 'v':
+ if (progress) {
+ fprintf(stderr, "Progress and Verbose mutually exclusive\n");
+ exit(1);
+ }
verbose++;
break;
+ case 'p':
+ if (verbose) {
+ fprintf(stderr, "Progress and Verbose mutually exclusive\n");
+ usage(argv[0]);
+ }
+ progress = 1;
+ break;
case 'W':
warn_no_match = 1;
break;
diff --exclude-from=exclude -N -u -r nsapolicycoreutils/setsebool/setsebool.8 policycoreutils-1.30.14/setsebool/setsebool.8 diff --exclude-from=exclude -N -u -r nsapolicycoreutils/setsebool/setsebool.8 policycoreutils-1.30.14/setsebool/setsebool.8
--- nsapolicycoreutils/setsebool/setsebool.8 2006-05-15 09:42:58.000000000 -0400 --- nsapolicycoreutils/setsebool/setsebool.8 2006-05-15 09:42:58.000000000 -0400
+++ policycoreutils-1.30.14/setsebool/setsebool.8 2006-06-19 10:32:36.000000000 -0400 +++ policycoreutils-1.30.14/setsebool/setsebool.8 2006-06-19 10:32:36.000000000 -0400

View File

@ -5,7 +5,7 @@
Summary: SELinux policy core utilities. Summary: SELinux policy core utilities.
Name: policycoreutils Name: policycoreutils
Version: 1.30.14 Version: 1.30.14
Release: 4 Release: 5
License: GPL License: GPL
Group: System Environment/Base Group: System Environment/Base
Source: http://www.nsa.gov/selinux/archives/policycoreutils-%{version}.tgz Source: http://www.nsa.gov/selinux/archives/policycoreutils-%{version}.tgz
@ -111,6 +111,9 @@ rm -rf %{buildroot}
[ -x /sbin/service ] && /sbin/service restorecond condrestart [ -x /sbin/service ] && /sbin/service restorecond condrestart
%changelog %changelog
* Thu Jun 22 2006 Dan Walsh <dwalsh@redhat.com> 1.30.14-5
- Add progress indicator on fixfiles/setfiles/restorecon
* Wed Jun 21 2006 Dan Walsh <dwalsh@redhat.com> 1.30.14-4 * Wed Jun 21 2006 Dan Walsh <dwalsh@redhat.com> 1.30.14-4
- Don't use translations with matchpathcon - Don't use translations with matchpathcon