]> andersk Git - moira.git/blobdiff - update/client.c
Build without krb4 if it's unavailable.
[moira.git] / update / client.c
index f5197b798c1632fdd7d65f8cf4682a2b72904955..5b86b0c5676a8f9f91cab5470badc8b06922ab42 100644 (file)
 #include <errno.h>
 #include <stdio.h>
 #include <stdlib.h>
+#include <string.h>
 
+#ifdef HAVE_KRB4
 #include <des.h>
 #include <krb.h>
+#endif
+#include <krb5.h>
 
 RCSID("$Header$");
 
+#ifdef HAVE_KRB4
 extern des_cblock session;
+#endif
+extern char *whoami;
+extern krb5_context context;
 
-int send_auth(int conn, char *host_name)
+int mr_send_krb5_auth(int conn, char *host_name)
 {
+  krb5_data auth;
+  int code;
+  long response;
+
+  memset(&auth, 0, sizeof(auth));
+
+  code = get_mr_krb5_update_ticket(host_name, &auth);
+  if (code)
+    goto out;
+  code = send_string(conn, "AUTH_003", 9);
+  if (code)
+    goto out;
+  code = recv_int(conn, &response);
+  if (code)
+    goto out;
+  if (response)
+    {
+      /* Talking to a server that doesn't do AUTH_003 */
+      krb5_free_data_contents(context, &auth);
+      return response;
+    }
+  code = send_string(conn, (char *)auth.data, auth.length);
+  if (code)
+    goto out;
+  code = recv_int(conn, &response);
+  if (code)
+    goto out;
+  if (response)
+    {
+      krb5_free_data_contents(context, &auth);
+      return response;
+    }
+
+  return MR_SUCCESS;
+
+ out:
+  krb5_free_data_contents(context, &auth);
+  return code;
+}
+
+int mr_send_auth(int conn, char *host_name)
+{
+#ifdef HAVE_KRB4
   KTEXT_ST ticket_st;
   int code, auth_version = 2;
   long response;
@@ -83,9 +134,12 @@ int send_auth(int conn, char *host_name)
     }
 
   return MR_SUCCESS;
+#else
+  return MR_NO_KRB4;
+#endif
 }
 
-int execute(int conn, char *path)
+int mr_execute(int conn, char *path)
 {
   long response;
   char *data;
@@ -108,12 +162,13 @@ int execute(int conn, char *path)
   return MR_SUCCESS;
 }
 
-void send_quit(int conn)
+void mr_send_quit(int conn)
 {
   send_string(conn, "quit", 5);
 }
 
 void fail(int conn, int err, char *msg)
 {
+  com_err(whoami, err, msg);
   return;
 }
This page took 0.046929 seconds and 4 git commands to generate.