]> andersk Git - moira.git/blobdiff - update/ticket.c
Use krb5_error_code for return value of krb5 library functions.
[moira.git] / update / ticket.c
index 26502f3b8d1a20196daf2b2865c44f6e67dc2139..442486cbc075af581c263866fb5ed94e6faeb206 100644 (file)
 #include <string.h>
 
 #include <krb.h>
+#include <krb5.h>
 #include <update.h>
 
 RCSID("$Header$");
 
-static char *srvtab = KEYFILE; /* default == /etc/srvtab */
 static char realm[REALM_SZ];
 static char master[INST_SZ] = "sms";
 static char service[ANAME_SZ] = "rcmd";
 des_cblock session;
+krb5_context context = NULL;
 
 static int get_mr_tgt(void);
 
+int get_mr_krb5_update_ticket(char *host, krb5_data auth)
+{
+  krb5_auth_context auth_con = NULL;
+  krb5_ccache ccache = NULL;
+  krb5_error_code code;
+
+  code = krb5_init_context(&context);
+  if (code)
+    goto out;
+
+  code = krb5_auth_con_init(context, &auth_con);
+  if (code)
+    goto out;
+
+  krb5_init_ets(context);
+
+  code = krb5_cc_default(context, &ccache);
+  if (code)
+    goto out;
+
+  code = krb5_mk_req(context, &auth_con, NULL, "host", host, NULL, ccache,
+                    &auth);
+
+ out:
+  if (ccache)
+    krb5_cc_close(context, ccache);
+  if (auth_con)
+    krb5_auth_con_free(context, auth_con);
+  return code;
+}
+
 int get_mr_update_ticket(char *host, KTEXT ticket)
 {
   int code, pass;
@@ -73,7 +105,7 @@ static int get_mr_tgt(void)
   linst[0] = '\0';
   strcpy(kinst, "krbtgt");
   code = krb_get_svc_in_tkt(master, linst, realm, kinst, realm,
-                           DEFAULT_TKT_LIFE, srvtab);
+                           DEFAULT_TKT_LIFE, KEYFILE);
   if (!code)
     return 0;
   else
This page took 0.035144 seconds and 4 git commands to generate.