]> git.ipfire.org Git - thirdparty/shadow.git/commitdiff
lib/, src/: Use STRNEQ() instead of their pattern master
authorAlejandro Colomar <alx@kernel.org>
Sun, 20 Jul 2025 15:02:17 +0000 (17:02 +0200)
committerSerge Hallyn <serge@hallyn.com>
Sat, 18 Oct 2025 19:08:47 +0000 (14:08 -0500)
Signed-off-by: Alejandro Colomar <alx@kernel.org>
lib/user_busy.c
lib/utmp.c
src/login.c
src/logoutd.c

index a05faef166723ef3aa7070d59ff6a789db64cec0..51f0a9ea37cdd9742138ce5d62d1d74a225f8aa3 100644 (file)
@@ -29,6 +29,7 @@
 #include "shadowlog.h"
 #include "string/sprintf/snprintf.h"
 #include "string/strcmp/streq.h"
+#include "string/strcmp/strneq.h"
 #include "string/strcmp/strprefix.h"
 
 
@@ -70,9 +71,9 @@ user_busy_utmp(const char *name)
                if (utent->ut_type != USER_PROCESS) {
                        continue;
                }
-               if (strncmp (utent->ut_user, name, sizeof utent->ut_user) != 0) {
+               if (!STRNEQ(utent->ut_user, name))
                        continue;
-               }
+
                if (kill (utent->ut_pid, 0) != 0) {
                        continue;
                }
index 43cd6aac1f6bec31bac8c5548fff2f52e7aaf736..9c7466352d0e6244ad33254f6cf103cdd81a70b1 100644 (file)
@@ -32,6 +32,7 @@
 #include "sizeof.h"
 #include "string/strchr/strnul.h"
 #include "string/strcmp/streq.h"
+#include "string/strcmp/strneq.h"
 #include "string/strcmp/strprefix.h"
 #include "string/strcpy/strncpy.h"
 #include "string/strcpy/strtcpy.h"
@@ -210,7 +211,7 @@ get_session_host(char **out, pid_t main_pid)
        ut = get_current_utmp(main_pid);
 
 #if defined(HAVE_STRUCT_UTMPX_UT_HOST)
-       if ((ut != NULL) && strncmp(ut->ut_host, "", countof(ut->ut_host)) != 0) {
+       if ((ut != NULL) && !STRNEQ(ut->ut_host, "")) {
                *out = XSTRNDUP(ut->ut_host);
        } else {
                *out = NULL;
@@ -281,7 +282,7 @@ prepare_utmp(const char *name, const char *line, const char *host,
        if (NULL != host && !streq(host, ""))
                hostname = xstrdup(host);
 #if defined(HAVE_STRUCT_UTMPX_UT_HOST)
-       else if (NULL != ut && strncmp(ut->ut_host, "", countof(ut->ut_host)) != 0)
+       else if (NULL != ut && !STRNEQ(ut->ut_host, ""))
                hostname = XSTRNDUP(ut->ut_host);
 #endif
 
@@ -436,10 +437,10 @@ active_sessions_count(const char *name, unsigned long limit)
                if (USER_PROCESS != ut->ut_type) {
                        continue;
                }
-               if (strncmp(ut->ut_user, "", countof(ut->ut_user)) == 0)
+               if (STRNEQ(ut->ut_user, ""))
                        continue;
 
-               if (strncmp(ut->ut_user, name, countof(ut->ut_user)) != 0)
+               if (!STRNEQ(ut->ut_user, name))
                        continue;
 
                count++;
index aff812e2e10c3d984a766161a5c33f3630158479..f52dbeec715891493c776b7b90f3ea0f0879c0f0 100644 (file)
@@ -42,6 +42,7 @@
 #include "string/memset/memzero.h"
 #include "string/sprintf/snprintf.h"
 #include "string/strcmp/streq.h"
+#include "string/strcmp/strneq.h"
 #include "string/strcmp/strprefix.h"
 #include "string/strcpy/strtcpy.h"
 #include "string/strdup/xstrdup.h"
@@ -1200,7 +1201,7 @@ int main (int argc, char **argv)
                        printf (_("Last login: %s on %s"),
                                ptime, ll.ll_line);
 #ifdef HAVE_LL_HOST            /* __linux__ || SUN4 */
-                       if (strncmp(ll.ll_host, "", countof(ll.ll_host)) != 0) {
+                       if (!STRNEQ(ll.ll_host, "")) {
                                printf (_(" from %.*s"),
                                        (int) sizeof ll.ll_host, ll.ll_host);
                        }
index fc08fa1fd50b34b0a596867f48659f783084558b..27b570a7a4bcb30e581d4648d912eda4f7330134 100644 (file)
@@ -22,6 +22,7 @@
 #include "prototypes.h"
 #include "shadowlog.h"
 #include "sizeof.h"
+#include "string/strcmp/strneq.h"
 #include "string/strcpy/strncat.h"
 #include "string/strdup/strndupa.h"
 
@@ -179,7 +180,7 @@ main(int argc, char **argv)
                        if (ut->ut_type != USER_PROCESS) {
                                continue;
                        }
-                       if (strncmp(ut->ut_user, "", countof(ut->ut_user)) == 0)
+                       if (STRNEQ(ut->ut_user, ""))
                                continue;
 
                        if (check_login (ut)) {