]> git.ipfire.org Git - thirdparty/shadow.git/commitdiff
contrib/, lib/, src/: Use streq() instead of its pattern
authorAlejandro Colomar <alx@kernel.org>
Sun, 17 Nov 2024 02:17:41 +0000 (03:17 +0100)
committerSerge Hallyn <serge@hallyn.com>
Mon, 2 Dec 2024 04:23:19 +0000 (22:23 -0600)
Except for the added (and sorted) includes, and the removal of redundant
parentheses, this patch can be approximated with the following semantic
patch:

$ cat ~/tmp/spatch/streq.sp;
@@
expression a, b;
@@

- strcmp(a, b) == 0
+ streq(a, b)

@@
expression a, b;
@@

- 0 == strcmp(a, b)
+ streq(a, b)

@@
expression a, b;
@@

- !strcmp(a, b)
+ streq(a, b)

$ find contrib/ lib* src/ -type f \
| xargs spatch --sp-file ~/tmp/spatch/streq.sp --in-place;
$ git restore lib/string/strcmp/streq.h;

Signed-off-by: Alejandro Colomar <alx@kernel.org>
52 files changed:
contrib/adduser.c
lib/chowndir.c
lib/commonio.c
lib/console.c
lib/copydir.c
lib/getdate.y
lib/getdef.c
lib/groupio.c
lib/gshadow.c
lib/hushed.c
lib/idmapping.c
lib/isexpired.c
lib/limits.c
lib/list.c
lib/nss.c
lib/obscure.c
lib/port.c
lib/prefix_flag.c
lib/remove_tree.c
lib/root_flag.c
lib/salt.c
lib/shadow.c
lib/subordinateio.c
lib/tcbfuncs.c
lib/ttytype.c
lib/user_busy.c
lib/utmp.c
lib/valid.c
src/chage.c
src/chfn.c
src/chgpasswd.c
src/chpasswd.c
src/chsh.c
src/get_subid_owners.c
src/getsubids.c
src/gpasswd.c
src/groupmems.c
src/groupmod.c
src/grpck.c
src/grpunconv.c
src/login.c
src/newgrp.c
src/newusers.c
src/passwd.c
src/pwconv.c
src/pwunconv.c
src/su.c
src/suauth.c
src/useradd.c
src/userdel.c
src/usermod.c
src/vipw.c

index 444f8d6ec8b8b0c6d5005662b96da7caa9d96c61..8061c76a4460464f91983b8e0e8a61ce71a8cc55 100644 (file)
 #include <sys/stat.h>
 #include <syslog.h>
 
+#include "string/strcmp/streq.h"
+
 
 #define IMMEDIATE_CHANGE       /* Expire newly created password, must be changed
                                 * immediately upon next login */
@@ -315,7 +317,7 @@ main (void)
 #ifdef HAVE_GETUSERSHELL
          setusershell ();
          while ((sh = getusershell ()) != NULL)
-           if (!strcmp (shell, sh))
+           if (streq(shell, sh))
              ok = 1;
          endusershell ();
 #endif
index d31618a56244080a308be0c42dadb2dc8fe40d4a..91fc657e619070911cbbda0b290bacc928daea74 100644 (file)
 
 #include <sys/types.h>
 #include <sys/stat.h>
-#include "prototypes.h"
-#include "defines.h"
 #include <fcntl.h>
 #include <stdio.h>
 #include <unistd.h>
 
+#include "defines.h"
+#include "prototypes.h"
+#include "string/strcmp/streq.h"
+
+
 static int chown_tree_at (int at_fd,
                 const char *path,
                 uid_t old_uid,
@@ -56,8 +59,8 @@ static int chown_tree_at (int at_fd,
                /*
                 * Skip the "." and ".." entries
                 */
-               if (   (strcmp (ent->d_name, ".") == 0)
-                   || (strcmp (ent->d_name, "..") == 0)) {
+               if (   streq(ent->d_name, ".")
+                   || streq(ent->d_name, "..")) {
                        continue;
                }
 
index edf12866f2592f3e31c620e2dec837fc2fafb374..4d83e83cb987edc7155c730a6fa04f8dfc5f6421 100644 (file)
@@ -36,6 +36,7 @@
 #include "sssd.h"
 #include "string/memset/memzero.h"
 #include "string/sprintf/snprintf.h"
+#include "string/strcmp/streq.h"
 #include "string/strtok/stpsep.h"
 
 
@@ -830,10 +831,8 @@ int commonio_sort_wrt (struct commonio_db *shadow,
                        if (NULL == spw_ptr->eptr) {
                                continue;
                        }
-                       if (strcmp (name, shadow->ops->getname (spw_ptr->eptr))
-                           == 0) {
+                       if (streq(name, shadow->ops->getname(spw_ptr->eptr)))
                                break;
-                       }
                }
                if (NULL == spw_ptr) {
                        continue;
@@ -1034,7 +1033,7 @@ static /*@dependent@*/ /*@null@*/struct commonio_entry *next_entry_by_name (
        for (p = pos; NULL != p; p = p->next) {
                ep = p->eptr;
                if (   (NULL != ep)
-                   && (strcmp (db->ops->getname (ep), name) == 0)) {
+                   && streq(db->ops->getname(ep), name)) {
                        break;
                }
        }
index 7903caa9de5077eb4d1de7e286a643a3ead9e248..b9f088d2d3517a829d9819e3c7d90d2033e41375 100644 (file)
@@ -16,6 +16,7 @@
 #include "defines.h"
 #include "getdef.h"
 #include "prototypes.h"
+#include "string/strcmp/streq.h"
 #include "string/strcpy/strtcpy.h"
 #include "string/strtok/stpsep.h"
 
@@ -51,7 +52,7 @@ static bool is_listed (const char *cfgin, const char *tty, bool def)
                STRTCPY(buf, cons);
                pbuf = &buf[0];
                while ((s = strtok (pbuf, ":")) != NULL) {
-                       if (strcmp (s, tty) == 0) {
+                       if (streq(s, tty)) {
                                return true;
                        }
 
@@ -76,7 +77,7 @@ static bool is_listed (const char *cfgin, const char *tty, bool def)
 
        while (fgets (buf, sizeof (buf), fp) != NULL) {
                stpsep(buf, "\n");
-               if (strcmp (buf, tty) == 0) {
+               if (streq(buf, tty)) {
                        (void) fclose (fp);
                        return true;
                }
index c1c3c8af6b700e4539d853ad755a464909cfd1df..6312399e5b3395f8aec2ecf1ccd64935a288ed04 100644 (file)
@@ -39,6 +39,7 @@
 #endif                         /* WITH_ATTR */
 #include "shadowlog.h"
 #include "string/sprintf/xasprintf.h"
+#include "string/strcmp/streq.h"
 
 
 static /*@null@*/const char *src_orig;
@@ -314,8 +315,8 @@ static int copy_tree_impl (const struct path_info *src, const struct path_info *
                /*
                 * Skip the "." and ".." entries
                 */
-               if (strcmp(ent->d_name, ".") == 0 ||
-                   strcmp(ent->d_name, "..") == 0)
+               if (streq(ent->d_name, ".") ||
+                   streq(ent->d_name, ".."))
                {
                        continue;
                }
index 385e55c692841fda77beff3baa0641fc036a9ae3..9a7e1d36fb2053a6f0d16f55189ff3520683b26f 100644 (file)
@@ -32,6 +32,7 @@
 #include "attr.h"
 #include "getdate.h"
 #include "string/strchr/stpspn.h"
+#include "string/strcmp/streq.h"
 
 
 /* Some old versions of bison generate parsers that use bcopy.
@@ -630,12 +631,12 @@ static int LookupWord (char *buff)
     if (isupper (*p))
       *p = tolower (*p);
 
-  if (strcmp (buff, "am") == 0 || strcmp (buff, "a.m.") == 0)
+  if (streq(buff, "am") || streq(buff, "a.m."))
     {
       yylval.Meridian = MERam;
       return tMERIDIAN;
     }
-  if (strcmp (buff, "pm") == 0 || strcmp (buff, "p.m.") == 0)
+  if (streq(buff, "pm") || streq(buff, "p.m."))
     {
       yylval.Meridian = MERpm;
       return tMERIDIAN;
@@ -662,7 +663,7 @@ static int LookupWord (char *buff)
              return tp->type;
            }
        }
-      else if (strcmp (buff, tp->name) == 0)
+      else if (streq(buff, tp->name))
        {
          yylval.Number = tp->value;
          return tp->type;
@@ -670,17 +671,17 @@ static int LookupWord (char *buff)
     }
 
   for (tp = TimezoneTable; tp->name; tp++)
-    if (strcmp (buff, tp->name) == 0)
+    if (streq(buff, tp->name))
       {
        yylval.Number = tp->value;
        return tp->type;
       }
 
-  if (strcmp (buff, "dst") == 0)
+  if (streq(buff, "dst"))
     return tDST;
 
   for (tp = UnitsTable; tp->name; tp++)
-    if (strcmp (buff, tp->name) == 0)
+    if (streq(buff, tp->name))
       {
        yylval.Number = tp->value;
        return tp->type;
@@ -692,7 +693,7 @@ static int LookupWord (char *buff)
     {
       stpcpy(&buff[i], "");
       for (tp = UnitsTable; tp->name; tp++)
-       if (strcmp (buff, tp->name) == 0)
+       if (streq(buff, tp->name))
          {
            yylval.Number = tp->value;
            return tp->type;
@@ -701,7 +702,7 @@ static int LookupWord (char *buff)
     }
 
   for (tp = OtherTable; tp->name; tp++)
-    if (strcmp (buff, tp->name) == 0)
+    if (streq(buff, tp->name))
       {
        yylval.Number = tp->value;
        return tp->type;
@@ -711,7 +712,7 @@ static int LookupWord (char *buff)
   if (buff[1] == '\0' && isalpha (*buff))
     {
       for (tp = MilitaryTable; tp->name; tp++)
-       if (strcmp (buff, tp->name) == 0)
+       if (streq(buff, tp->name))
          {
            yylval.Number = tp->value;
            return tp->type;
@@ -727,7 +728,7 @@ static int LookupWord (char *buff)
   stpcpy(p, "");
   if (0 != i)
     for (tp = TimezoneTable; NULL != tp->name; tp++)
-      if (strcmp (buff, tp->name) == 0)
+      if (streq(buff, tp->name))
        {
          yylval.Number = tp->value;
          return tp->type;
index e667a39becf571a833f38c566accc19c4440f2a2..c59e8807fea34f9118a39455fd70f6dddbe389ad 100644 (file)
@@ -32,6 +32,7 @@
 #include "string/sprintf/xasprintf.h"
 #include "string/strchr/stpspn.h"
 #include "string/strchr/strrspn.h"
+#include "string/strcmp/streq.h"
 #include "string/strtok/stpsep.h"
 
 
@@ -419,7 +420,7 @@ static /*@observer@*/ /*@null@*/struct itemdef *def_find (const char *name, cons
         */
 
        for (ptr = def_table; NULL != ptr->name; ptr++) {
-               if (strcmp (ptr->name, name) == 0) {
+               if (streq(ptr->name, name)) {
                        return ptr;
                }
        }
@@ -429,7 +430,7 @@ static /*@observer@*/ /*@null@*/struct itemdef *def_find (const char *name, cons
         */
 
        for (ptr = knowndef_table; NULL != ptr->name; ptr++) {
-               if (strcmp (ptr->name, name) == 0) {
+               if (streq(ptr->name, name)) {
                        goto out;
                }
        }
index 3984b4af5be2341c8c1615887cf49a4f64d42d94..516e3ccd243258d5f6ef8073bfc234be239e4702 100644 (file)
 
 #include "alloc/calloc.h"
 #include "alloc/malloc.h"
-#include "prototypes.h"
-#include "defines.h"
 #include "commonio.h"
+#include "defines.h"
 #include "getdef.h"
 #include "groupio.h"
+#include "prototypes.h"
+#include "string/strcmp/streq.h"
 
 
 static /*@null@*/struct commonio_entry *merge_group_entries (
@@ -263,8 +264,8 @@ static int group_open_hook (void)
                        struct group *g2 = gr2->eptr;
                        if (NULL != g1 &&
                            NULL != g2 &&
-                           0 == strcmp (g1->gr_name, g2->gr_name) &&
-                           0 == strcmp (g1->gr_passwd, g2->gr_passwd) &&
+                           streq(g1->gr_name, g2->gr_name) &&
+                           streq(g1->gr_passwd, g2->gr_passwd) &&
                            g1->gr_gid == g2->gr_gid) {
                                /* Both group entries refer to the same
                                 * group. It is a split group. Merge the
@@ -332,7 +333,7 @@ static /*@null@*/struct commonio_entry *merge_group_entries (
        for (i=0; NULL != gptr2->gr_mem[i]; i++) {
                char **pmember = gptr1->gr_mem;
                while (NULL != *pmember) {
-                       if (0 == strcmp(*pmember, gptr2->gr_mem[i])) {
+                       if (streq(*pmember, gptr2->gr_mem[i])) {
                                break;
                        }
                        pmember++;
@@ -355,7 +356,7 @@ static /*@null@*/struct commonio_entry *merge_group_entries (
        for (i=0; NULL != gptr2->gr_mem[i]; i++) {
                char **pmember = new_members;
                while (NULL != *pmember) {
-                       if (0 == strcmp(*pmember, gptr2->gr_mem[i])) {
+                       if (streq(*pmember, gptr2->gr_mem[i])) {
                                break;
                        }
                        pmember++;
index 8e9d6c8274ab7885e2e005a8e0bbf0be05b869d3..5a89ca2fbe1a5ebd4730b6ede58a852baa12adb2 100644 (file)
@@ -22,6 +22,7 @@
 #include "alloc/x/xrealloc.h"
 #include "defines.h"
 #include "prototypes.h"
+#include "string/strcmp/streq.h"
 #include "string/strtok/stpsep.h"
 
 
@@ -203,7 +204,7 @@ void endsgent (void)
        setsgent ();
 
        while ((sgrp = getsgent ()) != NULL) {
-               if (strcmp (name, sgrp->sg_name) == 0) {
+               if (streq(name, sgrp->sg_name)) {
                        break;
                }
        }
index caa687575aa1f5916cbd78fc951d6899056fa80f..526e0f298000358c92967da08d0c601966d2ab41 100644 (file)
@@ -21,6 +21,7 @@
 #include "getdef.h"
 #include "prototypes.h"
 #include "string/sprintf/snprintf.h"
+#include "string/strcmp/streq.h"
 #include "string/strtok/stpsep.h"
 
 
@@ -74,8 +75,8 @@ bool hushed (const char *username)
        }
        for (found = false; !found && (fgets (buf, sizeof buf, fp) == buf);) {
                stpsep(buf, "\n");
-               found = (strcmp (buf, pw->pw_shell) == 0) ||
-                       (strcmp (buf, pw->pw_name) == 0);
+               found = streq(buf, pw->pw_shell) ||
+                       streq(buf, pw->pw_name);
        }
        (void) fclose (fp);
        return found;
index a46c8c2480c33f90d98651da38e81e50a3ace20a..89c03b10113b770b105de627872fae051b14f720 100644 (file)
 #include <stdlib.h>
 #include <stdio.h>
 #include <strings.h>
+#if HAVE_SYS_CAPABILITY_H
+#include <sys/prctl.h>
+#include <sys/capability.h>
+#endif
 
 #include "alloc/calloc.h"
 #include "alloc/x/xmalloc.h"
 #include "atoi/a2i/a2u.h"
-#include "prototypes.h"
-#include "string/sprintf/stpeprintf.h"
 #include "idmapping.h"
-#if HAVE_SYS_CAPABILITY_H
-#include <sys/prctl.h>
-#include <sys/capability.h>
-#endif
+#include "prototypes.h"
 #include "shadowlog.h"
 #include "sizeof.h"
+#include "string/sprintf/stpeprintf.h"
+#include "string/strcmp/streq.h"
 
 
 struct map_range *
@@ -133,9 +134,9 @@ void write_mapping(int proc_dir_fd, int ranges, const struct map_range *mappings
        struct __user_cap_header_struct hdr = {_LINUX_CAPABILITY_VERSION_3, 0};
        struct __user_cap_data_struct data[2] = {{0}};
 
-       if (strcmp(map_file, "uid_map") == 0) {
+       if (streq(map_file, "uid_map")) {
                cap = CAP_SETUID;
-       } else if (strcmp(map_file, "gid_map") == 0) {
+       } else if (streq(map_file, "gid_map")) {
                cap = CAP_SETGID;
        } else {
                fprintf(log_get_logfd(), _("%s: Invalid map file %s specified\n"), log_get_progname(), map_file);
index c275691f7267065cc9536c1a39ded38193cd8b2b..f69938a132aad73786b8c8fce8534de163a64a3b 100644 (file)
@@ -21,6 +21,7 @@
 #include "adds.h"
 #include "defines.h"
 #include "prototypes.h"
+#include "string/strcmp/streq.h"
 
 #ident "$Id$"
 
@@ -67,7 +68,7 @@ int isexpired (const struct passwd *pw, /*@null@*/const struct spwd *sp)
         * returns sp_lstchg==0 (must change password) instead of -1!
         */
        if (   (0 == sp->sp_lstchg)
-           && (strcmp (pw->pw_passwd, SHADOW_PASSWD_STRING) == 0)) {
+           && streq(pw->pw_passwd, SHADOW_PASSWD_STRING)) {
                return 1;
        }
 
index 74398bd82b5d4c368da31cf9098e55805c0511d7..5a98a1295d1dda0d6a9146c25aa0343ac3c500b9 100644 (file)
@@ -37,6 +37,7 @@
 #include "atoi/str2i/str2u.h"
 #include "string/memset/memzero.h"
 #include "string/strchr/stpspn.h"
+#include "string/strcmp/streq.h"
 #include "typetraits.h"
 
 
@@ -194,7 +195,7 @@ static int do_user_limits (const char *buf, const char *name)
         * being ignored if a limit type is not known to the system.
         * Though, there will be complaining for unknown limit types.
         */
-       if (strcmp (pp, "-") == 0) {
+       if (streq(pp, "-")) {
                /* Remember to extend this, too, when adding new limits!
                 * Oh... but "unlimited" does not make sense for umask,
                 * or does it? (K-)
@@ -395,10 +396,10 @@ static int setup_user_limits (const char *uname)
                 */
                if (sscanf (buf, "%s%[ACDFIKLMNOPRSTUacdfiklmnoprstu0-9 \t-]",
                            name, tempbuf) == 2) {
-                       if (strcmp (name, uname) == 0) {
+                       if (streq(name, uname)) {
                                strcpy (limits, tempbuf);
                                break;
-                       } else if (strcmp (name, "*") == 0) {
+                       } else if (streq(name, "*")) {
                                strcpy (deflimits, tempbuf);
                        } else if (name[0] == '@') {
                                /* If the user is in the group, the group
@@ -436,7 +437,7 @@ static void setup_usergroups (const struct passwd *info)
                /* local, no need for xgetgrgid */
                grp = getgrgid (info->pw_gid);
                if (   (NULL != grp)
-                   && (strcmp (info->pw_name, grp->gr_name) == 0)) {
+                   && streq(info->pw_name, grp->gr_name)) {
                        mode_t tmpmask;
                        tmpmask = umask (0777);
                        tmpmask = (tmpmask & ~070) | ((tmpmask >> 3) & 070);
index fbc0e14a4648c4a60b031df0791722c288a7ba47..466bf7bf4128b3a1ef536eebacf02a8ed6af9d44 100644 (file)
@@ -16,6 +16,7 @@
 #include "prototypes.h"
 #include "defines.h"
 #include "string/strchr/strchrcnt.h"
+#include "string/strcmp/streq.h"
 #include "string/strdup/xstrdup.h"
 
 
@@ -41,7 +42,7 @@ add_list(/*@returned@*/ /*@only@*/char **list, const char *member)
         */
 
        for (i = 0; list[i] != NULL; i++) {
-               if (strcmp (list[i], member) == 0) {
+               if (streq(list[i], member)) {
                        return list;
                }
        }
@@ -167,7 +168,7 @@ bool is_on_list (char *const *list, const char *member)
        assert (NULL != list);
 
        while (NULL != *list) {
-               if (strcmp (*list, member) == 0) {
+               if (streq(*list, member)) {
                        return true;
                }
                list++;
index f0fcc026ac51d2052474bdaf6b30f408e039e43a..9373bba3328ef1f6ae64e02d76ff9b485f1f5097 100644 (file)
--- a/lib/nss.c
+++ b/lib/nss.c
@@ -15,8 +15,9 @@
 #include "shadowlog_internal.h"
 #include "shadowlog.h"
 #include "string/sprintf/snprintf.h"
-#include "string/strtok/stpsep.h"
 #include "string/strchr/stpspn.h"
+#include "string/strcmp/streq.h"
+#include "string/strtok/stpsep.h"
 
 
 #define NSSWITCH "/etc/nsswitch.conf"
@@ -98,7 +99,7 @@ nss_init(const char *nsswitch_path) {
                // subid_nss has to be null here, but to ease reviews:
                goto null_subid;
        }
-       if (strcmp(p, "files") == 0) {
+       if (streq(p, "files")) {
                goto null_subid;
        }
        if (strlen(p) > 50) {
index 59babd4bc4afe5f7526b434b87f6372b5b707c95..66b2361c3953863f4dcb4c2d8bf608cba0799210 100644 (file)
@@ -21,6 +21,7 @@
 #include "getdef.h"
 #include "string/memset/memzero.h"
 #include "string/sprintf/xasprintf.h"
+#include "string/strcmp/streq.h"
 #include "string/strdup/xstrdup.h"
 
 
@@ -95,7 +96,7 @@ static /*@observer@*//*@null@*/const char *password_check (
        const char *msg = NULL;
        char *oldmono, *newmono, *wrapped;
 
-       if (strcmp (new, old) == 0) {
+       if (streq(new, old)) {
                return _("no change");
        }
 
@@ -105,7 +106,7 @@ static /*@observer@*//*@null@*/const char *password_check (
 
        if (palindrome (oldmono, newmono)) {
                msg = _("a palindrome");
-       } else if (strcmp (oldmono, newmono) == 0) {
+       } else if (streq(oldmono, newmono)) {
                msg = _("case changes only");
        } else if (similar (oldmono, newmono)) {
                msg = _("too similar");
@@ -162,16 +163,16 @@ static /*@observer@*//*@null@*/const char *obscure_msg (
 
        } else {
 
-               if (   (strcmp (result, "MD5")    == 0)
+               if (   streq(result, "MD5")
 #ifdef USE_SHA_CRYPT
-                   || (strcmp (result, "SHA256") == 0)
-                   || (strcmp (result, "SHA512") == 0)
+                   || streq(result, "SHA256")
+                   || streq(result, "SHA512")
 #endif
 #ifdef USE_BCRYPT
-                   || (strcmp (result, "BCRYPT") == 0)
+                   || streq(result, "BCRYPT")
 #endif
 #ifdef USE_YESCRYPT
-                   || (strcmp (result, "YESCRYPT") == 0)
+                   || streq(result, "YESCRYPT")
 #endif
                    ) {
                        return NULL;
index f56923e0000ae5358888d9dbe0696b5d21f6ca26..52ed67e87884d38b7041cbcd5d2b43b5d554f9a7 100644 (file)
@@ -19,6 +19,7 @@
 #include "defines.h"
 #include "port.h"
 #include "prototypes.h"
+#include "string/strcmp/streq.h"
 #include "string/strtok/stpsep.h"
 
 
@@ -46,7 +47,7 @@ static int portcmp (const char *pattern, const char *port)
        if (('\0' == *pattern) && ('\0' == *port)) {
                return 0;
        }
-       if (strcmp(orig, "SU") == 0)
+       if (streq(orig, "SU"))
                return 1;
 
        return (*pattern == '*') ? 0 : 1;
@@ -339,9 +340,9 @@ getttyuser(const char *tty, const char *user)
                        continue;
 
                for (ptu = port->pt_users; *ptu != NULL; ptu++) {
-                       if (strcmp(*ptu, user) == 0)
+                       if (streq(*ptu, user))
                                goto end;
-                       if (strcmp(*ptu, "*") == 0)
+                       if (streq(*ptu, "*"))
                                goto end;
                }
        }
index 57d24332b0f63acf4bd59fbbd2e659676f000de8..ea0a0d7230283418fcbd0e3049c15ad9e65aaf09 100644 (file)
@@ -29,6 +29,7 @@
 #include "getdef.h"
 #include "shadowlog.h"
 #include "string/sprintf/xasprintf.h"
+#include "string/strcmp/streq.h"
 
 
 static char *passwd_db_file = NULL;
@@ -60,10 +61,11 @@ extern const char* process_prefix_flag (const char* short_opt, int argc, char **
 
        for (i = 0; i < argc; i++) {
                val = NULL;
-               if (   (strcmp (argv[i], "--prefix") == 0)
+               if (   streq(argv[i], "--prefix")
                    || ((strncmp (argv[i], "--prefix=", 9) == 0)
                        && (val = argv[i] + 9))
-                   || (strcmp (argv[i], short_opt) == 0)) {
+                   || streq(argv[i], short_opt))
+               {
                        if (NULL != prefix) {
                                fprintf (log_get_logfd(),
                                         _("%s: multiple --prefix options\n"),
@@ -96,7 +98,7 @@ extern const char* process_prefix_flag (const char* short_opt, int argc, char **
                        exit (EXIT_FAILURE);
                }
 
-               if ( prefix[0] == '\0' || !strcmp(prefix, "/"))
+               if (prefix[0] == '\0' || streq(prefix, "/"))
                        return ""; /* if prefix is "/" then we ignore the flag option */
                /* should we prevent symbolic link from being used as a prefix? */
 
@@ -153,7 +155,7 @@ extern struct group *prefix_getgrnam(const char *name)
                if (!fg)
                        return NULL;
                while ((grp = fgetgrent(fg)) != NULL) {
-                       if (!strcmp(name, grp->gr_name))
+                       if (streq(name, grp->gr_name))
                                break;
                }
                fclose(fg);
@@ -213,7 +215,7 @@ extern struct passwd *prefix_getpwnam(const char* name)
                if (!fg)
                        return NULL;
                while ((pwd = fgetpwent(fg)) != NULL) {
-                       if (!strcmp(name, pwd->pw_name))
+                       if (streq(name, pwd->pw_name))
                                break;
                }
                fclose(fg);
@@ -235,7 +237,7 @@ extern int prefix_getpwnam_r(const char* name, struct passwd* pwd,
                if (!fg)
                        return errno;
                while ((ret = fgetpwent_r(fg, pwd, buf, buflen, result)) == 0) {
-                       if (!strcmp(name, pwd->pw_name))
+                       if (streq(name, pwd->pw_name))
                                break;
                }
                fclose(fg);
@@ -256,7 +258,7 @@ extern struct spwd *prefix_getspnam(const char* name)
                if (!fg)
                        return NULL;
                while ((sp = fgetspent(fg)) != NULL) {
-                       if (!strcmp(name, sp->sp_namp))
+                       if (streq(name, sp->sp_namp))
                                break;
                }
                fclose(fg);
index 3d76b95e010296167b96795be1afe2f798f0525a..ce07b40cf0b5b509dd5d35f73d20536a4b812e6e 100644 (file)
 #include <sys/stat.h>
 #include <dirent.h>
 #include <unistd.h>
-#include "prototypes.h"
+
 #include "defines.h"
+#include "prototypes.h"
+#include "string/strcmp/streq.h"
+
 
 static int remove_tree_at (int at_fd, const char *path, bool remove_root)
 {
@@ -48,8 +51,8 @@ static int remove_tree_at (int at_fd, const char *path, bool remove_root)
                /*
                 * Skip the "." and ".." entries
                 */
-               if (strcmp (ent->d_name, ".") == 0 ||
-                   strcmp (ent->d_name, "..") == 0) {
+               if (streq(ent->d_name, ".") ||
+                   streq(ent->d_name, "..")) {
                        continue;
                }
 
index 5572831a064a8cb5dc942aff3b4347cd31088031..f63aa6496a8336042e487ebde5a6e5a1381c8b27 100644 (file)
 #ident "$Id$"
 
 #include <stdio.h>
-#include <assert.h>
+
 #include "defines.h"
-#include "prototypes.h"
 /*@-exitarg@*/
 #include "exitcodes.h"
+#include "prototypes.h"
 #include "shadowlog.h"
+#include "string/strcmp/streq.h"
+
+#include <assert.h>
+
 
 static void change_root (const char* newroot);
 
@@ -38,10 +42,10 @@ extern void process_root_flag (const char* short_opt, int argc, char **argv)
 
        for (i = 0; i < argc; i++) {
                val = NULL;
-               if (   (strcmp (argv[i], "--root") == 0)
+               if (   streq(argv[i], "--root")
                    || ((strncmp (argv[i], "--root=", 7) == 0)
                        && (val = argv[i] + 7))
-                   || (strcmp (argv[i], short_opt) == 0)) {
+                   || streq(argv[i], short_opt)) {
                        if (NULL != newroot) {
                                fprintf (log_get_logfd(),
                                         _("%s: multiple --root options\n"),
index efef4e59ca4f123600a8bddc65cecdaf34754c95..8acaa5748478445b7e62d248ec81b854283045e0 100644 (file)
 #include <string.h>
 #include <strings.h>
 
-#include "prototypes.h"
 #include "defines.h"
 #include "getdef.h"
+#include "prototypes.h"
 #include "shadowlog.h"
+#include "string/strcmp/streq.h"
+
 
 #if (defined CRYPT_GENSALT_IMPLEMENTS_AUTO_ENTROPY && \
      CRYPT_GENSALT_IMPLEMENTS_AUTO_ENTROPY)
@@ -372,31 +374,31 @@ static /*@observer@*/const char *gensalt (size_t salt_size)
                }
        }
 
-       if (0 == strcmp (method, "MD5")) {
+       if (streq(method, "MD5")) {
                MAGNUM(result, '1');
                salt_len = MD5_CRYPT_SALT_SIZE;
                rounds = 0;
 #ifdef USE_BCRYPT
-       } else if (0 == strcmp (method, "BCRYPT")) {
+       } else if (streq(method, "BCRYPT")) {
                BCRYPTMAGNUM(result);
                salt_len = BCRYPT_SALT_SIZE;
                rounds = BCRYPT_get_salt_rounds (arg);
                BCRYPT_salt_rounds_to_buf (result, rounds);
 #endif /* USE_BCRYPT */
 #ifdef USE_YESCRYPT
-       } else if (0 == strcmp (method, "YESCRYPT")) {
+       } else if (streq(method, "YESCRYPT")) {
                MAGNUM(result, 'y');
                salt_len = YESCRYPT_SALT_SIZE;
                rounds = YESCRYPT_get_salt_cost (arg);
                YESCRYPT_salt_cost_to_buf (result, rounds);
 #endif /* USE_YESCRYPT */
 #ifdef USE_SHA_CRYPT
-       } else if (0 == strcmp (method, "SHA256")) {
+       } else if (streq(method, "SHA256")) {
                MAGNUM(result, '5');
                salt_len = SHA_CRYPT_SALT_SIZE;
                rounds = SHA_get_salt_rounds (arg);
                SHA_salt_rounds_to_buf (result, rounds);
-       } else if (0 == strcmp (method, "SHA512")) {
+       } else if (streq(method, "SHA512")) {
                MAGNUM(result, '6');
                salt_len = SHA_CRYPT_SALT_SIZE;
                rounds = SHA_get_salt_rounds (arg);
index 1047f0e0fbc037ea0e02672ddcecc45d2a6e0a59..3bacd204c3844366257307aed135093ecd81a0b3 100644 (file)
@@ -22,6 +22,7 @@
 #include "atoi/str2i/str2u.h"
 #include "defines.h"
 #include "prototypes.h"
+#include "string/strcmp/streq.h"
 #include "string/strtok/stpsep.h"
 
 
@@ -100,7 +101,7 @@ struct spwd *getspnam (const char *name)
        setspent ();
 
        while ((sp = getspent ()) != NULL) {
-               if (strcmp (name, sp->sp_namp) == 0) {
+               if (streq(name, sp->sp_namp)) {
                        break;
                }
        }
index 295df2bd4823c4877d15a0d4805a5d5761676daa..45085481acfdb5649349a994e0a0be8f7019ed99 100644 (file)
@@ -23,6 +23,7 @@
 #include "alloc/reallocf.h"
 #include "atoi/str2i/str2u.h"
 #include "string/sprintf/snprintf.h"
+#include "string/strcmp/streq.h"
 
 
 #define ID_SIZE 31
@@ -161,7 +162,7 @@ static bool range_exists(struct commonio_db *db, const char *owner)
        const struct subordinate_range *range;
        commonio_rewind(db);
        while ((range = commonio_next(db)) != NULL) {
-               if (0 == strcmp(range->owner, owner))
+               if (streq(range->owner, owner))
                        return true;
        }
        return false;
@@ -246,7 +247,7 @@ static const struct subordinate_range *find_range(struct commonio_db *db,
                  * Range matches. Check if range owner is specified
                  * as numeric UID and if it matches.
                  */
-                if (0 == strcmp(range->owner, owner_uid_string)) {
+                if (streq(range->owner, owner_uid_string)) {
                         return range;
                 }
 
@@ -889,7 +890,7 @@ int list_owner_ranges(const char *owner, enum subid_type id_type, struct subid_r
 
        commonio_rewind(db);
        while ((range = commonio_next(db)) != NULL) {
-               if (0 == strcmp(range->owner, owner)) {
+               if (streq(range->owner, owner)) {
                        if (!append_range(&ranges, range, count++)) {
                                free(ranges);
                                ranges = NULL;
@@ -899,7 +900,7 @@ int list_owner_ranges(const char *owner, enum subid_type id_type, struct subid_r
                }
 
                // Let's also compare with the ID
-               if (have_owner_id == true && 0 == strcmp(range->owner, id)) {
+               if (have_owner_id == true && streq(range->owner, id)) {
                        if (!append_range(&ranges, range, count++)) {
                                free(ranges);
                                ranges = NULL;
index 6971ebe840dd776ab45f727d49bf69bd6e2ba046..c8a6f8d816613dc6c2aee0c86f251985026d163b 100644 (file)
@@ -5,6 +5,8 @@
 
 #define _GNU_SOURCE
 
+#include <config.h>
+
 #include <errno.h>
 #include <fcntl.h>
 #include <grp.h>
 #include <tcb.h>
 #include <unistd.h>
 
-#include "config.h"
-
 #include "defines.h"
-#include "prototypes.h"
 #include "fs/readlink/readlinknul.h"
 #include "getdef.h"
-#include "shadowio.h"
+#include "prototypes.h"
 #include "tcbfuncs.h"
+#include "shadowio.h"
 #include "shadowlog_internal.h"
+#include "string/strcmp/streq.h"
 
 
 #define SHADOWTCB_HASH_BY 1000
@@ -308,7 +309,7 @@ static shadowtcb_status move_dir (const char *user_newname, uid_t user_newid)
        if (NULL == real_new_dir) {
                goto out_free;
        }
-       if (strcmp (real_old_dir, real_new_dir) == 0) {
+       if (streq(real_old_dir, real_new_dir)) {
                ret = SHADOWTCB_SUCCESS;
                goto out_free;
        }
index 850cb8d8acbc0a135a9fa0a88678d38051515c6d..fbe71ee001772982aa9f1d0b52dee6244893cc73 100644 (file)
@@ -17,6 +17,7 @@
 #include "defines.h"
 #include "getdef.h"
 #include "prototypes.h"
+#include "string/strcmp/streq.h"
 #include "string/strtok/stpsep.h"
 
 
@@ -53,7 +54,7 @@ void ttytype (const char *line)
                stpsep(buf, "\n");
 
                if (   (sscanf (buf, "%1023s %1023s", type, port) == 2)
-                   && (strcmp (line, port) == 0)) {
+                   && streq(line, port)) {
                        break;
                }
        }
index 43cff5b0735fbf57234de1c8ca824ce450346bc8..73c380bccab16d2c4b3322d3495ddd43486b3103 100644 (file)
@@ -28,6 +28,7 @@
 #endif                         /* ENABLE_SUBIDS */
 #include "shadowlog.h"
 #include "string/sprintf/snprintf.h"
+#include "string/strcmp/streq.h"
 
 
 #ifdef __linux__
@@ -103,7 +104,7 @@ static int different_namespace (const char *sname)
        if (READLINKNUL("/proc/self/ns/user", buf2) == -1)
                return 0;
 
-       if (strcmp(buf, buf2) == 0)
+       if (streq(buf, buf2))
                return 0; /* same namespace */
 
        return 1;
@@ -199,8 +200,8 @@ static int user_busy_processes (const char *name, uid_t uid)
                 * This patch is applied by default in some RedHat
                 * kernels.
                 */
-               if (   (strcmp (tmp_d_name, ".") == 0)
-                   || (strcmp (tmp_d_name, "..") == 0)) {
+               if (   streq(tmp_d_name, ".")
+                   || streq(tmp_d_name, "..")) {
                        continue;
                }
                if (*tmp_d_name == '.') {
index 4e10eb9864ec9ccd6fd274f4d0d340b2bb4c3172..37a1bbdae6e20c55a87b0b1d2d456bbcdccf8ceb 100644 (file)
@@ -26,6 +26,7 @@
 #include "alloc/x/xcalloc.h"
 #include "alloc/x/xmalloc.h"
 #include "sizeof.h"
+#include "string/strcmp/streq.h"
 #include "string/strcpy/strncpy.h"
 #include "string/strcpy/strtcpy.h"
 #include "string/strdup/xstrdup.h"
@@ -63,7 +64,7 @@ is_my_tty(const char tty[UTX_LINESIZE])
                exit (EXIT_FAILURE);
        }
 
-       return strcmp (full_tty, tmptty) == 0;
+       return streq(full_tty, tmptty);
 }
 
 
index 326635ffc283128b4b6f67e9b4e56580b5ce82ac..d21afc5f70bfa8f926eaad79e41670579a5a97d3 100644 (file)
 
 #ident "$Id$"
 
-#include <sys/types.h>
+#include <pwd.h>
 #include <stdio.h>
-#include "prototypes.h"
+#include <sys/types.h>
+
 #include "defines.h"
-#include <pwd.h>
+#include "prototypes.h"
+#include "string/strcmp/streq.h"
+
+
 /*
  * valid - compare encrypted passwords
  *
@@ -73,7 +77,7 @@ bool valid (const char *password, const struct passwd *ent)
 
        if (   (NULL != ent->pw_name)
            && (NULL != encrypted)
-           && (strcmp (encrypted, ent->pw_passwd) == 0)) {
+           && streq(encrypted, ent->pw_passwd)) {
                return true;
        } else {
                return false;
index 796906035acab07ef0df45112dbce57daaf88d17..a7933e0d88c167ecfec84cb77341e6428d70ae5d 100644 (file)
@@ -34,6 +34,7 @@
 #include "shadowlog.h"
 #include "string/memset/memzero.h"
 #include "string/sprintf/snprintf.h"
+#include "string/strcmp/streq.h"
 #include "string/strcpy/strtcpy.h"
 #include "string/strdup/xstrdup.h"
 #include "string/strftime.h"
@@ -186,7 +187,7 @@ static int new_fields (void)
 
        change_field (buf, sizeof buf, _("Last Password Change (YYYY-MM-DD)"));
 
-       if (strcmp (buf, "-1") == 0) {
+       if (streq(buf, "-1")) {
                lstchgdate = -1;
        } else {
                lstchgdate = strtoday (buf);
@@ -213,7 +214,7 @@ static int new_fields (void)
        change_field (buf, sizeof buf,
                      _("Account Expiration Date (YYYY-MM-DD)"));
 
-       if (strcmp (buf, "-1") == 0) {
+       if (streq(buf, "-1")) {
                expdate = -1;
        } else {
                expdate = strtoday (buf);
index 68ee5340068d596c707c8c750ddc1bdab2840210..2bb2463825dd0353c5636c240f1c2371f2c56260 100644 (file)
 #include <sys/types.h>
 #include <getopt.h>
 
+#include "chkname.h"
 #include "defines.h"
+/*@-exitarg@*/
+#include "exitcodes.h"
 #include "getdef.h"
 #include "nscd.h"
-#include "sssd.h"
 #ifdef USE_PAM
 #include "pam_defs.h"
 #endif
 #include "prototypes.h"
 #include "pwauth.h"
 #include "pwio.h"
-/*@-exitarg@*/
-#include "exitcodes.h"
 #include "shadowlog.h"
+#include "sssd.h"
 #include "string/sprintf/snprintf.h"
+#include "string/strcmp/streq.h"
 #include "string/strcpy/strtcpy.h"
 #include "string/strdup/xstrdup.h"
-#include "chkname.h"
 
 
 /*
@@ -151,9 +152,9 @@ static bool may_change_field (int field)
        cp = getdef_str ("CHFN_RESTRICT");
        if (NULL == cp) {
                cp = "";
-       } else if (strcmp (cp, "yes") == 0) {
+       } else if (streq(cp, "yes")) {
                cp = "rwh";
-       } else if (strcmp (cp, "no") == 0) {
+       } else if (streq(cp, "no")) {
                cp = "frwh";
        }
 
index 50a299aed883c9f16b878eb413d3818492b1253b..1eb7d1a299499ed806628898f582b000c27f65c9 100644 (file)
@@ -34,6 +34,7 @@
 /*@-exitarg@*/
 #include "exitcodes.h"
 #include "shadowlog.h"
+#include "string/strcmp/streq.h"
 #include "string/strtok/stpsep.h"
 
 
@@ -198,19 +199,19 @@ static void process_flags (int argc, char **argv)
                                usage (E_USAGE);
                        }
 #if defined(USE_SHA_CRYPT)
-                       if (  (   ((0 == strcmp (crypt_method, "SHA256")) || (0 == strcmp (crypt_method, "SHA512")))
+                       if (  (   (streq(crypt_method, "SHA256") || streq(crypt_method, "SHA512"))
                               && (-1 == str2sl(&sha_rounds, optarg)))) {
                             bad_s = 1;
                         }
 #endif                         /* USE_SHA_CRYPT */
 #if defined(USE_BCRYPT)
-                        if ((   (0 == strcmp (crypt_method, "BCRYPT"))
+                        if ((   streq(crypt_method, "BCRYPT")
                               && (-1 == str2sl(&bcrypt_rounds, optarg)))) {
                             bad_s = 1;
                         }
 #endif                         /* USE_BCRYPT */
 #if defined(USE_YESCRYPT)
-                        if ((   (0 == strcmp (crypt_method, "YESCRYPT"))
+                        if ((   streq(crypt_method, "YESCRYPT")
                               && (-1 == str2sl(&yescrypt_cost, optarg)))) {
                             bad_s = 1;
                         }
@@ -498,18 +499,18 @@ int main (int argc, char **argv)
 #if defined(USE_SHA_CRYPT) || defined(USE_BCRYPT) || defined(USE_YESCRYPT)
                        if (sflg) {
 #if defined(USE_SHA_CRYPT)
-                               if (   (0 == strcmp (crypt_method, "SHA256"))
-                                       || (0 == strcmp (crypt_method, "SHA512"))) {
+                               if (   streq(crypt_method, "SHA256")
+                                       || streq(crypt_method, "SHA512")) {
                                        arg = &sha_rounds;
                                }
 #endif                         /* USE_SHA_CRYPT */
 #if defined(USE_BCRYPT)
-                               if (0 == strcmp (crypt_method, "BCRYPT")) {
+                               if (streq(crypt_method, "BCRYPT")) {
                                        arg = &bcrypt_rounds;
                                }
 #endif                         /* USE_BCRYPT */
 #if defined(USE_YESCRYPT)
-                               if (0 == strcmp (crypt_method, "YESCRYPT")) {
+                               if (streq(crypt_method, "YESCRYPT")) {
                                        arg = &yescrypt_cost;
                                }
 #endif                         /* USE_YESCRYPT */
@@ -548,8 +549,8 @@ int main (int argc, char **argv)
                        sg = sgr_locate (name);
 
                        if (   (NULL == sg)
-                           && (strcmp (gr->gr_passwd,
-                                       SHADOW_PASSWD_STRING) == 0)) {
+                           && streq(gr->gr_passwd, SHADOW_PASSWD_STRING))
+                       {
                                static char *empty = NULL;
                                /* If the password is set to 'x' in
                                 * group, but there are no entries in
index 55817ddf4d6b2b364f5203710e1bef0f1cb2b561..1074d99f585852217a516cf07b746fd7adcb5fa9 100644 (file)
 /*@-exitarg@*/
 #include "exitcodes.h"
 #include "shadowlog.h"
+#include "string/strcmp/streq.h"
 #include "string/strtok/stpsep.h"
 
 
-#define IS_CRYPT_METHOD(str) ((crypt_method != NULL && strcmp(crypt_method, str) == 0) ? true : false)
+#define IS_CRYPT_METHOD(str) ((crypt_method != NULL && streq(crypt_method, str)) ? true : false)
 
 /*
  * Global variables
@@ -588,8 +589,8 @@ int main (int argc, char **argv)
                        sp = spw_locate (name);
 
                        if (   (NULL == sp)
-                           && (strcmp (pw->pw_passwd,
-                                       SHADOW_PASSWD_STRING) == 0)) {
+                           && streq(pw->pw_passwd, SHADOW_PASSWD_STRING))
+                       {
                                /* If the password is set to 'x' in
                                 * passwd, but there are no entries in
                                 * shadow, create one.
index d1488c674f89c2a477aa7adece1fe20939eebdc0..15bfae32379d2856379b30b1ba887b86cd35a3ab 100644 (file)
 #include <stdio.h>
 #include <sys/types.h>
 
+#include "chkname.h"
 #include "defines.h"
+/*@-exitarg@*/
+#include "exitcodes.h"
 #include "getdef.h"
 #include "nscd.h"
-#include "sssd.h"
 #include "prototypes.h"
 #include "pwauth.h"
 #include "pwio.h"
 #ifdef USE_PAM
 #include "pam_defs.h"
 #endif
-/*@-exitarg@*/
-#include "exitcodes.h"
 #include "shadowlog.h"
+#include "sssd.h"
+#include "string/strcmp/streq.h"
 #include "string/strcpy/strtcpy.h"
 #include "string/strdup/xstrdup.h"
-#include "chkname.h"
 
 
 #ifndef SHELLS_FILE
@@ -179,7 +180,7 @@ static bool shell_is_listed (const char *sh)
        }
 
        for (size_t i = 0; i < size; i++) {
-               if (strcmp (keys[i], sh) == 0) {
+               if (streq(keys[i], sh)) {
                        found = true;
                        break;
                }
@@ -200,7 +201,7 @@ static bool shell_is_listed (const char *sh)
        char *cp;
        setusershell ();
        while ((cp = getusershell ())) {
-               if (strcmp (cp, sh) == 0) {
+               if (streq(cp, sh)) {
                        found = true;
                        break;
                }
@@ -221,7 +222,7 @@ static bool shell_is_listed (const char *sh)
                        continue;
                }
 
-               if (strcmp (buf, sh) == 0) {
+               if (streq(buf, sh)) {
                        found = true;
                        break;
                }
index 593d6f1ceada56bf524dad6c3f71bbe22b7a601b..abb42ba841b6d319f376277626abee582f73efc6 100644 (file)
@@ -4,10 +4,11 @@
 #include <stdio.h>
 
 #include "atoi/getnum.h"
-#include "subid.h"
-#include "stdlib.h"
 #include "prototypes.h"
 #include "shadowlog.h"
+#include "stdlib.h"
+#include "string/strcmp/streq.h"
+#include "subid.h"
 
 
 static const char Prog[] = "get_subid_owners";
@@ -32,10 +33,10 @@ int main(int argc, char *argv[])
        if (argc < 2) {
                usage();
        }
-       if (argc == 3 && strcmp(argv[1], "-g") == 0) {
+       if (argc == 3 && streq(argv[1], "-g")) {
                get_uid(argv[2], &u);
                n = subid_get_gid_owners(u, &uids);
-       } else if (argc == 2 && strcmp(argv[1], "-h") == 0) {
+       } else if (argc == 2 && streq(argv[1], "-h")) {
                usage();
        } else {
                get_gid(argv[1], &u);
index 871e850f2be359673f7162f1494e36ebed61fb78..739792e973ce990dd23608fe2bc25caff6d1ce9e 100644 (file)
@@ -1,11 +1,13 @@
 /* SPDX-License-Identifier: BSD-3-Clause */
 
 #include <stdio.h>
-#include <string.h>
 #include <stdlib.h>
-#include "subid.h"
+#include <string.h>
+
 #include "prototypes.h"
 #include "shadowlog.h"
+#include "string/strcmp/streq.h"
+#include "subid.h"
 
 static const char Prog[] = "getsubids";
 
@@ -28,10 +30,10 @@ int main(int argc, char *argv[])
        if (argc < 2)
                usage();
        owner = argv[1];
-       if (argc == 3 && strcmp(argv[1], "-g") == 0) {
+       if (argc == 3 && streq(argv[1], "-g")) {
                owner = argv[2];
                count = subid_get_gid_ranges(owner, &ranges);
-       } else if (argc == 2 && strcmp(argv[1], "-h") == 0) {
+       } else if (argc == 2 && streq(argv[1], "-h")) {
                usage();
        } else {
                count = subid_get_uid_ranges(owner, &ranges);
index 4fdd2812222bef022cb5eebb88e3ff1c4015d48a..d129aca21c3e20d91821a15323845d01065a063d 100644 (file)
 #include "alloc/x/xmalloc.h"
 #include "attr.h"
 #include "defines.h"
+/*@-exitarg@*/
+#include "exitcodes.h"
 #include "groupio.h"
 #include "nscd.h"
-#include "sssd.h"
 #include "prototypes.h"
 #ifdef SHADOWGRP
 #include "sgroupio.h"
 #endif
-/*@-exitarg@*/
-#include "exitcodes.h"
 #include "shadowlog.h"
+#include "sssd.h"
 #include "string/memset/memzero.h"
 #include "string/sprintf/snprintf.h"
+#include "string/strcmp/streq.h"
 #include "string/strcpy/strtcpy.h"
 #include "string/strdup/xstrdup.h"
 
@@ -843,7 +844,7 @@ static void change_passwd (struct group *gr)
                        exit (1);
                }
 
-               if (strcmp (pass, cp) == 0) {
+               if (streq(pass, cp)) {
                        erase_pass (cp);
                        break;
                }
index b88694984dcfc620e5d5423c3fb71031444f5e75..53729b767c52f21f8fc20235819861a4b551b30e 100644 (file)
 
 #include "alloc/x/xmalloc.h"
 #include "defines.h"
-#include "prototypes.h"
 #include "groupio.h"
+#include "prototypes.h"
 #ifdef SHADOWGRP
 #include "sgroupio.h"
 #endif
 #include "shadowlog.h"
+#include "string/strcmp/streq.h"
 #include "string/strdup/xstrdup.h"
 
 
@@ -85,7 +86,7 @@ static char *whoami (void)
 
        if (   (NULL != usr)
            && (NULL != grp)
-           && (0 == strcmp (usr->pw_name, grp->gr_name))) {
+           && streq(usr->pw_name, grp->gr_name)) {
                return xstrdup (usr->pw_name);
        } else {
                return NULL;
index 0c0e29a600998a7d5ecf8f67cb29e254f7dc21b2..bedbc60673700dba9a8bb310aa16f6b1d26525e9 100644 (file)
 #include "chkname.h"
 #include "defines.h"
 #include "groupio.h"
-#include "pwio.h"
 #include "nscd.h"
-#include "sssd.h"
 #include "prototypes.h"
+#include "pwio.h"
 #ifdef SHADOWGRP
 #include "sgroupio.h"
 #endif
 #include "shadowlog.h"
+#include "sssd.h"
 #include "string/sprintf/stpeprintf.h"
+#include "string/strcmp/streq.h"
 #include "string/strcpy/stpecpy.h"
 #include "string/strdup/xstrdup.h"
 
@@ -227,7 +228,7 @@ static void grp_update (void)
                        sgrp = *osgrp;
                        new_sgent (&sgrp);
                } else if (   pflg
-                          && (strcmp (grp.gr_passwd, SHADOW_PASSWD_STRING) == 0)) {
+                          && streq(grp.gr_passwd, SHADOW_PASSWD_STRING)) {
                        static char *empty = NULL;
                        /* If there is a gshadow file with no entries for
                         * the group, but the group file indicates a
@@ -357,7 +358,7 @@ check_new_name(void)
        /*
         * Make sure they are actually changing the name.
         */
-       if (strcmp (group_name, group_newname) == 0) {
+       if (streq(group_name, group_newname)) {
                nflg = 0;
                return;
        }
index 4ef1b1542621abfe153be8623865da73d18a6aaf..a97e756c55f22fbdab86b8017697b0dc70eae9db 100644 (file)
 #include <pwd.h>
 #include <stdio.h>
 #include <getopt.h>
+
 #include "chkname.h"
 #include "commonio.h"
 #include "defines.h"
 #include "groupio.h"
 #include "nscd.h"
-#include "sssd.h"
 #include "prototypes.h"
 #include "shadowlog.h"
+#include "sssd.h"
+#include "string/strcmp/streq.h"
 
 #ifdef SHADOWGRP
 #include "sgroupio.h"
@@ -436,7 +438,7 @@ static void compare_members_lists (const char *groupname,
 
        for (pmem = members; NULL != *pmem; pmem++) {
                for (other_pmem = other_members; NULL != *other_pmem; other_pmem++) {
-                       if (strcmp (*pmem, *other_pmem) == 0) {
+                       if (streq(*pmem, *other_pmem)) {
                                break;
                        }
                }
index d001ece73297de6de13164acae82ce51295120c2..ea65a329f46fd80dfdbd0d189b23edde4bed0e47 100644 (file)
 #include <getopt.h>
 
 #include "attr.h"
-#include "nscd.h"
-#include "sssd.h"
-#include "prototypes.h"
 /*@-exitarg@*/
 #include "exitcodes.h"
+#include "nscd.h"
+#include "prototypes.h"
+#include "sssd.h"
+#include "string/strcmp/streq.h"
+
 #ifdef SHADOWGRP
 #include "groupio.h"
 #include "sgroupio.h"
 #include "shadowlog.h"
+
+
 /*
  * Global variables
  */
@@ -174,7 +178,7 @@ int main (int argc, char **argv)
        while ((gr = gr_next ()) != NULL) {
                sg = sgr_locate (gr->gr_name);
                if (   (NULL != sg)
-                   && (strcmp (gr->gr_passwd, SHADOW_PASSWD_STRING) == 0)) {
+                   && streq(gr->gr_passwd, SHADOW_PASSWD_STRING)) {
                        /* add password to /etc/group */
                        grent = *gr;
                        grent.gr_passwd = sg->sg_passwd;
index 2319f50b39a02c8e1f64075702b836f2fd241c50..31162af18bfa398c0d5098ddaef8db8c59b937a6 100644 (file)
 #include "attr.h"
 #include "chkname.h"
 #include "defines.h"
+/*@-exitarg@*/
+#include "exitcodes.h"
 #include "faillog.h"
 #include "failure.h"
 #include "getdef.h"
 #include "prototypes.h"
 #include "pwauth.h"
-/*@-exitarg@*/
-#include "exitcodes.h"
 #include "shadowlog.h"
 #include "string/memset/memzero.h"
 #include "string/sprintf/snprintf.h"
+#include "string/strcmp/streq.h"
 #include "string/strcpy/strtcpy.h"
 #include "string/strdup/xstrdup.h"
 #include "string/strftime.h"
@@ -269,7 +270,7 @@ static void process_flags (int argc, char *const *argv)
                if (argv[arg][0] == '-' && strlen (argv[arg]) > 2) {
                        usage ();
                }
-               if (strcmp(argv[arg], "--") == 0) {
+               if (streq(argv[arg], "--")) {
                        break; /* stop checking on a "--" */
                }
        }
@@ -864,22 +865,22 @@ int main (int argc, char **argv)
                                failed = true;
                        }
 
-                       if (strcmp (user_passwd, "") == 0) {
+                       if (streq(user_passwd, "")) {
                                const char *prevent_no_auth = getdef_str("PREVENT_NO_AUTH");
 
                                if (prevent_no_auth == NULL) {
                                        prevent_no_auth = "superuser";
                                }
-                               if (strcmp(prevent_no_auth, "yes") == 0) {
+                               if (streq(prevent_no_auth, "yes")) {
                                        failed = true;
                                } else if ((pwd->pw_uid == 0)
-                                       && (strcmp(prevent_no_auth, "superuser") == 0)) {
+                                       && streq(prevent_no_auth, "superuser")) {
                                        failed = true;
                                }
                        }
                }
 
-               if (strcmp (user_passwd, SHADOW_PASSWD_STRING) == 0) {
+               if (streq(user_passwd, SHADOW_PASSWD_STRING)) {
                        spwd = xgetspnam (username);
                        if (NULL != spwd) {
                                user_passwd = spwd->sp_pwdp;
index 979901e4239e22cb3d0cb45fdb9b68e4d301c750..4955ebcefcd9f6c02d16550f550a28d259e6cd0a 100644 (file)
 
 #include "agetpass.h"
 #include "alloc/x/xmalloc.h"
+#include "chkname.h"
 #include "defines.h"
-#include "getdef.h"
-#include "prototypes.h"
 /*@-exitarg@*/
 #include "exitcodes.h"
+#include "getdef.h"
+#include "prototypes.h"
 #include "shadowlog.h"
 #include "string/sprintf/snprintf.h"
+#include "string/strcmp/streq.h"
 #include "string/strdup/xstrdup.h"
-#include "chkname.h"
 
 
 /*
@@ -428,7 +429,7 @@ int main (int argc, char **argv)
         * injecting arbitrary strings into our stderr/stdout, as this can
         * be an exploit vector.
         */
-       is_newgrp = (strcmp (Basename (argv[0]), "newgrp") == 0);
+       is_newgrp = streq(Basename (argv[0]), "newgrp");
        Prog = is_newgrp ? "newgrp" : "sg";
 
        log_set_progname(Prog);
@@ -472,8 +473,8 @@ int main (int argc, char **argv)
         *      sg [-] groupid [[-c command]
         */
        if (   (argc > 0)
-           && (   (strcmp (argv[0], "-")  == 0)
-               || (strcmp (argv[0], "-l") == 0))) {
+           && (   streq(argv[0], "-")
+               || streq(argv[0], "-l"))) {
                argc--;
                argv++;
                initflag = true;
@@ -505,7 +506,7 @@ int main (int argc, char **argv)
                         * "sg group -c command" (as in the man page) or
                         * "sg group command" (as in the usage message).
                         */
-                       if ((argc > 1) && (strcmp (argv[0], "-c") == 0)) {
+                       if ((argc > 1) && streq(argv[0], "-c")) {
                                command = argv[1];
                        } else {
                                command = argv[0];
index 044ce32e1e4e02a18f4218d498cf2afb31c320d2..eee0d260d9ea95a8fd804fb96d33117bf9c2d0ea 100644 (file)
 #include "pam_defs.h"
 #endif                         /* USE_PAM */
 #endif                         /* ACCT_TOOLS_SETUID */
-#include "prototypes.h"
+#include "chkname.h"
 #include "defines.h"
 #include "getdef.h"
 #include "groupio.h"
 #include "nscd.h"
-#include "sssd.h"
+#include "prototypes.h"
 #include "pwio.h"
 #include "sgroupio.h"
 #include "shadowio.h"
 #ifdef ENABLE_SUBIDS
 #include "subordinateio.h"
 #endif                         /* ENABLE_SUBIDS */
-#include "chkname.h"
 #include "shadowlog.h"
+#include "sssd.h"
 #include "string/sprintf/snprintf.h"
+#include "string/strcmp/streq.h"
 #include "string/strdup/xstrdup.h"
 #include "string/strtok/stpsep.h"
 
@@ -428,29 +429,29 @@ static int update_passwd (struct passwd *pwd, const char *password)
        if (NULL != crypt_method) {
 #if defined(USE_SHA_CRYPT)
                if (sflg) {
-                       if (   (0 == strcmp (crypt_method, "SHA256"))
-                               || (0 == strcmp (crypt_method, "SHA512"))) {
+                       if (   streq(crypt_method, "SHA256")
+                               || streq(crypt_method, "SHA512")) {
                                crypt_arg = &sha_rounds;
                        }
                }
 #endif                         /* USE_SHA_CRYPT */
 #if defined(USE_BCRYPT)
                if (sflg) {
-                       if (0 == strcmp (crypt_method, "BCRYPT")) {
+                       if (streq(crypt_method, "BCRYPT")) {
                                crypt_arg = &bcrypt_rounds;
                        }
                }
 #endif                         /* USE_BCRYPT */
 #if defined(USE_YESCRYPT)
                if (sflg) {
-                       if (0 == strcmp (crypt_method, "YESCRYPT")) {
+                       if (streq(crypt_method, "YESCRYPT")) {
                                crypt_arg = &yescrypt_cost;
                        }
                }
 #endif                         /* USE_YESCRYPT */
        }
 
-       if ((NULL != crypt_method) && (0 == strcmp(crypt_method, "NONE"))) {
+       if ((NULL != crypt_method) && streq(crypt_method, "NONE")) {
                pwd->pw_passwd = (char *)password;
        } else {
                const char *salt = crypt_make_salt (crypt_method, crypt_arg);
@@ -484,22 +485,23 @@ static int add_passwd (struct passwd *pwd, const char *password)
        if (NULL != crypt_method) {
 #if defined(USE_SHA_CRYPT)
                if (sflg) {
-                       if (   (0 == strcmp (crypt_method, "SHA256"))
-                               || (0 == strcmp (crypt_method, "SHA512"))) {
+                       if (streq(crypt_method, "SHA256")
+                           || streq(crypt_method, "SHA512"))
+                       {
                                crypt_arg = &sha_rounds;
                        }
                }
 #endif                         /* USE_SHA_CRYPT */
 #if defined(USE_BCRYPT)
                if (sflg) {
-                       if (0 == strcmp (crypt_method, "BCRYPT")) {
+                       if (streq(crypt_method, "BCRYPT")) {
                                crypt_arg = &bcrypt_rounds;
                        }
                }
 #endif                         /* USE_BCRYPT */
 #if defined(USE_YESCRYPT)
                if (sflg) {
-                       if (0 == strcmp (crypt_method, "YESCRYPT")) {
+                       if (streq(crypt_method, "YESCRYPT")) {
                                crypt_arg = &yescrypt_cost;
                        }
                }
@@ -525,7 +527,8 @@ static int add_passwd (struct passwd *pwd, const char *password)
        if (NULL != sp) {
                spent = *sp;
                if (   (NULL != crypt_method)
-                   && (0 == strcmp(crypt_method, "NONE"))) {
+                   && streq(crypt_method, "NONE"))
+               {
                        spent.sp_pwdp = (char *)password;
                } else {
                        const char *salt = crypt_make_salt (crypt_method,
@@ -576,7 +579,7 @@ static int add_passwd (struct passwd *pwd, const char *password)
         */
        spent.sp_namp = pwd->pw_name;
 #ifndef USE_PAM
-       if ((crypt_method != NULL) && (0 == strcmp(crypt_method, "NONE"))) {
+       if ((crypt_method != NULL) && streq(crypt_method, "NONE")) {
                spent.sp_pwdp = (char *)password;
        } else {
                const char *salt = crypt_make_salt (crypt_method, crypt_arg);
@@ -682,19 +685,19 @@ static void process_flags (int argc, char **argv)
                                usage (EXIT_FAILURE);
                        }
 #if defined(USE_SHA_CRYPT)
-                       if (  (   ((0 == strcmp (crypt_method, "SHA256")) || (0 == strcmp (crypt_method, "SHA512")))
+                       if (  (   (streq(crypt_method, "SHA256") || streq(crypt_method, "SHA512"))
                               && (-1 == str2sl(&sha_rounds, optarg)))) {
                             bad_s = 1;
                         }
 #endif                         /* USE_SHA_CRYPT */
 #if defined(USE_BCRYPT)
-                        if ((   (0 == strcmp (crypt_method, "BCRYPT"))
+                        if ((   streq(crypt_method, "BCRYPT")
                               && (-1 == str2sl(&bcrypt_rounds, optarg)))) {
                             bad_s = 1;
                         }
 #endif                         /* USE_BCRYPT */
 #if defined(USE_YESCRYPT)
-                        if ((   (0 == strcmp (crypt_method, "YESCRYPT"))
+                        if ((   streq(crypt_method, "YESCRYPT")
                               && (-1 == str2sl(&yescrypt_cost, optarg)))) {
                             bad_s = 1;
                         }
index 7c6b3a82dc5d5061d2e96081f0a5678ff9b6ca93..a201e5d0db6def8bd376967e9f56454e90840c11 100644 (file)
 
 #include "agetpass.h"
 #include "atoi/a2i/a2s.h"
+#include "chkname.h"
 #include "defines.h"
 #include "getdef.h"
 #include "nscd.h"
-#include "sssd.h"
 #include "prototypes.h"
 #include "pwauth.h"
 #include "pwio.h"
 #include "shadowio.h"
 #include "shadowlog.h"
+#include "sssd.h"
 #include "string/memset/memzero.h"
 #include "string/sprintf/xasprintf.h"
+#include "string/strcmp/streq.h"
 #include "string/strcpy/strtcpy.h"
 #include "string/strdup/xstrdup.h"
 #include "time/day_to_str.h"
-#include "chkname.h"
 
 
 /*
@@ -242,16 +243,16 @@ static int new_password (const struct passwd *pw)
                        pass_max_len = getdef_num ("PASS_MAX_LEN", 8);
                }
        } else {
-               if (   (strcmp (method, "MD5")    == 0)
+               if (   streq(method, "MD5")
 #ifdef USE_SHA_CRYPT
-                   || (strcmp (method, "SHA256") == 0)
-                   || (strcmp (method, "SHA512") == 0)
+                   || streq(method, "SHA256")
+                   || streq(method, "SHA512")
 #endif /* USE_SHA_CRYPT */
 #ifdef USE_BCRYPT
-                   || (strcmp (method, "BCRYPT") == 0)
+                   || streq(method, "BCRYPT")
 #endif /* USE_BCRYPT*/
 #ifdef USE_YESCRYPT
-                   || (strcmp (method, "YESCRYPT") == 0)
+                   || streq(method, "YESCRYPT")
 #endif /* USE_YESCRYPT*/
 
                    ) {
index 7dd327ae006f615ba7f0263fbf811fb94ff01dc2..1bb9275288d88f332b34a1ca356dc27a7997b6cd 100644 (file)
 
 #include "defines.h"
 #include "getdef.h"
+#include "nscd.h"
 #include "prototypes.h"
 #include "pwio.h"
-#include "shadowio.h"
-#include "nscd.h"
 #include "sssd.h"
+#include "shadowio.h"
 #include "shadowlog.h"
+#include "string/strcmp/streq.h"
+
 
 /*
  * exit status values
@@ -231,7 +233,7 @@ int main (int argc, char **argv)
                sp = spw_locate (pw->pw_name);
                if (NULL != sp) {
                        /* do we need to update this entry? */
-                       if (strcmp (pw->pw_passwd, SHADOW_PASSWD_STRING) == 0) {
+                       if (streq(pw->pw_passwd, SHADOW_PASSWD_STRING)) {
                                continue;
                        }
                        /* update existing shadow entry */
index fe18113a62e1ed6c7c851798ce1d1919ce815a28..2e4d3d7597ec1bf67faffc764497b9ee8eb1286b 100644 (file)
 #include <sys/types.h>
 #include <unistd.h>
 #include <getopt.h>
+
 #include "defines.h"
+/*@-exitarg@*/
+#include "exitcodes.h"
 #include "getdef.h"
 #include "nscd.h"
-#include "sssd.h"
 #include "prototypes.h"
 #include "pwio.h"
 #include "shadowio.h"
-/*@-exitarg@*/
-#include "exitcodes.h"
 #include "shadowlog.h"
+#include "sssd.h"
+#include "string/strcmp/streq.h"
+
 
 /*
  * Global variables
@@ -180,7 +183,7 @@ int main (int argc, char **argv)
                /*
                 * Update password if non-shadow is "x".
                 */
-               if (strcmp (pw->pw_passwd, SHADOW_PASSWD_STRING) == 0) {
+               if (streq(pw->pw_passwd, SHADOW_PASSWD_STRING)) {
                        pwent.pw_passwd = spwd->sp_pwdp;
                }
 
index 40e8189f95871b5149343381d01ff966ab5f40fb..6c1fdc5bc6f44ec2b03eb6ed7ef15cc52d14c097 100644 (file)
--- a/src/su.c
+++ b/src/su.c
 #include "alloc/x/xmalloc.h"
 #include "attr.h"
 #include "cast.h"
-#include "prototypes.h"
 #include "defines.h"
-#include "pwauth.h"
+/*@-exitarg@*/
+#include "exitcodes.h"
 #include "getdef.h"
 #ifdef USE_PAM
 #include "pam_defs.h"
 #endif                         /* USE_PAM */
-/*@-exitarg@*/
-#include "exitcodes.h"
+#include "pwauth.h"
+#include "prototypes.h"
 #include "shadowlog.h"
 #include "string/sprintf/snprintf.h"
 #include "string/sprintf/xasprintf.h"
+#include "string/strcmp/streq.h"
 #include "string/strcpy/strtcpy.h"
 #include "string/strdup/xstrdup.h"
 
@@ -186,7 +187,7 @@ static bool restricted_shell (const char *shellname)
 
        setusershell ();
        while ((line = getusershell ()) != NULL) {
-               if (('#' != *line) && (strcmp (line, shellname) == 0)) {
+               if (('#' != *line) && streq(line, shellname)) {
                        endusershell ();
                        return false;
                }
@@ -511,17 +512,17 @@ static void check_perms_nopam (const struct passwd *pw)
                return;
        }
 
-       if (strcmp (pw->pw_passwd, "") == 0) {
+       if (streq(pw->pw_passwd, "")) {
                const char  *prevent_no_auth = getdef_str("PREVENT_NO_AUTH");
 
                if (prevent_no_auth == NULL) {
                        prevent_no_auth = "superuser";
                }
-               if (strcmp(prevent_no_auth, "yes") == 0) {
+               if (streq(prevent_no_auth, "yes")) {
                        fprintf(stderr, _("Password field is empty, this is forbidden for all accounts.\n"));
                        exit(1);
                } else if ((pw->pw_uid == 0)
-                               && (strcmp(prevent_no_auth, "superuser") == 0)) {
+                               && streq(prevent_no_auth, "superuser")) {
                        fprintf(stderr, _("Password field is empty, this is forbidden for super-user.\n"));
                        exit(1);
                }
@@ -555,7 +556,7 @@ static void check_perms_nopam (const struct passwd *pw)
        }
        spwd = getspnam (name); /* !USE_PAM, no need for xgetspnam */
 #ifdef SU_ACCESS
-       if (strcmp (pw->pw_passwd, SHADOW_PASSWD_STRING) == 0) {
+       if (streq(pw->pw_passwd, SHADOW_PASSWD_STRING)) {
                if (NULL != spwd) {
                        password = spwd->sp_pwdp;
                }
@@ -792,7 +793,7 @@ save_caller_context(void)
         * -- chris
         */
        password = pw->pw_passwd;
-       if (strcmp (pw->pw_passwd, SHADOW_PASSWD_STRING) == 0) {
+       if (streq(pw->pw_passwd, SHADOW_PASSWD_STRING)) {
                const struct spwd *spwd = getspnam (caller_name);
                if (NULL != spwd) {
                        password = spwd->sp_pwdp;
@@ -853,7 +854,7 @@ static void process_flags (int argc, char **argv)
                }
        }
 
-       if ((optind < argc) && (strcmp (argv[optind], "-") == 0)) {
+       if ((optind < argc) && streq(argv[optind], "-")) {
                fakelogin = true;
                optind++;
        }
index cbb33dc8da058372ab600db512fc0030fc4dc5cb..ee035a02867411466b3f69df508312dd3dd55607 100644 (file)
@@ -20,6 +20,7 @@
 #include "prototypes.h"
 #include "string/strchr/stpspn.h"
 #include "string/strchr/strrspn.h"
+#include "string/strcmp/streq.h"
 #include "string/strtok/stpsep.h"
 
 
@@ -104,7 +105,7 @@ int check_su_auth (const char *actual_id,
                        continue;
                if (!applies (actual_id, from_users))
                        continue;
-               if (!strcmp (action, "DENY")) {
+               if (streq(action, "DENY")) {
                        SYSLOG ((su_to_root ? LOG_WARN : LOG_NOTICE,
                                 "DENIED su from '%s' to '%s' (%s)\n",
                                 actual_id, wanted_id, SUAUTHFILE));
@@ -112,14 +113,14 @@ int check_su_auth (const char *actual_id,
                               stderr);
                        fclose (authfile_fd);
                        return DENY;
-               } else if (!strcmp (action, "NOPASS")) {
+               } else if (streq(action, "NOPASS")) {
                        SYSLOG ((su_to_root ? LOG_NOTICE : LOG_INFO,
                                 "NO password asked for su from '%s' to '%s' (%s)\n",
                                 actual_id, wanted_id, SUAUTHFILE));
                        fputs (_("Password authentication bypassed.\n"),stderr);
                        fclose (authfile_fd);
                        return NOPWORD;
-               } else if (!strcmp (action, "OWNPASS")) {
+               } else if (streq(action, "OWNPASS")) {
                        SYSLOG ((su_to_root ? LOG_NOTICE : LOG_INFO,
                                 "su from '%s' to '%s': asking for user's own password (%s)\n",
                                 actual_id, wanted_id, SUAUTHFILE));
@@ -147,7 +148,7 @@ static int applies (const char *single, char *list)
        for (tok = strtok (list, split); tok != NULL;
             tok = strtok (NULL, split)) {
 
-               if (!strcmp (tok, "ALL")) {
+               if (streq(tok, "ALL")) {
                        if (state != 0) {
                                SYSLOG ((LOG_ERR,
                                         "%s, line %d: ALL in bad place\n",
@@ -155,7 +156,7 @@ static int applies (const char *single, char *list)
                                return 0;
                        }
                        state = 1;
-               } else if (!strcmp (tok, "EXCEPT")) {
+               } else if (streq(tok, "EXCEPT")) {
                        if (state != 1) {
                                SYSLOG ((LOG_ERR,
                                         "%s, line %d: EXCEPT in bas place\n",
@@ -163,7 +164,7 @@ static int applies (const char *single, char *list)
                                return 0;
                        }
                        state = 2;
-               } else if (!strcmp (tok, "GROUP")) {
+               } else if (streq(tok, "GROUP")) {
                        if ((state != 0) && (state != 2)) {
                                SYSLOG ((LOG_ERR,
                                         "%s, line %d: GROUP in bad place\n",
@@ -174,7 +175,7 @@ static int applies (const char *single, char *list)
                } else {
                        switch (state) {
                        case 0: /* No control words yet */
-                               if (!strcmp (tok, single))
+                               if (streq(tok, single))
                                        return 1;
                                break;
                        case 1: /* An all */
@@ -183,7 +184,7 @@ static int applies (const char *single, char *list)
                                         SUAUTHFILE, lines));
                                return 0;
                        case 2: /* All except */
-                               if (!strcmp (tok, single))
+                               if (streq(tok, single))
                                        return 0;
                                break;
                        case 3: /* Group */
index bd3b0624a655982dd36221ca597d949a899a01eb..9fc3db90a47167b1f6e800ac3ef7331573b69c77 100644 (file)
@@ -45,7 +45,6 @@
 #include "getdef.h"
 #include "groupio.h"
 #include "nscd.h"
-#include "sssd.h"
 #include "prototypes.h"
 #include "pwauth.h"
 #include "pwio.h"
 #include "tcbfuncs.h"
 #endif
 #include "shadowlog.h"
+#include "sssd.h"
 #include "string/memset/memzero.h"
 #include "string/sprintf/snprintf.h"
 #include "string/sprintf/xasprintf.h"
+#include "string/strcmp/streq.h"
 #include "string/strdup/xstrdup.h"
 #include "string/strtok/stpsep.h"
 
@@ -370,7 +371,7 @@ get_defaults(void)
                /*
                 * Primary GROUP identifier
                 */
-               if (strcmp(buf, DGROUP) == 0) {
+               if (streq(buf, DGROUP)) {
                        const struct group *grp = prefix_getgr_nam_gid (cp);
                        if (NULL == grp) {
                                fprintf (stderr,
@@ -387,7 +388,7 @@ get_defaults(void)
 
                ccp = cp;
 
-               if (strcmp(buf, DGROUPS) == 0) {
+               if (streq(buf, DGROUPS)) {
                        if (get_groups (cp) != 0) {
                                fprintf (stderr,
                                         _("%s: the '%s=' configuration in %s has an invalid group, ignoring the bad group\n"),
@@ -401,21 +402,21 @@ get_defaults(void)
                /*
                 * Default HOME filesystem
                 */
-               else if (strcmp(buf, DHOME) == 0) {
+               else if (streq(buf, DHOME)) {
                        def_home = xstrdup(ccp);
                }
 
                /*
                 * Default Login Shell command
                 */
-               else if (strcmp(buf, DSHELL) == 0) {
+               else if (streq(buf, DSHELL)) {
                        def_shell = xstrdup(ccp);
                }
 
                /*
                 * Default Password Inactive value
                 */
-               else if (strcmp(buf, DINACT) == 0) {
+               else if (streq(buf, DINACT)) {
                        if (a2sl(&def_inactive, ccp, NULL, 0, -1, LONG_MAX) == -1) {
                                fprintf (stderr,
                                         _("%s: invalid numeric argument '%s'\n"),
@@ -430,14 +431,14 @@ get_defaults(void)
                /*
                 * Default account expiration date
                 */
-               else if (strcmp(buf, DEXPIRE) == 0) {
+               else if (streq(buf, DEXPIRE)) {
                        def_expire = xstrdup(ccp);
                }
 
                /*
                 * Default Skeleton information
                 */
-               else if (strcmp(buf, DSKEL) == 0) {
+               else if (streq(buf, DSKEL)) {
                        if ('\0' == *ccp)
                                ccp = SKEL_DIR;
 
@@ -454,7 +455,7 @@ get_defaults(void)
                /*
                 * Default Usr Skeleton information
                 */
-               else if (strcmp(buf, DUSRSKEL) == 0) {
+               else if (streq(buf, DUSRSKEL)) {
                        if ('\0' == *ccp)
                                ccp = USRSKELDIR;
 
@@ -470,7 +471,7 @@ get_defaults(void)
                /*
                 * Create by default user mail spool or not ?
                 */
-               else if (strcmp(buf, DCREATE_MAIL_SPOOL) == 0) {
+               else if (streq(buf, DCREATE_MAIL_SPOOL)) {
                        if (*ccp == '\0')
                                ccp = "no";
 
@@ -480,7 +481,7 @@ get_defaults(void)
                /*
                 * By default do we add the user to the lastlog and faillog databases ?
                 */
-               else if (strcmp(buf, DLOG_INIT) == 0) {
+               else if (streq(buf, DLOG_INIT)) {
                        if (*ccp == '\0')
                                ccp = def_log_init;
 
@@ -620,38 +621,38 @@ set_defaults(void)
                val = stpsep(buf, "=");
                if (val == NULL) {
                        fprintf(ofp, "%s\n", buf);
-               } else if (!out_group && strcmp(buf, DGROUP) == 0) {
+               } else if (!out_group && streq(buf, DGROUP)) {
                        fprintf(ofp, DGROUP "=%u\n", (unsigned int) def_group);
                        out_group = true;
-               } else if (!out_groups && strcmp(buf, DGROUPS) == 0) {
+               } else if (!out_groups && streq(buf, DGROUPS)) {
                        fprintf(ofp, DGROUPS "=%s\n", def_groups);
                        out_groups = true;
-               } else if (!out_home && strcmp(buf, DHOME) == 0) {
+               } else if (!out_home && streq(buf, DHOME)) {
                        fprintf(ofp, DHOME "=%s\n", def_home);
                        out_home = true;
-               } else if (!out_inactive && strcmp(buf, DINACT) == 0) {
+               } else if (!out_inactive && streq(buf, DINACT)) {
                        fprintf(ofp, DINACT "=%ld\n", def_inactive);
                        out_inactive = true;
-               } else if (!out_expire && strcmp(buf, DEXPIRE) == 0) {
+               } else if (!out_expire && streq(buf, DEXPIRE)) {
                        fprintf(ofp, DEXPIRE "=%s\n", def_expire);
                        out_expire = true;
-               } else if (!out_shell && strcmp(buf, DSHELL) == 0) {
+               } else if (!out_shell && streq(buf, DSHELL)) {
                        fprintf(ofp, DSHELL "=%s\n", def_shell);
                        out_shell = true;
-               } else if (!out_skel && strcmp(buf, DSKEL) == 0) {
+               } else if (!out_skel && streq(buf, DSKEL)) {
                        fprintf(ofp, DSKEL "=%s\n", def_template);
                        out_skel = true;
-               } else if (!out_usrskel && strcmp(buf, DUSRSKEL) == 0) {
+               } else if (!out_usrskel && streq(buf, DUSRSKEL)) {
                        fprintf(ofp, DUSRSKEL "=%s\n", def_usrtemplate);
                        out_usrskel = true;
                } else if (!out_create_mail_spool
-                          && strcmp(buf, DCREATE_MAIL_SPOOL) == 0)
+                          && streq(buf, DCREATE_MAIL_SPOOL))
                {
                        fprintf(ofp,
                                DCREATE_MAIL_SPOOL "=%s\n",
                                def_create_mail_spool);
                        out_create_mail_spool = true;
-               } else if (!out_log_init && strcmp(buf, DLOG_INIT) == 0) {
+               } else if (!out_log_init && streq(buf, DLOG_INIT)) {
                        fprintf(ofp, DLOG_INIT "=%s\n", def_log_init);
                        out_log_init = true;
                } else {
@@ -1583,7 +1584,7 @@ static void process_flags (int argc, char **argv)
        if (!lflg) {
                /* If we are missing the flag lflg aka -l, check the defaults
                * file to see if we need to disable it as a default*/
-               if (strcmp (def_log_init, "no") == 0) {
+               if (streq(def_log_init, "no")) {
                        lflg = true;
                }
        }
index ead696041bbfbcbebab88aa9f8208fce254f88c1..6552c5ae7430fdc59a457a055eaa60a4fb89cabb 100644 (file)
@@ -52,6 +52,7 @@
 #endif                         /* ENABLE_SUBIDS */
 #include "shadowlog.h"
 #include "string/sprintf/xasprintf.h"
+#include "string/strcmp/streq.h"
 #include "string/strdup/xstrdup.h"
 
 
@@ -319,7 +320,7 @@ static void remove_usergroup (void)
                 */
                prefix_setpwent ();
                while ((pwd = prefix_getpwent ()) != NULL) {
-                       if (strcmp (pwd->pw_name, user_name) == 0) {
+                       if (streq(pwd->pw_name, user_name)) {
                                continue;
                        }
                        if (pwd->pw_gid == grp->gr_gid) {
@@ -1183,7 +1184,7 @@ int main (int argc, char **argv)
                 */
                prefix_setpwent ();
                while ((pwd = prefix_getpwent ())) {
-                       if (strcmp (pwd->pw_name, user_name) == 0) {
+                       if (streq(pwd->pw_name, user_name)) {
                                continue;
                        }
                        if (path_prefix (user_home, pwd->pw_dir)) {
index ddcd64010155a86a8e2a3d74262e562fcb306ac7..4cde39bef17c23f93329ffe4be548df88af684a3 100644 (file)
@@ -44,7 +44,6 @@
 #include "groupio.h"
 #include "must_be.h"
 #include "nscd.h"
-#include "sssd.h"
 #include "prototypes.h"
 #include "pwauth.h"
 #include "pwio.h"
@@ -62,6 +61,7 @@
 #include "tcbfuncs.h"
 #endif
 #include "shadowlog.h"
+#include "sssd.h"
 #include "string/memset/memzero.h"
 #include "string/sprintf/xasprintf.h"
 #include "string/strcmp/streq.h"
@@ -1374,10 +1374,10 @@ process_flags(int argc, char **argv)
                gflg = false;
        }
        if (   (NULL != user_newshell)
-           && (strcmp (user_newshell, user_shell) == 0)) {
+           && streq(user_newshell, user_shell)) {
                sflg = false;
        }
-       if (strcmp (user_newname, user_name) == 0) {
+       if (streq(user_newname, user_name)) {
                lflg = false;
        }
        if (user_newinactive == user_inactive) {
@@ -1387,12 +1387,12 @@ process_flags(int argc, char **argv)
                eflg = false;
        }
        if (   (NULL != user_newhome)
-           && (strcmp (user_newhome, user_home) == 0)) {
+           && streq(user_newhome, user_home)) {
                dflg = false;
                mflg = false;
        }
        if (   (NULL != user_newcomment)
-           && (strcmp (user_newcomment, user_comment) == 0)) {
+           && streq(user_newcomment, user_comment)) {
                cflg = false;
        }
 
@@ -1727,7 +1727,7 @@ static void usr_update (void)
                        spent = *spwd;
                        new_spent (&spent);
                } else if (   (    pflg
-                              && (strcmp (pwent.pw_passwd, SHADOW_PASSWD_STRING) == 0))
+                              && streq(pwent.pw_passwd, SHADOW_PASSWD_STRING))
                           || eflg || fflg) {
                        /* In some cases, we force the creation of a
                         * shadow entry:
index 4df05b6f594ac4f1c84a2bea6af846353f593caf..a855e0d7ffcc46f04024c35bffddbb218e98b24d 100644 (file)
@@ -31,7 +31,6 @@
 #include "getdef.h"
 #include "groupio.h"
 #include "nscd.h"
-#include "sssd.h"
 #include "prototypes.h"
 #include "pwio.h"
 #include "sgroupio.h"
 #include "tcbfuncs.h"
 #endif                         /* WITH_TCB */
 #include "shadowlog.h"
+#include "sssd.h"
 #include "string/sprintf/snprintf.h"
 #include "string/sprintf/xasprintf.h"
+#include "string/strcmp/streq.h"
 
 
 #define MSG_WARN_EDIT_OTHER_FILE _( \
@@ -471,7 +472,7 @@ int main (int argc, char **argv)
        bool  editshadow = false;
        bool  do_vigr;
 
-       do_vigr = (strcmp(Basename(argv[0]), "vigr") == 0);
+       do_vigr = streq(Basename(argv[0]), "vigr");
 
        Prog = do_vigr ? "vigr" : "vipw";
        log_set_progname(Prog);