#undef EGD_POOL
+
+
+/* check for the bsd style getpwuid_r */
+#undef BSD_GETPWUID
}
#ifndef __CYGWIN__
if (st.st_uid != CTDLUID) {
- fprintf(stderr, "%s must be owned by uid=%d but %d owns it!\n", file_citadel_config, CTDLUID, st.st_uid);
+ fprintf(stderr, "%s must be owned by uid=%ld but %ld owns it!\n", file_citadel_config, CTDLUID, st.st_uid);
exit(CTDLEXIT_CONFIG);
}
int desired_mode = (S_IFREG | S_IRUSR | S_IWUSR) ;
AC_DEFINE(HAVE_UT_TYPE)
fi
+AC_CACHE_CHECK([for call semantics from getpwuid_r], ac_cv_call_getpwuid_r,
+[AC_TRY_COMPILE([#include <pwd.h>], [
+ struct passwd pw, *pwp = NULL;
+ char pwbuf[64];
+ uid_t uid;
+
+ getpwuid_r(uid, &pw, pwbuf, sizeof(pwbuf), &pwp);
+
+],
+ac_cv_call_getpwuid_r=yes, ac_cv_call_getpwuid_r=no)])
+if test $ac_cv_call_getpwuid_r = no; then
+ AC_DEFINE(BSD_GETPWUID)
+fi
+
+
+
AC_CACHE_CHECK([for ut_host in struct utmp], ac_cv_struct_ut_host,
[AC_TRY_COMPILE([#include <sys/types.h>
#include <utmp.h>], [struct utmp ut; ut.ut_host;],
*/
void lock_control(void)
{
+#ifndef BSD_GETPWUID
+/*
+ * TODO: solaris manpages describe this function, but the headers
+ * don't show it!
+ */
if (flock(fileno(control_fp), (LOCK_EX | LOCK_NB))) {
lprintf(CTDL_EMERG, "citserver: unable to lock %s.\n", file_citadel_control);
lprintf(CTDL_EMERG, "Is another citserver already running?\n");
exit(CTDLEXIT_CONTROL);
}
+#endif
}
/* on some dists rundir gets purged on startup. so we need to recreate it. */
if (stat(ctdl_run_dir, &filestats)==-1){
+#ifdef BSD_GETPWUID
+ pwp = getpwuid_r(config.c_ctdluid, &pw, pwbuf, sizeof(pwbuf));
+#else
getpwuid_r(config.c_ctdluid, &pw, pwbuf, sizeof(pwbuf), &pwp);
+#endif
mkdir(ctdl_run_dir, 0755);
chown(ctdl_run_dir, config.c_ctdluid, (pwp==NULL)?-1:pw.pw_gid);
}
* corresponding group ids
*/
if (drop_root_perms) {
+#ifdef BSD_GETPWUID
+ pwp = getpwuid_r(config.c_ctdluid, &pw, pwbuf, sizeof(pwbuf));
+#else
getpwuid_r(config.c_ctdluid, &pw, pwbuf, sizeof(pwbuf), &pwp);
-
+#endif
if (pwp == NULL)
lprintf(CTDL_CRIT, "WARNING: getpwuid(%ld): %s\n"
"Group IDs will be incorrect.\n", (long)CTDLUID,
#include <sys/stat.h>
#include <sys/wait.h>
#include <sys/socket.h>
+#include <syslog.h>
#include <sys/syslog.h>
#if TIME_WITH_SYS_TIME
sin.sin_addr.s_addr = inet_addr(ip_addr);
}
- if (sin.sin_addr.s_addr == INADDR_NONE) {
+ if (sin.sin_addr.s_addr == !INADDR_ANY) {
sin.sin_addr.s_addr = INADDR_ANY;
}
else {
fp = fopen(file_pid_file, "w");
if (fp != NULL) {
- fprintf(fp, "%d\n", child);
+ fprintf(fp, "%ld\n", child);
fclose(fp);
}
waitpid(current_child, &status, 0);
char pwdbuffer[256];
lprintf(CTDL_DEBUG, "asking host about <%s>\n", username);
+#ifdef BSD_GETPWUID
+ tempPwdPtr = getpwnam_r(username, &pd, pwdbuffer, sizeof pwdbuffer);
+#else
getpwnam_r(username, &pd, pwdbuffer, sizeof pwdbuffer, &tempPwdPtr);
+#endif
if (tempPwdPtr == NULL) {
return login_not_found;
}
- lprintf(CTDL_DEBUG, "found it! uid=%d, gecos=%s\n", pd.pw_uid, pd.pw_gecos);
+ lprintf(CTDL_DEBUG, "found it! uid=%ld, gecos=%s\n", (long)pd.pw_uid, pd.pw_gecos);
/* Locate the associated Citadel account.
* If not found, make one attempt to create it.
struct passwd *tempPwdPtr;
char pwdbuffer[256];
+#ifdef BSD_GETPWUID
+ tempPwdPtr = getpwnam_r(username, &pd, pwdbuffer, sizeof(pwdbuffer));
+#else
getpwnam_r(username, &pd, pwdbuffer, sizeof pwdbuffer, &tempPwdPtr);
+#endif
if (tempPwdPtr != NULL) {
extract_token(username, pd.pw_gecos, 0, ',', sizeof username);
uid = pd.pw_uid;