]> andersk Git - moira.git/blobdiff - update/client.c
Use krb5_error_code for return value of krb5 library functions.
[moira.git] / update / client.c
index 8b8f46c8bbbf7b540b1212620b19f057d2184cc4..4733e984a3c259a9bc1b9b70255262766e5259aa 100644 (file)
 
 #include <des.h>
 #include <krb.h>
+#include <krb5.h>
 
 RCSID("$Header$");
 
 extern des_cblock session;
 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;
+
+  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)
 {
   KTEXT_ST ticket_st;
   int code, auth_version = 2;
@@ -87,7 +129,7 @@ int send_auth(int conn, char *host_name)
   return MR_SUCCESS;
 }
 
-int execute(int conn, char *path)
+int mr_execute(int conn, char *path)
 {
   long response;
   char *data;
@@ -110,7 +152,7 @@ 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);
 }
This page took 0.034563 seconds and 4 git commands to generate.