* solaris compatibility patches.
authorWilfried Göesgens <willi@citadel.org>
Sun, 25 Feb 2007 22:10:26 +0000 (22:10 +0000)
committerWilfried Göesgens <willi@citadel.org>
Sun, 25 Feb 2007 22:10:26 +0000 (22:10 +0000)
citadel/acconfig.h
citadel/config.c
citadel/configure.ac
citadel/control.c
citadel/server_main.c
citadel/sysdep.c
citadel/user_ops.c

index f3e96e6b071e98afee3a99879b0e9ae75c7eb77f..63401969f5e3140b97f0f7808109c72db1f60b52 100644 (file)
@@ -64,3 +64,7 @@
 
 
 #undef EGD_POOL 
+
+
+/* check for the bsd style getpwuid_r */
+#undef BSD_GETPWUID
index 412f1a7176480cff988cb7b02cbdda39d2d54008..b466c3acae182f4f7660bdf2320a946389cd9640 100644 (file)
@@ -55,7 +55,7 @@ void get_config(void) {
        }
 #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) ;
index fefd6b1c224b3f111656b4ebbd46a1b9cd032994..7e76d37e65611df73b10eeb8b9e3e603081477dd 100644 (file)
@@ -609,6 +609,22 @@ if test $ac_cv_struct_ut_type = yes; then
        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;],
index 5ef54287aee0154d3710c1543d70c5c940f606f3..a6d61f82d4fbf44591f93c604da6033fddf914b2 100644 (file)
@@ -57,11 +57,17 @@ FILE *control_fp = NULL;
  */
 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
 }
 
 
index 568467fd437e9c829af3def6a5b40237cfc37f7a..f5ee8dc7d9e12d1ebbc05cf4c60df54bb3a866df 100644 (file)
@@ -191,7 +191,11 @@ 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 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);
        }
@@ -237,8 +241,11 @@ int main(int argc, char **argv)
         * 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,
index 8986c9ed72879838bcba0ee4c9030ef6d35130f6..d463421b47c122f20d42d60957ff8c1f2aecb920 100644 (file)
@@ -23,6 +23,7 @@
 #include <sys/stat.h>
 #include <sys/wait.h>
 #include <sys/socket.h>
+#include <syslog.h>
 #include <sys/syslog.h>
 
 #if TIME_WITH_SYS_TIME
@@ -290,7 +291,7 @@ int ig_tcp_server(char *ip_addr, int port_number, int queue_len, char **errormes
                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;
        }
 
@@ -836,7 +837,7 @@ void start_daemon(int unused) {
                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);
index 296a576774442d87ed2a01678d39cdf8d339c6e3..db277c5ae4289bea9a0f66c751bfaebfb933a545 100644 (file)
@@ -367,11 +367,15 @@ int CtdlLoginExistingUser(char *trythisname)
                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.
@@ -834,7 +838,11 @@ int create_user(char *newusername, int become_user)
                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;