Skip to contentSkip to conversation

libsemanage: make expand-check a proper boolean option

PATCH Superseded Kalevi Kolttonen 1 participant 1 message May 6 SELinux security module

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 libsemanage: make expand-check a proper boolean option

Make expand-check configuration option accept values 'true' and 'false' for consistency with the rest of the boolean options. Preserve backwards compatibility with old configuration file settings by still accepting the values "1" and "0".

---
 libsemanage/src/conf-parse.y    | 21 ++++++++++++---------
 libsemanage/src/semanage_conf.h |  2 +-
 2 files changed, 13 insertions(+), 10 deletions(-)
libsemanage/src/conf-parse.y +12 -9
index b69ac75b..2a63b101 100644
@@ -168,15 +168,18 @@ target_platform: TARGET_PLATFORM '=' ARG  {
         ;
 
 expand_check:   EXPAND_CHECK '=' ARG  {
-                        char *endptr;
-                        long value;
-                        errno = 0;
-                        value = strtol($3, &endptr, 10);
-                        if (*endptr != '\0' || errno != 0 || (value != 0 && value != 1))
-                                yyerror("expand-check can only be '1' or '0'");
-                        else
-                                current_conf->expand_check = value;
-                        free($3);
+	                if (strcasecmp($3, "true") == 0)
+		                current_conf->expand_check = true;
+			else if (strcmp($3, "1") == 0)
+		                current_conf->expand_check = true;
+			else if (strcasecmp($3, "false") == 0)
+		                current_conf->expand_check = false;
+			else if (strcmp($3, "0") == 0)
+		                current_conf->expand_check = false;
+			else {
+				yyerror("expand-check can only be 'true' or 'false'");
+			}
+			free($3);
                 }
         ;
 
libsemanage/src/semanage_conf.h +1 -1
index 2388faad..3b16af4e 100644
@@ -36,7 +36,7 @@ typedef struct semanage_conf {
 	int server_port;
 	int policyvers;		/* version for server generated policies */
 	int target_platform;
-	int expand_check;
+	bool expand_check;
 	int save_previous;
 	int save_linked;
 	int disable_genhomedircon;
Signature · 1 line
2.54.0