pam: Use POSIX getpwnam_r on Solaris
[openafs.git] / src / pam / afs_setcred.c
index e6713f3..286b262 100644 (file)
@@ -1,29 +1,22 @@
 /*
  * Copyright 2000, International Business Machines Corporation and others.
  * All Rights Reserved.
- * 
+ *
  * This software has been released under the terms of the IBM Public
  * License.  For details, see the LICENSE file in the top-level source
  * directory or online at http://www.openafs.org/dl/license10.html
  */
 
-#include <syslog.h>
-#include <stdlib.h>
-#include <string.h>
-#include <pwd.h>
-#include <unistd.h>
-#include <errno.h>
 #include <afsconfig.h>
 #include <afs/param.h>
 
+#include <roken.h>
+
 #include <security/pam_appl.h>
 #include <security/pam_modules.h>
 
-RCSID
-    ("$Header$");
-
-#include <sys/param.h>
 #include <afs/kautils.h>
+
 #include "afs_message.h"
 #include "afs_util.h"
 
@@ -62,7 +55,7 @@ pam_sm_setcred(pam_handle_t * pamh, int flags, int argc, const char **argv)
     int auth_ok = 0;
     char *lh;
     char *user = NULL;
-    long password_expires = -1;
+    int password_expires = -1;
     char *reason = NULL;
     struct passwd unix_pwd, *upwd = NULL;
     char upwd_buf[2048];       /* size is a guess. */
@@ -108,7 +101,7 @@ pam_sm_setcred(pam_handle_t * pamh, int flags, int argc, const char **argv)
                pam_afs_syslog(LOG_ERR, PAMAFS_OTHERCELL,
                               "cell missing argument");
            } else {
-               cell_ptr = argv[i];
+               cell_ptr = (char *)argv[i];
                pam_afs_syslog(LOG_INFO, PAMAFS_OTHERCELL, cell_ptr);
            }
        } else if (strcasecmp(argv[i], "no_unlog") == 0) {
@@ -157,8 +150,8 @@ pam_sm_setcred(pam_handle_t * pamh, int flags, int argc, const char **argv)
     /* enhanced: use "ignore_uid <number>" to specify the largest uid
      * which should be ignored by this module
      */
-#if    defined(AFS_HPUX_ENV)
-#if     defined(AFS_HPUX110_ENV)
+#if    defined(AFS_HPUX_ENV) || defined(AFS_DARWIN100_ENV) || defined(AFS_SUN58_ENV)
+#if     defined(AFS_HPUX110_ENV) || defined(AFS_DARWIN100_ENV) || defined(AFS_SUN58_ENV)
     i = getpwnam_r(user, &unix_pwd, upwd_buf, sizeof(upwd_buf), &upwd);
 #else /* AFS_HPUX110_ENV */
     i = getpwnam_r(user, &unix_pwd, upwd_buf, sizeof(upwd_buf));
@@ -170,7 +163,7 @@ pam_sm_setcred(pam_handle_t * pamh, int flags, int argc, const char **argv)
        RET(PAM_AUTH_ERR);
     }
 #else
-#if     defined(AFS_LINUX20_ENV) || defined(AFS_FBSD_ENV) || defined(AFS_NBSD_ENV)
+#if     defined(AFS_LINUX20_ENV) || defined(AFS_FBSD_ENV) || defined(AFS_DFBSD_ENV) || defined(AFS_NBSD_ENV)
     upwd = getpwnam(user);
 #else
     upwd = getpwnam_r(user, &unix_pwd, upwd_buf, sizeof(upwd_buf));
@@ -326,7 +319,7 @@ pam_sm_setcred(pam_handle_t * pamh, int flags, int argc, const char **argv)
            goto try_auth;
        }
 
-       /* pam_sm_authenticate should have set this 
+       /* pam_sm_authenticate should have set this
         * if (auth_ok && !got_authtok) {
         *     torch_password = 0;
         *     (void) pam_set_item(pamh, PAM_AUTHTOK, password);