From 2cecb84bd7c2108b2e184b7ad196b39deb301ec4 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Wilfried=20G=C3=B6esgens?= Date: Thu, 10 Jan 2008 00:09:28 +0000 Subject: [PATCH] * openbsd doesn't like pam. so... if we don't have the calls don't use 'em --- citadel/citadel.c | 1 + citadel/configure.ac | 2 +- citadel/server_main.c | 17 +++++++++++++---- citadel/user_ops.c | 16 ++++++++++++---- 4 files changed, 27 insertions(+), 9 deletions(-) diff --git a/citadel/citadel.c b/citadel/citadel.c index edd981cb3..700c732f2 100644 --- a/citadel/citadel.c +++ b/citadel/citadel.c @@ -2341,3 +2341,4 @@ TERMN8: scr_printf("%s logged out.", fullname); goto GSTA; } /* end main() */ + diff --git a/citadel/configure.ac b/citadel/configure.ac index 4880fd306..cb7ed9be8 100644 --- a/citadel/configure.ac +++ b/citadel/configure.ac @@ -308,7 +308,7 @@ dnl Checks for libraries. dnl We want to test for the following in libc before checking for their dnl respective libraries, because some systems (like Irix) have both, and the dnl non-libc versions may be broken. -AC_CHECK_FUNCS(crypt gethostbyname connect flock) +AC_CHECK_FUNCS(crypt gethostbyname connect flock getpwnam_r getpwuid_r) dnl disable backtrace if we don't want it. diff --git a/citadel/server_main.c b/citadel/server_main.c index d9c6d17e8..a63564d17 100644 --- a/citadel/server_main.c +++ b/citadel/server_main.c @@ -229,11 +229,15 @@ int main(int argc, char **argv) /* on some dists rundir gets purged on startup. so we need to recreate it. */ if (stat(ctdl_run_dir, &filestats)==-1){ +#ifdef HAVE_GETPWUID_R #ifdef SOLARIS_GETPWUID pwp = getpwuid_r(config.c_ctdluid, &pw, pwbuf, sizeof(pwbuf)); -#else +#else // SOLARIS_GETPWUID getpwuid_r(config.c_ctdluid, &pw, pwbuf, sizeof(pwbuf), &pwp); -#endif +#endif // SOLARIS_GETPWUID +#else // HAVE_GETPWUID_R + pwp = NULL; +#endif // HAVE_GETPWUID_R mkdir(ctdl_run_dir, 0755); chown(ctdl_run_dir, config.c_ctdluid, (pwp==NULL)?-1:pw.pw_gid); } @@ -304,11 +308,16 @@ int main(int argc, char **argv) if (drop_root_perms) { cdb_chmod_data(); /* make sure we own our data files */ +#ifdef HAVE_GETPWUID_R #ifdef SOLARIS_GETPWUID pwp = getpwuid_r(config.c_ctdluid, &pw, pwbuf, sizeof(pwbuf)); -#else +#else // SOLARIS_GETPWUID getpwuid_r(config.c_ctdluid, &pw, pwbuf, sizeof(pwbuf), &pwp); -#endif +#endif // SOLARIS_GETPWUID +#else // HAVE_GETPWUID_R + pwp = NULL; +#endif // HAVE_GETPWUID_R + if (pwp == NULL) CtdlLogPrintf(CTDL_CRIT, "WARNING: getpwuid(%ld): %s\n" "Group IDs will be incorrect.\n", (long)CTDLUID, diff --git a/citadel/user_ops.c b/citadel/user_ops.c index 67eab32fc..a144fc0d2 100644 --- a/citadel/user_ops.c +++ b/citadel/user_ops.c @@ -390,11 +390,15 @@ int CtdlLoginExistingUser(char *authname, char *trythisname) char pwdbuffer[256]; lprintf(CTDL_DEBUG, "asking host about <%s>\n", username); +#ifdef HAVE_GETPWNAM_R #ifdef SOLARIS_GETPWUID tempPwdPtr = getpwnam_r(username, &pd, pwdbuffer, sizeof pwdbuffer); -#else +#else // SOLARIS_GETPWUID getpwnam_r(username, &pd, pwdbuffer, sizeof pwdbuffer, &tempPwdPtr); -#endif +#endif // SOLARIS_GETPWUID +#else // HAVE_GETPWNAM_R + tempPwdPtr = NULL; +#endif // HAVE_GETPWNAM_R if (tempPwdPtr == NULL) { return login_not_found; } @@ -876,11 +880,15 @@ int create_user(char *newusername, int become_user) struct passwd *tempPwdPtr; char pwdbuffer[256]; +#ifdef HAVE_GETPWNAM_R #ifdef SOLARIS_GETPWUID tempPwdPtr = getpwnam_r(username, &pd, pwdbuffer, sizeof(pwdbuffer)); -#else +#else // SOLARIS_GETPWUID getpwnam_r(username, &pd, pwdbuffer, sizeof pwdbuffer, &tempPwdPtr); -#endif +#endif // SOLARIS_GETPWUID +#else // HAVE_GETPWNAM_R + tempPwdPtr = NULL; +#endif // HAVE_GETPWNAM_R if (tempPwdPtr != NULL) { extract_token(username, pd.pw_gecos, 0, ',', sizeof username); uid = pd.pw_uid; -- 2.30.2