summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHalton Huo <halton.huo@sun.com>2009-02-11 20:39:18 -0500
committerWilliam Jon McCann <jmccann@redhat.com>2009-02-11 20:39:18 -0500
commitfef7d6f777b017878ba225395fe4199af5f1c581 (patch)
treef83d45bb2d53bb21482eb1423a81122f8185f0cc
parentda3a3fe00ad4c4e750e467db58d383ebf4da978f (diff)
fix building with Solaris PAM
This patch is a little different with Brian's. Let's me explain the whole patch one by one. 1. pam-ck-connector/Makefile.am (same with Brian's) Solaris does not have libpam_misc, so only build test_pam under linux 2. +#include <limits.h> This is to get macro PATH_MAX from system. I think it is better than +#ifndef PATH_MAX +#define PATH_MAX 4096 +#endif On ubuntu, PATH_MAX=4096, on Solaris, PATH_MAX=1024 3. +#include <security/pam_appl.h> This is to include declaration of pam_handle_t, to resolve error like: "/usr/include/security/pam_modules.h", line 38: syntax error before or at: * "/usr/include/security/pam_modules.h", line 45: syntax error before or at: * 4.-#include <security/_pam_macros.h> Solaris does not have this file, I remove it, no more error, seems no use here. 5. +#ifndef PAM_EXTERN ... part Solaris PAM_EXTERN marco in pam_modules.h, while Ubuntu has, I just copy the logic from Ubuntu. 6. getpwnam_r part (same with Brian's) getpwnam_r() have difference behavior between Solaris and Ubuntu. https://bugs.freedesktop.org/show_bug.cgi?id=18173
-rw-r--r--pam-ck-connector/Makefile.am2
-rw-r--r--pam-ck-connector/pam-ck-connector.c18
2 files changed, 19 insertions, 1 deletions
diff --git a/pam-ck-connector/Makefile.am b/pam-ck-connector/Makefile.am
index eab4864..9d32639 100644
--- a/pam-ck-connector/Makefile.am
+++ b/pam-ck-connector/Makefile.am
@@ -22,6 +22,7 @@ pam_ck_connector_la_LIBADD = \
man_MANS = pam_ck_connector.8
+if CK_COMPILE_LINUX
noinst_PROGRAMS = \
test-pam \
$(NULL)
@@ -34,6 +35,7 @@ test_pam_LDADD = \
$(PAM_LIBS) \
-lpam_misc \
$(NULL)
+endif
endif
diff --git a/pam-ck-connector/pam-ck-connector.c b/pam-ck-connector/pam-ck-connector.c
index 091f4b2..6e41cf5 100644
--- a/pam-ck-connector/pam-ck-connector.c
+++ b/pam-ck-connector/pam-ck-connector.c
@@ -39,6 +39,7 @@
#include <sys/types.h>
#include <unistd.h>
#include <dirent.h>
+#include <limits.h>
#include <errno.h>
#ifdef HAVE_PATHS_H
@@ -51,8 +52,8 @@
#define PAM_SM_SESSION
+#include <security/pam_appl.h>
#include <security/pam_modules.h>
-#include <security/_pam_macros.h>
#ifdef HAVE_SECURITY_PAM_MODUTIL_H
#include <security/pam_modutil.h>
#endif
@@ -71,6 +72,14 @@ static int opt_nox11 = FALSE;
#define LOG_AUTHPRIV LOG_AUTH
#endif
+#ifndef PAM_EXTERN
+#ifdef PAM_STATIC
+#define PAM_EXTERN static
+#else
+#define PAM_EXTERN extern
+#endif
+#endif
+
static void
ck_pam_vsyslog (const pam_handle_t *pamh,
int priority,
@@ -188,10 +197,17 @@ _util_name_to_uid (const char *username,
bufsize = sysconf (_SC_GETPW_R_SIZE_MAX);
buf = calloc (sizeof (char), bufsize);
+#ifdef __sun
+ pwdp = getpwnam_r (username, &pwd, buf, bufsize);
+ if (pwdp == NULL) {
+ goto out;
+ }
+#else
rc = getpwnam_r (username, &pwd, buf, bufsize, &pwdp);
if (rc != 0 || pwdp == NULL) {
goto out;
}
+#endif
res = pwdp->pw_uid;
if (default_gid != NULL) {