Blame SOURCES/0037-setfiles-drop-ABORT_ON_ERRORS-and-related-code.patch

afc235
From 2f135022f4372dc34198c48cfd67b91044e6dfd7 Mon Sep 17 00:00:00 2001
afc235
From: Petr Lautrbach <plautrba@redhat.com>
afc235
Date: Wed, 13 Jan 2021 22:09:48 +0100
afc235
Subject: [PATCH] setfiles: drop ABORT_ON_ERRORS and related code
afc235
afc235
`setfiles -d` doesn't have any impact on number of errors before it
afc235
aborts. It always aborts on first invalid context in spec file.
afc235
afc235
Signed-off-by: Petr Lautrbach <plautrba@redhat.com>
afc235
---
afc235
 policycoreutils/setfiles/Makefile      |  3 ---
afc235
 policycoreutils/setfiles/ru/setfiles.8 |  2 +-
afc235
 policycoreutils/setfiles/setfiles.8    |  3 +--
afc235
 policycoreutils/setfiles/setfiles.c    | 18 ------------------
afc235
 4 files changed, 2 insertions(+), 24 deletions(-)
afc235
afc235
diff --git a/policycoreutils/setfiles/Makefile b/policycoreutils/setfiles/Makefile
afc235
index bc5a8db789a5..a3bbbe116b7f 100644
afc235
--- a/policycoreutils/setfiles/Makefile
afc235
+++ b/policycoreutils/setfiles/Makefile
afc235
@@ -5,8 +5,6 @@ SBINDIR ?= /sbin
afc235
 MANDIR = $(PREFIX)/share/man
afc235
 AUDITH ?= $(shell test -f /usr/include/libaudit.h && echo y)
afc235
 
afc235
-ABORT_ON_ERRORS=$(shell grep "^\#define ABORT_ON_ERRORS" setfiles.c | awk -S '{ print $$3 }')
afc235
-
afc235
 CFLAGS ?= -g -Werror -Wall -W
afc235
 override LDLIBS += -lselinux -lsepol
afc235
 
afc235
@@ -26,7 +24,6 @@ restorecon_xattr: restorecon_xattr.o restore.o
afc235
 
afc235
 man:
afc235
 	@cp -af setfiles.8 setfiles.8.man
afc235
-	@sed -i "s/ABORT_ON_ERRORS/$(ABORT_ON_ERRORS)/g" setfiles.8.man
afc235
 
afc235
 install: all
afc235
 	[ -d $(DESTDIR)$(MANDIR)/man8 ] || mkdir -p $(DESTDIR)$(MANDIR)/man8
afc235
diff --git a/policycoreutils/setfiles/ru/setfiles.8 b/policycoreutils/setfiles/ru/setfiles.8
afc235
index 27815a3f1eee..910101452625 100644
afc235
--- a/policycoreutils/setfiles/ru/setfiles.8
afc235
+++ b/policycoreutils/setfiles/ru/setfiles.8
afc235
@@ -47,7 +47,7 @@ setfiles \- установить SELinux-контексты безопаснос
afc235
 проверить действительность контекстов относительно указанной двоичной политики.
afc235
 .TP
afc235
 .B \-d
afc235
-показать, какая спецификация соответствует каждому из файлов (не прекращать проверку после получения ошибок ABORT_ON_ERRORS).
afc235
+показать, какая спецификация соответствует каждому из файлов.
afc235
 .TP
afc235
 .BI \-e \ directory
afc235
 исключить каталог (чтобы исключить более одного каталога, этот параметр необходимо использовать соответствующее количество раз).
afc235
diff --git a/policycoreutils/setfiles/setfiles.8 b/policycoreutils/setfiles/setfiles.8
afc235
index a8a76c860dac..b7d3cefb96ff 100644
afc235
--- a/policycoreutils/setfiles/setfiles.8
afc235
+++ b/policycoreutils/setfiles/setfiles.8
afc235
@@ -56,8 +56,7 @@ option will force a replacement of the entire context.
afc235
 check the validity of the contexts against the specified binary policy.
afc235
 .TP
afc235
 .B \-d
afc235
-show what specification matched each file (do not abort validation
afc235
-after ABORT_ON_ERRORS errors). Not affected by "\-q"
afc235
+show what specification matched each file. Not affected by "\-q"
afc235
 .TP
afc235
 .BI \-e \ directory
afc235
 directory to exclude (repeat option for more than one directory).
afc235
diff --git a/policycoreutils/setfiles/setfiles.c b/policycoreutils/setfiles/setfiles.c
afc235
index 68eab45aa2b4..bcbdfbfe53e2 100644
afc235
--- a/policycoreutils/setfiles/setfiles.c
afc235
+++ b/policycoreutils/setfiles/setfiles.c
afc235
@@ -23,14 +23,6 @@ static int nerr;
afc235
 
afc235
 #define STAT_BLOCK_SIZE 1
afc235
 
afc235
-/* setfiles will abort its operation after reaching the
afc235
- * following number of errors (e.g. invalid contexts),
afc235
- * unless it is used in "debug" mode (-d option).
afc235
- */
afc235
-#ifndef ABORT_ON_ERRORS
afc235
-#define ABORT_ON_ERRORS	10
afc235
-#endif
afc235
-
afc235
 #define SETFILES "setfiles"
afc235
 #define RESTORECON "restorecon"
afc235
 static int iamrestorecon;
afc235
@@ -57,15 +49,6 @@ static __attribute__((__noreturn__)) void usage(const char *const name)
afc235
 	exit(-1);
afc235
 }
afc235
 
afc235
-void inc_err(void)
afc235
-{
afc235
-	nerr++;
afc235
-	if (nerr > ABORT_ON_ERRORS - 1 && !r_opts.debug) {
afc235
-		fprintf(stderr, "Exiting after %d errors.\n", ABORT_ON_ERRORS);
afc235
-		exit(-1);
afc235
-	}
afc235
-}
afc235
-
afc235
 void set_rootpath(const char *arg)
afc235
 {
afc235
 	if (strlen(arg) == 1 && strncmp(arg, "/", 1) == 0) {
afc235
@@ -98,7 +81,6 @@ int canoncon(char **contextp)
afc235
 		*contextp = tmpcon;
afc235
 	} else if (errno != ENOENT) {
afc235
 		rc = -1;
afc235
-		inc_err();
afc235
 	}
afc235
 
afc235
 	return rc;
afc235
-- 
afc235
2.30.0
afc235