]> andersk Git - moira.git/blobdiff - clients/moira/namespace.c
Build without krb4 if it's unavailable.
[moira.git] / clients / moira / namespace.c
index a383aa351d0ddd05dc3314f24a53a143c823b59c..ad6e748de1e082119de1341268081ca1b89cdfb1 100644 (file)
@@ -14,6 +14,7 @@
 
 #include <mit-copyright.h>
 #include <moira.h>
+#include <mrclient.h>
 #include "defs.h"
 #include "f_defs.h"
 #include "globals.h"
@@ -22,8 +23,6 @@
 #include <stdio.h>
 #include <string.h>
 
-#include <krb.h>
-
 RCSID("$Header$");
 
 static void ErrorExit(char *buf, int status);
@@ -175,7 +174,6 @@ int main(int argc, char **argv)
   int status;
   Menu *menu;
   char *motd, **arg;
-  char pname[ANAME_SZ];
   struct sigaction act;
 
   if (!(program_name = strrchr(argv[0], '/')))
@@ -185,6 +183,10 @@ int main(int argc, char **argv)
   program_name = strdup(program_name);
   whoami = strdup(program_name); /* used by menu.c,  ugh !!! */
 
+  user = mrcl_krb_user();
+  if (!user)
+    exit(1);
+
   verbose = TRUE;
   arg = argv;
   moira_server = NULL;
@@ -223,41 +225,26 @@ int main(int argc, char **argv)
        }
     }
 
-  if ((status = mr_connect(moira_server)))
-    ErrorExit("\nConnection to Moira server failed", status);
+  if (mrcl_connect(moira_server, program_name, QUERY_VERSION, 0)
+      != MRCL_SUCCESS)
+    exit(1);
 
-  /* do this now since calling mr_connect initialized the krb error table
-   * for us.
-   */
-  if ((status = tf_init(TKT_FILE, R_TKT_FIL)) ||
-      (status = tf_get_pname(pname)))
+  if ((status = mr_krb5_auth(program_name)))
     {
-      com_err(whoami, status, "cannot find your ticket file");
-      exit(1);
-    }
-  tf_close();
-  user = strdup(pname);
+      if (status == MR_UNKNOWN_PROC)
+       status = mr_auth(program_name);
 
-  if ((status = mr_motd(&motd)))
-    ErrorExit("\nUnable to check server status", status);
-  if (motd)
-    {
-      fprintf(stderr, "The Moira server is currently unavailable:\n%s\n",
-             motd);
-      mr_disconnect();
-      exit(1);
-    }
-
-  if ((status = mr_auth(program_name)))
-    {
-      if (status == MR_USER_AUTH)
+      if (status)
        {
-         char buf[BUFSIZ];
-         com_err(program_name, status, "\nPress [RETURN] to continue");
-         fgets(buf, BUFSIZ, stdin);
+         if (status == MR_USER_AUTH)
+           {
+             char buf[BUFSIZ];
+             com_err(program_name, status, "\nPress [RETURN] to continue");
+             fgets(buf, BUFSIZ, stdin);
+           }
+         else
+           ErrorExit("\nAuthorization failed -- please run kinit", status);
        }
-      else
-       ErrorExit("\nAuthorization failed -- please run kinit", status);
     }
 
   /*
This page took 0.037564 seconds and 4 git commands to generate.