From fef7d6f777b017878ba225395fe4199af5f1c581 Mon Sep 17 00:00:00 2001 From: Halton Huo Date: Wed, 11 Feb 2009 20:39:18 -0500 Subject: 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 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 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 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 --- pam-ck-connector/Makefile.am | 2 ++ pam-ck-connector/pam-ck-connector.c | 18 +++++++++++++++++- 2 files changed, 19 insertions(+), 1 deletion(-) 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 #include #include +#include #include #ifdef HAVE_PATHS_H @@ -51,8 +52,8 @@ #define PAM_SM_SESSION +#include #include -#include #ifdef HAVE_SECURITY_PAM_MODUTIL_H #include #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) { -- cgit