random problems, mostly relating to dependencies on kth-krb?

Assar Westerlund assar at stacken.kth.se
Wed Jul 14 22:34:38 CEST 1999


Ken Raeburn <raeburn at raeburn.org> writes:
> If the type `krb_principal' doesn't exist (as in Cygnus or MIT
> versions), it's a good bet that functions manipulating krb_principal
> objects aren't available either:
> 
> 	krb_parse_name
> 	krb_unparse_name_r
> 	krb_unparse_name_long_r

Ok, I've added implementations (in the first case in terms of
kname_parse, and the second copying the code from krb4).  Patches at
the end.

> Also missing were
> 
> 	krb_life_to_time

This is rather hard, or it's some amount of code to copy (~200
lines).  Against what kerberos library are you linking that doesn't
have that?

> 	krb_kdctimeofday

Ok, now just calls gettimeofday if there's none.

> 	KRB_TICKET_GRANTING_TICKET

Fixed.

> the simple fix is to drop in the KTH versions to compile specially for
> Arla when a different Kerberos package is in use.

Yeah, but hopefully we will not get so far that road so that we might
as well include the whole package. :-(

/assar

Index: configure.in
===================================================================
RCS file: /afs/stacken.kth.se/src/SourceRepository/arla/configure.in,v
retrieving revision 1.285
diff -u -w -r1.285 configure.in
--- configure.in	1999/07/13 21:21:59	1.285
+++ configure.in	1999/07/14 20:31:29
@@ -532,9 +532,10 @@
 AC_TYPE_IOVEC
 AC_TYPE_KRB_PRINCIPAL
 AC_FUNC_KRB_GET_ERR_TEXT
+AC_FUNC_KRB_KDCTIMEOFDAY
 
Index: appl/klog.c
===================================================================
RCS file: /afs/stacken.kth.se/src/SourceRepository/arla/appl/klog.c,v
retrieving revision 1.2
diff -u -w -r1.2 klog.c
--- appl/klog.c	1999/07/13 07:30:53	1.2
+++ appl/klog.c	1999/07/14 20:31:31
@@ -236,6 +236,9 @@
 	return(ilist.val[0]);
 }
 
+#ifndef KRB_TICKET_GRANTING_TICKET
+#define KRB_TICKET_GRANTING_TICKET "krbtgt"
+#endif
 
 /* Get a Kerberos 4 TGT */
 
Index: appl/tokens.c
===================================================================
RCS file: /afs/stacken.kth.se/src/SourceRepository/arla/appl/tokens.c,v
retrieving revision 1.1
diff -u -w -r1.1 tokens.c
--- appl/tokens.c	1999/07/12 22:29:33	1.1
+++ appl/tokens.c	1999/07/14 20:31:31
@@ -131,7 +131,11 @@
 	/* make sure cell name is null-terminated */
 	t[127] = '\0';
 
+#ifdef HAVE_KRB_KDCTIMEOFDAY	
 	krb_kdctimeofday (&tv);
+#else
+	gettimeofday (&tv, NULL);
+#endif
 	strncpy (buf1, short_date(ct.BeginTimestamp), sizeof(buf1));
 	if (option_verbose || tv.tv_sec < ct.EndTimestamp)
 	    strncpy (buf2, short_date(ct.EndTimestamp), sizeof(buf2));
Index: cf/func-krb-kdctimeofday.m4
===================================================================
RCS file: func-krb-kdctimeofday.m4
diff -N func-krb-kdctimeofday.m4
--- /dev/null	Wed Jul 14 16:31:25 1999
+++ func-krb-kdctimeofday.m4	Wed Jul 14 16:31:33 1999
@@ -0,0 +1,28 @@
+dnl
+dnl $Id$
+dnl
+
+dnl
+dnl Check for krb_kdctimeofday
+dnl
+
+AC_DEFUN(AC_FUNC_KRB_KDCTIMEOFDAY, [
+
+AC_CACHE_CHECK(for krb_kdctimeofday, ac_cv_func_krb_kdctimeofday, [
+if test "$ac_cv_found_krb" = "yes"; then
+save_CPPFLAGS="${CPPFLAGS}"
+save_LIBS="${LIBS}"
+CPPFLAGS="${KRB_INC_FLAGS} ${CPPFLAGS}"
+LIBS="${KRB_LIB_FLAGS} ${LIBS}"
+AC_TRY_LINK([#include <krb.h>],
+[krb_kdctimeofday(0);],
+ac_cv_func_krb_kdctimeofday=yes,
+ac_cv_func_krb_kdctimeofday=no)
+CPPFLAGS="${save_CPPFLAGS}"
+LIBS="${save_LIBS}"
+fi
+])
+if test "$ac_cv_func_krb_kdctimeofday" = "yes"; then
+  AC_DEFINE(HAVE_KRB_KDCTIMEOFDAY, 1, [define if you have krb_kdctimeofday])
+fi
+])
Index: lib/acl/acl_files.c
===================================================================
RCS file: /afs/stacken.kth.se/src/SourceRepository/arla/lib/acl/acl_files.c,v
retrieving revision 1.2
diff -u -w -r1.2 acl_files.c
--- lib/acl/acl_files.c	1998/12/20 15:56:11	1.2
+++ lib/acl/acl_files.c	1999/07/14 20:31:34
@@ -52,6 +52,110 @@
 #include <krb.h>
 #include <acl.h>
 
+/*
+ * compat functions for different krb libraries
+ *
+ * this should either be moved somewhere else or compatability with
+ * other kerberos implementations should just be given up.
+ */
+
+#ifndef HAVE_KRB_PRINCIPAL 
+
+typedef struct krb_principal{
+    char name[ANAME_SZ];
+    char instance[INST_SZ];
+    char realm[REALM_SZ];
+}krb_principal;
+
+int
+krb_parse_name (const char *fullname, krb_principal *principal)
+{
+    return kname_parse (principal->name,
+			principal->instance,
+			principal->realm,
+			fullname);
+}
+
+/* copied from unparse_name.c in krb4 */
+
+static void
+quote_string(char *quote, char *from, char *to)
+{
+    while(*from){
+	if(strchr(quote, *from))
+	    *to++ = '\\';
+	*to++ = *from++;
+    }
+    *to = 0;
+}
+
+/* To be compatible with old functions, we quote differently in each
+   part of the principal*/
+
+char *
+krb_unparse_name_r(krb_principal *pr, char *fullname)
+{
+    quote_string("'@\\", pr->name, fullname);
+    if(pr->instance[0]){
+	strcat(fullname, ".");
+	quote_string("@\\", pr->instance, fullname + strlen(fullname));
+    }
+    if(pr->realm[0]){
+	strcat(fullname, "@");
+	quote_string("\\", pr->realm, fullname + strlen(fullname));
+    }
+    return fullname;
+}
+
+char *
+krb_unparse_name_long_r(char *name, char *instance, char *realm,
+			char *fullname)
+{
+    krb_principal pr;
+
+    memset(&pr, 0, sizeof(pr));
+    strncpy (pr.name, name, sizeof(pr.name));
+    pr.name[sizeof(pr.name) - 1] = '\0';
+    if(instance) {
+	strncpy (pr.instance, instance, sizeof(pr.instance));
+	pr.instance[sizeof(pr.instance) - 1] = '\0';
+    }
+    if(realm) {
+	strncpy (pr.realm, realm, sizeof(pr.realm));
+	pr.realm[sizeof(pr.realm) - 1] = '\0';
+    }
+    return krb_unparse_name_r(&pr, fullname);
+}
+
+char *
+krb_unparse_name(krb_principal *pr)
+{
+    static char principal[MAX_K_NAME_SZ];
+    krb_unparse_name_r(pr, principal);
+    return principal;
+}
+
+char *
+krb_unparse_name_long(char *name, char *instance, char *realm)
+{
+    krb_principal pr;
+
+    memset(&pr, 0, sizeof(pr));
+    strncpy(pr.name, name, sizeof(pr.name));
+    pr.name[sizeof(pr.name) - 1] = '\0';
+    if(instance) {
+	strncpy(pr.instance, instance, sizeof(pr.instance));
+	pr.instance[sizeof(pr.instance) - 1] = '\0';
+    }
+    if(realm) {
+	strncpy(pr.realm, realm, sizeof(pr.realm));
+	pr.realm[sizeof(pr.realm) - 1] = '\0';
+    }
+    return krb_unparse_name(&pr);
+}
+
+#endif /* HAVE_KRB_PRINCIPAL */
+
 /*** Routines for manipulating access control list files ***/
 
 /* "aname.inst at realm" */





More information about the Arla-drinkers mailing list