Have restorecon exit -1 on errors for consistancy.

This commit is contained in:
Dan Walsh 2013-03-06 12:03:27 -05:00
parent b4e4f79ed5
commit 3aca74a161
2 changed files with 130 additions and 3 deletions

View File

@ -2911,10 +2911,10 @@ index 89d2a49..12bca43 100644
.B \-p
show progress by printing * every STAR_COUNT files. (If you relabel the entire OS, this will show you the percentage complete.)
diff --git a/policycoreutils/setfiles/setfiles.c b/policycoreutils/setfiles/setfiles.c
index b11e49f..d3f02ae 100644
index b11e49f..ac1c39a 100644
--- a/policycoreutils/setfiles/setfiles.c
+++ b/policycoreutils/setfiles/setfiles.c
@@ -45,14 +45,14 @@ void usage(const char *const name)
@@ -45,18 +45,18 @@ void usage(const char *const name)
{
if (iamrestorecon) {
fprintf(stderr,
@ -2934,3 +2934,127 @@ index b11e49f..d3f02ae 100644
"usage: %s -c policyfile spec_file\n",
name, name, name, name);
}
- exit(1);
+ exit(-1);
}
static int nerr = 0;
@@ -66,7 +66,7 @@ void inc_err()
nerr++;
if (nerr > ABORT_ON_ERRORS - 1 && !r_opts.debug) {
fprintf(stderr, "Exiting after %d errors.\n", ABORT_ON_ERRORS);
- exit(1);
+ exit(-1);
}
}
@@ -80,7 +80,7 @@ void set_rootpath(const char *arg)
if (NULL == r_opts.rootpath) {
fprintf(stderr, "%s: insufficient memory for r_opts.rootpath\n",
r_opts.progname);
- exit(1);
+ exit(-1);
}
/* trim trailing /, if present */
@@ -98,7 +98,7 @@ int canoncon(char **contextp)
if (policyfile) {
if (sepol_check_context(context) < 0) {
fprintf(stderr, "invalid context %s\n", context);
- exit(1);
+ exit(-1);
}
} else if (security_canonicalize_context_raw(context, &tmpcon) == 0) {
free(context);
@@ -175,7 +175,7 @@ int main(int argc, char **argv)
r_opts.progname = strdup(argv[0]);
if (!r_opts.progname) {
fprintf(stderr, "%s: Out of memory!\n", argv[0]);
- exit(1);
+ exit(-1);
}
base = basename(r_opts.progname);
@@ -242,7 +242,7 @@ int main(int argc, char **argv)
fprintf(stderr,
"Error opening %s: %s\n",
policyfile, strerror(errno));
- exit(1);
+ exit(-1);
}
__fsetlocking(policystream,
FSETLOCKING_BYCALLER);
@@ -252,7 +252,7 @@ int main(int argc, char **argv)
fprintf(stderr,
"Error reading policy %s: %s\n",
policyfile, strerror(errno));
- exit(1);
+ exit(-1);
}
fclose(policystream);
@@ -268,7 +268,7 @@ int main(int argc, char **argv)
break;
}
if (add_exclude(optarg))
- exit(1);
+ exit(-1);
break;
case 'f':
use_input_file = 1;
@@ -318,13 +318,13 @@ int main(int argc, char **argv)
if (optind + 1 >= argc) {
fprintf(stderr, "usage: %s -r rootpath\n",
argv[0]);
- exit(1);
+ exit(-1);
}
if (NULL != r_opts.rootpath) {
fprintf(stderr,
"%s: only one -r can be specified\n",
argv[0]);
- exit(1);
+ exit(-1);
}
set_rootpath(argv[optind++]);
break;
@@ -337,7 +337,7 @@ int main(int argc, char **argv)
if (r_opts.progress) {
fprintf(stderr,
"Progress and Verbose mutually exclusive\n");
- exit(1);
+ exit(-1);
}
r_opts.verbose++;
break;
@@ -391,12 +391,12 @@ int main(int argc, char **argv)
if (stat(argv[optind], &sb) < 0) {
perror(argv[optind]);
- exit(1);
+ exit(-1);
}
if (!S_ISREG(sb.st_mode)) {
fprintf(stderr, "%s: spec file %s is not a regular file.\n",
argv[0], argv[optind]);
- exit(1);
+ exit(-1);
}
altpath = argv[optind];
@@ -409,7 +409,7 @@ int main(int argc, char **argv)
r_opts.selabel_opt_path = altpath;
if (nerr)
- exit(1);
+ exit(-1);
restore_init(&r_opts);
if (use_input_file) {
@@ -452,5 +452,5 @@ int main(int argc, char **argv)
if (r_opts.progress && r_opts.count >= STAR_COUNT)
printf("\n");
- exit(errors);
+ exit(errors ? -1: 0);
}

View File

@ -7,7 +7,7 @@
Summary: SELinux policy core utilities
Name: policycoreutils
Version: 2.1.14
Release: 18%{?dist}
Release: 19%{?dist}
License: GPLv2
Group: System Environment/Base
# Based on git repository with tag 20101221
@ -310,6 +310,9 @@ The policycoreutils-restorecond package contains the restorecond service.
%{_bindir}/systemctl try-restart restorecond.service >/dev/null 2>&1 || :
%changelog
* Wed Mar 6 2013 Dan Walsh <dwalsh@redhat.com> - 2.1.14-19
- Have restorecon exit -1 on errors for consistancy.
* Tue Mar 5 2013 Dan Walsh <dwalsh@redhat.com> - 2.1.14-18
- Need to provide a value to semanage boolean -m