diff mbox series

[for-3.5,3/5] setfiles: remove useless "iamrestorecon" checks in option parsing

Message ID 20220428065354.27605-4-lersek@redhat.com (mailing list archive)
State Superseded
Headers show
Series selinux_restorecon(3), setfiles(8): skip relabeling errors | expand

Commit Message

Laszlo Ersek April 28, 2022, 6:53 a.m. UTC
Commit 219eea83cea9 ("policycoreutils: setfiles/restorecon: fix -r/-R
option", 2015-04-16) split the option strings between "setfiles" and
"restorecon". Since that commit, an "iamrestorecon" check has only been
necessary for an option that is (a) accepted by both "setfiles" and
"restorecon", but (b) behaves differently between "setfiles" and
"restorecon". Currently, the only such options are "-r" and "-R". Remove
the "iamrestorecon" checks from the "setfiles"-only "-c" and "-d" options,
and from the "restorecon"-only "-x" option.

Cc: "Richard W.M. Jones" <rjones@redhat.com>
Cc: Petr Lautrbach <plautrba@redhat.com>
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1794518
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
---
 policycoreutils/setfiles/setfiles.c | 11 +----------
 1 file changed, 1 insertion(+), 10 deletions(-)

Comments

Daniel Burgener April 28, 2022, 4:07 p.m. UTC | #1
On 4/28/2022 2:53 AM, Laszlo Ersek wrote:
> Commit 219eea83cea9 ("policycoreutils: setfiles/restorecon: fix -r/-R
> option", 2015-04-16) split the option strings between "setfiles" and
> "restorecon". Since that commit, an "iamrestorecon" check has only been
> necessary for an option that is (a) accepted by both "setfiles" and
> "restorecon", but (b) behaves differently between "setfiles" and
> "restorecon". Currently, the only such options are "-r" and "-R". Remove
> the "iamrestorecon" checks from the "setfiles"-only "-c" and "-d" options,
> and from the "restorecon"-only "-x" option.
> 
> Cc: "Richard W.M. Jones" <rjones@redhat.com>
> Cc: Petr Lautrbach <plautrba@redhat.com>
> Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1794518
> Signed-off-by: Laszlo Ersek <lersek@redhat.com>
> ---
>   policycoreutils/setfiles/setfiles.c | 11 +----------
>   1 file changed, 1 insertion(+), 10 deletions(-)
> 
> diff --git a/policycoreutils/setfiles/setfiles.c b/policycoreutils/setfiles/setfiles.c
> index cf504618d38f..aeec1fdcc2ab 100644
> --- a/policycoreutils/setfiles/setfiles.c
> +++ b/policycoreutils/setfiles/setfiles.c
> @@ -227,9 +227,6 @@ int main(int argc, char **argv)
>   			{
>   				FILE *policystream;
>   
> -				if (iamrestorecon)
> -					usage(argv[0]);
> -
>   				policyfile = optarg;
>   
>   				policystream = fopen(policyfile, "r");
> @@ -267,8 +264,6 @@ int main(int argc, char **argv)
>   			input_filename = optarg;
>   			break;
>   		case 'd':
> -			if (iamrestorecon)
> -				usage(argv[0]);
>   			r_opts.debug = 1;
>   			r_opts.log_matches =
>   					   SELINUX_RESTORECON_LOG_MATCHES;
> @@ -367,11 +362,7 @@ int main(int argc, char **argv)
>   			null_terminated = 1;
>   			break;
>   		case 'x':
> -			if (iamrestorecon) {
> -				r_opts.xdev = SELINUX_RESTORECON_XDEV;
> -			} else {
> -				usage(argv[0]);
> -			}
> +			r_opts.xdev = SELINUX_RESTORECON_XDEV;
>   			break;
>   		case 'T':
>   			nthreads = strtoull(optarg, &endptr, 10);

Reviewed-By: Daniel Burgener <dburgener@linux.microsoft.com>
diff mbox series

Patch

diff --git a/policycoreutils/setfiles/setfiles.c b/policycoreutils/setfiles/setfiles.c
index cf504618d38f..aeec1fdcc2ab 100644
--- a/policycoreutils/setfiles/setfiles.c
+++ b/policycoreutils/setfiles/setfiles.c
@@ -227,9 +227,6 @@  int main(int argc, char **argv)
 			{
 				FILE *policystream;
 
-				if (iamrestorecon)
-					usage(argv[0]);
-
 				policyfile = optarg;
 
 				policystream = fopen(policyfile, "r");
@@ -267,8 +264,6 @@  int main(int argc, char **argv)
 			input_filename = optarg;
 			break;
 		case 'd':
-			if (iamrestorecon)
-				usage(argv[0]);
 			r_opts.debug = 1;
 			r_opts.log_matches =
 					   SELINUX_RESTORECON_LOG_MATCHES;
@@ -367,11 +362,7 @@  int main(int argc, char **argv)
 			null_terminated = 1;
 			break;
 		case 'x':
-			if (iamrestorecon) {
-				r_opts.xdev = SELINUX_RESTORECON_XDEV;
-			} else {
-				usage(argv[0]);
-			}
+			r_opts.xdev = SELINUX_RESTORECON_XDEV;
 			break;
 		case 'T':
 			nthreads = strtoull(optarg, &endptr, 10);