[5603] in Moira

home help back first fref pref prev next nref lref last post

patch to compile moira against heimdal krb5

daemon@ATHENA.MIT.EDU (Benjamin Kaduk)
Thu Feb 25 23:03:52 2010

Date: Thu, 25 Feb 2010 23:03:45 -0500 (EST)
From: Benjamin Kaduk <kaduk@MIT.EDU>
To: moiradev@MIT.EDU
Message-ID: <alpine.GSO.1.10.1002252255470.29136@multics.mit.edu>
MIME-Version: 1.0
Content-Type: TEXT/PLAIN; format=flowed; charset=US-ASCII

It's unclear if this is orthogonal to the configure.in patch to use 
krb5-config or not.

The patch below should not be taken directly, as it breaks compilation 
against MIT krb5, but I think it's probably worth getting it into the 
discuss archive.

Looking towards a version-agnostic patch, judging by what Russ Allbery has 
done for similar cases, it's probably best to check for a 
krb5_principal_get_comp_string() in configure and define one (in terms of 
krb5_princ_component()) if necessary.

I guess the right thing to do for the auth_003.c case is to check
in configure whether the krb5_ticket type has an enc_part2 member
and conditionalize on that, but that is less clear to me.

-Ben

diff -ru src-orig/clients/lib/utils.c src/clients/lib/utils.c
--- src-orig/clients/lib/utils.c	2010-02-25 20:35:30.000000000 -0500
+++ src/clients/lib/utils.c	2010-02-25 22:39:40.000000000 -0500
@@ -113,6 +113,7 @@
    krb5_principal princ = NULL;
    krb5_error_code status;
    char *username = NULL;
+  const char *o_username = NULL;

    if (!context)
      krb5_init_context(&context);
@@ -131,13 +132,12 @@
        goto out;
      }

-  username = malloc(krb5_princ_component(context, princ, 0)->length + 1);
+  o_username = krb5_principal_get_comp_string(context, princ, 0);
+  username = malloc(strlen(o_username) + 1);
    if (!username)
      goto out;

-  strncpy(username, krb5_princ_component(context, princ, 0)->data,
-	  krb5_princ_component(context, princ, 0)->length);
-  username[krb5_princ_component(context, princ, 0)->length] = '\0';
+  strncpy(username, o_username, strlen(o_username) + 1);

   out:
    if (cache)
diff -ru src-orig/update/auth_003.c src/update/auth_003.c
--- src-orig/update/auth_003.c	2010-02-25 20:35:08.000000000 -0500
+++ src/update/auth_003.c	2010-02-25 22:40:30.000000000 -0500
@@ -110,7 +110,7 @@
        goto out;
      }

-  code = krb5_copy_principal(context, ticket->enc_part2->client, &client);
+  code = krb5_copy_principal(context, ticket->client, &client);
    if (code)
      {
        com_err(whoami, code, "(krb5_copy_principal failed)");


home help back first fref pref prev next nref lref last post