[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: keytab code and missing /etc/srvtab



Chris Chiappa <griffon+heimdal-discuss@snurgle.org> writes:
> I've spent some time debugging this and I'm getting somewhat lost in the
> various levels of indirection so I'm hoping someone more familiar with the
> code can spot the problem.  Using the OpenSSH sshd with the gssapi patches
> from http://www.sxw.org.uk/computing/patches/openssh.html, the server
> process chokes if there is no /etc/srvtab with the attached backtrace.  My
> naive fix is in keytab_krb4.c:krb4_kt_end_seq_get at the top to do
>     if(c->fd < 0)
>         return 0;

I assume this is with 0.3f?  In that case, it's due to my bug in the
code.  Either apply the appended patch or upgrade to 0.4b.

/assar
Index: keytab_any.c
===================================================================
RCS file: /afs/pdc.kth.se/src/packages/kth-krb/SourceRepository/heimdal/lib/krb5/keytab_any.c,v
retrieving revision 1.2
retrieving revision 1.4
diff -u -w -u -w -r1.2 -r1.4
--- keytab_any.c	2001/05/14 06:14:48	1.2
+++ keytab_any.c	2001/06/24 02:22:33	1.4
@@ -33,7 +33,7 @@
 
 #include "krb5_locl.h"
 
-RCSID("$Id: keytab_any.c,v 1.2 2001/05/14 06:14:48 assar Exp $");
+RCSID("$Id: keytab_any.c,v 1.4 2001/06/24 02:22:33 assar Exp $");
 
 struct any_data {
     krb5_keytab kt;
@@ -68,7 +68,7 @@
 	}
 	if (a0 == NULL) {
 	    a0 = a;
-	    a->name = strdup(name);
+	    a->name = strdup(buf);
 	    if (a->name == NULL) {
 		krb5_set_error_string(context, "malloc: out of memory");
 		ret = ENOMEM;
@@ -139,11 +139,9 @@
     ed->a = a;
     ret = krb5_kt_start_seq_get(context, ed->a->kt, &ed->cursor);
     if (ret) {
-	free (ed);
 	free (c->data);
 	c->data = NULL;
-	krb5_set_error_string (context, "malloc: out of memory");
-	return ENOMEM;
+	return ret;
     }
     return 0;
 }
@@ -166,14 +164,15 @@
 	    ret2 = krb5_kt_end_seq_get (context, ed->a->kt, &ed->cursor);
 	    if (ret2)
 		return ret2;
-	    ed->a = ed->a->next;
+	    while ((ed->a = ed->a->next) != NULL) {
+		ret2 = krb5_kt_start_seq_get(context, ed->a->kt, &ed->cursor);
+		if (ret2 == 0)
+		    break;
+	    }
 	    if (ed->a == NULL) {
 		krb5_clear_error_string (context);
 		return KRB5_CC_END;
 	    }
-	    ret2 = krb5_kt_start_seq_get(context, ed->a->kt, &ed->cursor);
-	    if (ret2)
-		return ret2;
 	} else
 	    return ret;
     } while (ret == KRB5_CC_END);