]> andersk Git - moira.git/blobdiff - server/mr_main.c
Build without krb4 if it's unavailable.
[moira.git] / server / mr_main.c
index 629cc34930eb71b11803ce55efa91560985e9dcb..2935aa7f9f7610dc85d3550f19ad4a197c825af3 100644 (file)
 #include <string.h>
 #include <unistd.h>
 
+#ifdef HAVE_KRB4
 #include <krb.h>
+#endif
+#include <krb5.h>
 
 RCSID("$Header$");
 
-extern char *krb_get_lrealm(char *, int);
-
 client *cur_client;
 
 char *whoami;
@@ -43,13 +44,16 @@ FILE *journal;
 time_t now;
 
 char *host;
-char krb_realm[REALM_SZ];
+krb5_context context = NULL;
+char *krb_realm = NULL;
 
 /* Client array and associated data. This needs to be global for _list_users */
 client **clients;
 int nclients, clientssize;
 
 int dormant;
+int child_exited_abnormally = 0;
+int child_pid, child_signal, child_status;
 
 void reapchild(int x);
 void godormant(int x);
@@ -104,7 +108,19 @@ int main(int argc, char **argv)
        }
     }
 
-  krb_get_lrealm(krb_realm, 1);
+  status = krb5_init_context(&context);
+  if (status)
+    {
+      com_err(whoami, status, "Initializing krb5 context.");
+      exit(1);
+    }
+
+  status = krb5_get_default_realm(context, &krb_realm);
+  if (status)
+    {
+      com_err(whoami, status, "Getting default Kerberos realm.");
+      exit(1);
+    }
 
   /*
    * Database initialization.  Only init if database should be open.
@@ -162,9 +178,10 @@ int main(int argc, char **argv)
   /*
    * Establish template connection.
    */
-  if (!(listener = mr_listen(port)))
+  listener = mr_listen(port);
+  if (listener == -1)
     {
-      com_err(whoami, status, "trying to create listening connection");
+      com_err(whoami, MR_ABORTED, "trying to create listening connection");
       exit(1);
     }
   FD_ZERO(&xreadfds);
@@ -213,6 +230,14 @@ int main(int argc, char **argv)
 
       if (takedown)
        break;
+
+      if (child_exited_abnormally)
+       {
+         critical_alert("moirad", "%d: child exits with signal %d status %d",
+                        child_pid, child_signal, child_status);
+         child_exited_abnormally = 0;
+       }
+
       time(&now);
       if (!inc_running || now - inc_started > INC_TIMEOUT)
        next_incremental();
@@ -372,8 +397,10 @@ void reapchild(int x)
        inc_running = 0;
       if (!takedown && (WTERMSIG(status) != 0 || WEXITSTATUS(status) != 0))
        {
-         critical_alert("moirad", "%d: child exits with signal %d status %d",
-                        pid, WTERMSIG(status), WEXITSTATUS(status));
+         child_exited_abnormally = 1;
+         child_pid = pid;
+         child_signal = WTERMSIG(status);
+         child_status = WEXITSTATUS(status);
        }
     }
 }
This page took 0.169547 seconds and 4 git commands to generate.