]> git.ipfire.org Git - thirdparty/shadow.git/commitdiff
lib/, src/: Use strcaseeq() instead of its pattern
authorAlejandro Colomar <alx@kernel.org>
Sat, 8 Feb 2025 23:18:58 +0000 (00:18 +0100)
committerSerge Hallyn <serge@hallyn.com>
Sat, 15 Feb 2025 16:26:50 +0000 (10:26 -0600)
Signed-off-by: Alejandro Colomar <alx@kernel.org>
lib/getdef.c
src/login_nopam.c

index d234fe18b0c1cff6062775dcd0493b5c4bfe62b3..f5cf391f8d6f32de1e3eccda64e2227410fa78a7 100644 (file)
@@ -32,6 +32,7 @@
 #include "string/sprintf/xasprintf.h"
 #include "string/strchr/stpspn.h"
 #include "string/strchr/strrspn.h"
+#include "string/strcmp/strcaseeq.h"
 #include "string/strcmp/streq.h"
 #include "string/strtok/stpsep.h"
 
@@ -226,7 +227,7 @@ bool getdef_bool (const char *item)
                return false;
        }
 
-       return (strcasecmp (d->value, "yes") == 0);
+       return strcaseeq(d->value, "yes");
 }
 
 
index 896ab9410373243044c6f3a33a58e4d62d0f82dd..dfd6f1353004d8273f9b8869b84710a0b8170d29 100644 (file)
@@ -60,6 +60,7 @@
 #include "prototypes.h"
 #include "sizeof.h"
 #include "string/strchr/strrspn.h"
+#include "string/strcmp/strcaseeq.h"
 #include "string/strcmp/streq.h"
 #include "string/strtok/stpsep.h"
 
@@ -158,7 +159,7 @@ list_match(char *list, const char *item, bool (*match_fn)(char *, const char*))
         * affected by any exceptions.
         */
        while (NULL != (tok = strsep(&list, ", \t"))) {
-               if (strcasecmp (tok, "EXCEPT") == 0) {  /* EXCEPT: invert */
+               if (strcaseeq(tok, "EXCEPT")) {  /* EXCEPT: invert */
                        if (!matched) { /* stop processing: not part of list */
                                break;
                        }
@@ -232,7 +233,7 @@ static bool user_match (char *tok, const char *string)
        } else if ((group = getgrnam (tok)) != NULL) {  /* try group membership */
                int i;
                for (i = 0; NULL != group->gr_mem[i]; i++) {
-                       if (strcasecmp (string, group->gr_mem[i]) == 0) {
+                       if (strcaseeq(string, group->gr_mem[i])) {
                                return true;
                        }
                }
@@ -309,10 +310,10 @@ static bool from_match (char *tok, const char *string)
                str_len = strlen (string);
                tok_len = strlen (tok);
                if (   (str_len > tok_len)
-                   && (strcasecmp (tok, string + str_len - tok_len) == 0)) {
+                   && strcaseeq(tok, string + str_len - tok_len)) {
                        return true;
                }
-       } else if (strcasecmp (tok, "LOCAL") == 0) {    /* local: no dots */
+       } else if (strcaseeq(tok, "LOCAL")) {   /* LOCAL: no dots */
                if (strchr (string, '.') == NULL) {
                        return true;
                }
@@ -331,9 +332,9 @@ static bool string_match (const char *tok, const char *string)
         * If the token has the magic value "ALL" the match always succeeds.
         * Otherwise, return true if the token fully matches the string.
         */
-       if (strcasecmp (tok, "ALL") == 0) {     /* all: always matches */
+       if (strcaseeq(tok, "ALL")) {  /* ALL: always matches */
                return true;
-       } else if (strcasecmp (tok, string) == 0) {     /* try exact match */
+       } else if (strcaseeq(tok, string)) {  /* try exact match */
                return true;
        }
        return false;