]> andersk Git - moira.git/blobdiff - update/ticket.c
Diane Delgado's changes for a fixed table-locking order
[moira.git] / update / ticket.c
index 52bab6caca05985a15a545bec284d15fb47d9d95..f07ed3267e707ea39fd6d7504a6833f0e82947e8 100644 (file)
@@ -15,7 +15,7 @@ static char *rcsid_ticket_c = "$Header$";
 #include <krb.h>
 #include <sys/types.h>
 #include <sys/stat.h>
-#include <strings.h>
+#include <string.h>
 #include <update.h>
 #include <com_err.h>
 #include <krb_et.h>
@@ -23,10 +23,9 @@ static char *rcsid_ticket_c = "$Header$";
 /* too bad we can't set the pathname easily */
 static char *srvtab = KEYFILE; /* default == /etc/srvtab */
 static char realm[REALM_SZ];
-static char master[] = "sms";
-static char service[] = "rcmd";
-
-extern char *tkt_string(), *PrincipalHostname();
+static char master[INST_SZ] = "sms";
+static char service[ANAME_SZ] = "rcmd";
+C_Block session;
 
 
 static init()
@@ -34,7 +33,8 @@ static init()
     static int initialized = 0;
 
     if (!initialized) {
-       get_krbrlm(realm, 1);
+       if (krb_get_lrealm(realm, 1))
+           strcpy(realm, KRB_REALM);
        initialize_krb_error_table();
        initialized=1;
     }
@@ -42,40 +42,49 @@ static init()
 
 
 int
-get_sms_update_ticket(host, ticket)
+get_mr_update_ticket(host, ticket)
      char *host;
      KTEXT ticket;
 {
      register int code;
      register int pass;
      char phost[BUFSIZ];
+     CREDENTIALS cr;
 
      pass = 1;
      init();
-     strcpy(phost, PrincipalHostname(host));
+     strcpy(phost, krb_get_phost(host));
  try_it:
      code = krb_mk_req(ticket, service, phost, realm, (long)0);
-     if (code)
-       code += ERROR_TABLE_BASE_krb;
-     if (pass == 1) {
-        /* maybe we're taking too long? */
-        if ((code = get_sms_tgt()) != 0) {
-            /* don't need phost buffer any more */
-            com_err(whoami, code, " can't get Kerberos TGT");
-            return(code);
+     if (code) {
+        if (pass == 1) {
+            /* maybe we're taking too long? */
+            if ((code = get_mr_tgt()) != 0) {
+                com_err(whoami, code, " can't get Kerberos TGT");
+                return(code);
+            }
+            pass++;
+            goto try_it;
         }
-        pass++;
-        goto try_it;
+        com_err(whoami, code, "in krb_mk_req");
+     } else {
+        code = krb_get_cred(service, phost, realm, &cr);
+        memcpy(session, cr.session, sizeof(session));
      }
      return(code);
 }
 
 int
-get_sms_tgt()
+get_mr_tgt()
 {
     register int code;
+    char linst[INST_SZ], kinst[INST_SZ];
+
     init();
-    code = get_svc_in_tkt(master, "", realm, "krbtgt", realm, 1, srvtab);
+    linst[0] = '\0';
+    strcpy(kinst, "krbtgt");
+    code = krb_get_svc_in_tkt(master, linst, realm, kinst, realm,
+                             DEFAULT_TKT_LIFE, srvtab);
     if (!code)
        return(0);
     else
This page took 0.131638 seconds and 4 git commands to generate.