From 1bf063002c813dcb6ff5d6f8111119a90cb3db3a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Henrik=20Grubbstr=C3=B6m=20=28Grubba=29?=
 <grubba@grubba.org>
Date: Thu, 27 May 1999 20:31:30 +0200
Subject: [PATCH] Added support for Linux-style getspnam_r().

Rev: src/modules/system/passwords.c:1.28
---
 src/modules/system/passwords.c | 21 ++++++++++++++++++---
 1 file changed, 18 insertions(+), 3 deletions(-)

diff --git a/src/modules/system/passwords.c b/src/modules/system/passwords.c
index 4bcafe7147..e647773867 100644
--- a/src/modules/system/passwords.c
+++ b/src/modules/system/passwords.c
@@ -1,5 +1,5 @@
 /*
- * $Id: passwords.c,v 1.27 1999/05/26 17:56:56 grubba Exp $
+ * $Id: passwords.c,v 1.28 1999/05/27 18:31:30 grubba Exp $
  *
  * Password handling for Pike.
  *
@@ -22,7 +22,7 @@
 #include "system_machine.h"
 #include "system.h"
 
-RCSID("$Id: passwords.c,v 1.27 1999/05/26 17:56:56 grubba Exp $");
+RCSID("$Id: passwords.c,v 1.28 1999/05/27 18:31:30 grubba Exp $");
 
 #include "module_support.h"
 #include "interpret.h"
@@ -123,7 +123,7 @@ void push_pwent(struct passwd *ent)
   SAFE_PUSH_TEXT(ent->pw_name);
 
 #if defined(HAVE_GETSPNAM) || defined(HAVE_GETSPNAM_R)
-  if(!strcmp(ent->pw_passwd, "x") && !getuid())
+  if(!strcmp(ent->pw_passwd, "x"))
   {
     /* 64-bit Solaris 7 SIGSEGV's with an access to address 0xffffffff
      * if the user is not root:
@@ -148,9 +148,24 @@ void push_pwent(struct passwd *ent)
      *   /grubba 1999-05-26
      */
     static char buffer[2048];
+
     THREADS_ALLOW_UID();
+
+#ifdef HAVE_SOLARIS_GETSPNAM_R
     foo = getspnam_r(ent->pw_name, &bar, buffer, sizeof(buffer));
+#else /* !HAVE_SOLARIS_GETSPNAM_R */
+    /* Assume Linux-style getspnam_r().
+     * It would be nice if the function was documented...
+     *   /grubba 1999-05-27
+     */
+    foo = NULL;
+    if (getspnam_r(ent->pw_name, &bar, buffer, sizeof(buffer), &foo) < 0) {
+      foo = NULL;
+    }
+#endif /* HAVE_SOLARIS_GETSPNAM_R */
+
     THREADS_DISALLOW_UID();
+
 #else /* !HAVE_GETSPNAM_R */
     /* getspnam() is MT-unsafe!
      * /grubba 1999-05-26
-- 
GitLab