]> git.ipfire.org Git - thirdparty/shadow.git/commitdiff
lib/, src/, po/: pw_entry(): Move function to src/sulogin.c
authorAlejandro Colomar <alx@kernel.org>
Wed, 17 Jan 2024 15:48:53 +0000 (16:48 +0100)
committerSerge Hallyn <serge@hallyn.com>
Thu, 18 Jan 2024 00:11:19 +0000 (18:11 -0600)
That's the only file where it's called, and it's a delicate function.
Reduce the chances that other files call it.

Link: <https://github.com/shadow-maint/shadow/pull/908>
Suggested-by: Samanta Navarro <ferivoz@riseup.net>
Cc: Serge Hallyn <serge@hallyn.com>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
lib/Makefile.am
lib/entry.c [deleted file]
lib/prototypes.h
po/POTFILES.in
src/sulogin.c

index b437bbd397b902d6b6065324856005a75ba0162b..308099fc26262263a389a078a414f75df22d6404 100644 (file)
@@ -50,7 +50,6 @@ libshadow_la_SOURCES = \
        date_to_str.c \
        defines.h \
        encrypt.c \
-       entry.c \
        env.c \
        exitcodes.h \
        faillog.h \
diff --git a/lib/entry.c b/lib/entry.c
deleted file mode 100644 (file)
index 88a06b2..0000000
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * SPDX-FileCopyrightText: 1989 - 1994, Julianne Frances Haugh
- * SPDX-FileCopyrightText: 1996 - 2000, Marek Michałkiewicz
- * SPDX-FileCopyrightText: 2003 - 2005, Tomasz Kłoczko
- * SPDX-FileCopyrightText: 2007 - 2008, Nicolas François
- *
- * SPDX-License-Identifier: BSD-3-Clause
- */
-
-#include <config.h>
-
-#ident "$Id$"
-
-#include <sys/types.h>
-#include <stdio.h>
-
-#include "alloc.h"
-#include "prototypes.h"
-#include "defines.h"
-#include <pwd.h>
-
-void pw_entry (const char *name, struct passwd *pwent)
-{
-       struct passwd *passwd;
-
-       struct spwd *spwd;
-
-       if (!(passwd = getpwnam (name))) { /* local, no need for xgetpwnam */
-               pwent->pw_name = NULL;
-               return;
-       } else {
-               pwent->pw_name = xstrdup (passwd->pw_name);
-               pwent->pw_uid = passwd->pw_uid;
-               pwent->pw_gid = passwd->pw_gid;
-               pwent->pw_gecos = xstrdup (passwd->pw_gecos);
-               pwent->pw_dir = xstrdup (passwd->pw_dir);
-               pwent->pw_shell = xstrdup (passwd->pw_shell);
-#if !defined(AUTOSHADOW)
-               /* local, no need for xgetspnam */
-               if ((spwd = getspnam (name))) {
-                       pwent->pw_passwd = xstrdup (spwd->sp_pwdp);
-                       return;
-               }
-#endif
-               pwent->pw_passwd = xstrdup (passwd->pw_passwd);
-       }
-}
index 0f709bdd6f0b717c97a2cea249b56e2e9536f4d1..6aa48e9b0eb9d2c37e35b4dab9a4b87fd6b41f41 100644 (file)
@@ -114,9 +114,6 @@ extern void date_to_str (size_t size, char buf[size], long date);
 /* encrypt.c */
 extern /*@exposed@*//*@null@*/char *pw_encrypt (const char *, const char *);
 
-/* entry.c */
-extern void pw_entry (const char *, struct passwd *);
-
 /* env.c */
 extern void addenv (const char *, /*@null@*/const char *);
 extern void initenv (void);
index d6c877519061b46edbfa4944f2dfa278c43f5c2a..d49a546066b19c5f82d9bc53a6224b3841773ab4 100644 (file)
@@ -15,7 +15,6 @@ lib/console.c
 lib/copydir.c
 lib/date_to_str.c
 lib/encrypt.c
-lib/entry.c
 lib/env.c
 lib/failure.c
 lib/fields.c
index 0bb9d900b9712b46164395ba35cdd9c27c323044..95b1a48aff3c99434d38249012302af83897c70d 100644 (file)
 #include <signal.h>
 #include <stdio.h>
 #include <sys/ioctl.h>
+#include <sys/types.h>
 
 #include "agetpass.h"
+#include "alloc.h"
 #include "attr.h"
 #include "defines.h"
 #include "getdef.h"
@@ -29,6 +31,7 @@
 #include "shadowlog.h"
 #include "string/strtcpy.h"
 
+
 /*
  * Global variables
  */
@@ -45,8 +48,10 @@ extern size_t newenvc;
 #define        ALARM   60
 #endif
 
-/* local function prototypes */
+
 static void catch_signals (int);
+static void pw_entry(const char *name, struct passwd *pwent);
+
 
 static void catch_signals (unused int sig)
 {
@@ -184,3 +189,31 @@ static void catch_signals (unused int sig)
        return ((err == ENOENT) ? E_CMD_NOTFOUND : E_CMD_NOEXEC);
 }
 
+
+static void
+pw_entry(const char *name, struct passwd *pwent)
+{
+       struct passwd *passwd;
+
+       struct spwd *spwd;
+
+       if (!(passwd = getpwnam (name))) { /* local, no need for xgetpwnam */
+               pwent->pw_name = NULL;
+               return;
+       } else {
+               pwent->pw_name = xstrdup (passwd->pw_name);
+               pwent->pw_uid = passwd->pw_uid;
+               pwent->pw_gid = passwd->pw_gid;
+               pwent->pw_gecos = xstrdup (passwd->pw_gecos);
+               pwent->pw_dir = xstrdup (passwd->pw_dir);
+               pwent->pw_shell = xstrdup (passwd->pw_shell);
+#if !defined(AUTOSHADOW)
+               /* local, no need for xgetspnam */
+               if ((spwd = getspnam (name))) {
+                       pwent->pw_passwd = xstrdup (spwd->sp_pwdp);
+                       return;
+               }
+#endif
+               pwent->pw_passwd = xstrdup (passwd->pw_passwd);
+       }
+}