[24214] in Source-Commits
/svn/athena r23815 - in trunk/athena/bin/discuss: debian ets libds mclient
daemon@ATHENA.MIT.EDU (Evan Broder)
Mon May 18 23:50:19 2009
Date: Mon, 18 May 2009 23:50:09 -0400
From: Evan Broder <broder@MIT.EDU>
Message-Id: <200905190350.n4J3o9kC007588@drugstore.mit.edu>
To: source-commits@mit.edu
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Author: broder
Date: 2009-05-18 23:50:09 -0400 (Mon, 18 May 2009)
New Revision: 23815
Modified:
trunk/athena/bin/discuss/debian/changelog
trunk/athena/bin/discuss/ets/discuss_err.et
trunk/athena/bin/discuss/libds/auth_krb.c
trunk/athena/bin/discuss/libds/res_module.c
trunk/athena/bin/discuss/libds/rpcall.c
trunk/athena/bin/discuss/mclient/Makefile.in
Log:
In discuss:
* Assorted changes to make discuss work with any combination of krb4 and
krb5 (including neither).
Modified: trunk/athena/bin/discuss/debian/changelog
===================================================================
--- trunk/athena/bin/discuss/debian/changelog 2009-05-19 02:06:26 UTC (rev 23814)
+++ trunk/athena/bin/discuss/debian/changelog 2009-05-19 03:50:09 UTC (rev 23815)
@@ -4,8 +4,10 @@
* Squash some lintian warnings by switching from ${Source-Version} to
${source:Version} and ${binary:Version}
* Use HAVE_KRB4 and HAVE_KRB5 instead of KERBEROS and KERBEROS5.
+ * Assorted changes to make discuss work with any combination of krb4 and
+ krb5 (including neither).
- -- Evan Broder <broder@mit.edu> Mon, 18 May 2009 18:48:39 -0400
+ -- Evan Broder <broder@mit.edu> Mon, 18 May 2009 23:50:01 -0400
debathena-discuss (10.0.7-0debathena3) unstable; urgency=low
Modified: trunk/athena/bin/discuss/ets/discuss_err.et
===================================================================
--- trunk/athena/bin/discuss/ets/discuss_err.et 2009-05-19 02:06:26 UTC (rev 23814)
+++ trunk/athena/bin/discuss/ets/discuss_err.et 2009-05-19 03:50:09 UTC (rev 23815)
@@ -32,7 +32,7 @@
ec DISC_ACTION_NOT_PERFORMED,
"Action not performed"
- ec DISC_NO_KRB
+ ec DISC_NO_KRB,
"No Kerberos support built in"
end
Modified: trunk/athena/bin/discuss/libds/auth_krb.c
===================================================================
--- trunk/athena/bin/discuss/libds/auth_krb.c 2009-05-19 02:06:26 UTC (rev 23814)
+++ trunk/athena/bin/discuss/libds/auth_krb.c 2009-05-19 03:50:09 UTC (rev 23815)
@@ -28,6 +28,7 @@
#ifdef HAVE_KRB5
#include "krb5.h"
#endif /* HAVE_KRB5 */
+#include "discuss_err.h"
char *local_host_name ();
@@ -52,8 +53,9 @@
#elif HAVE_KRB4
get_authenticator_krb4(service_id, checksum, authp, authl, result);
#else /* No Kerberos */
- printf("get_authenticator", DISC_NO_KRB, "while initializing authentication");
- exit(1);
+ *authl = 0;
+ *authp = NULL;
+ *result = DISC_NO_KRB;
#endif
}
Modified: trunk/athena/bin/discuss/libds/res_module.c
===================================================================
--- trunk/athena/bin/discuss/libds/res_module.c 2009-05-19 02:06:26 UTC (rev 23814)
+++ trunk/athena/bin/discuss/libds/res_module.c 2009-05-19 03:50:09 UTC (rev 23815)
@@ -34,18 +34,21 @@
#include <ctype.h>
#ifdef HAVE_KRB4
-#include "krb.h"
+#include <krb.h>
#ifndef MAX_K_NAME_SZ
/* @#$%^$ last minute changes by jtkohl */
#define krb_get_lrealm get_krbrlm
#endif
-static void ExpandHost ();
#endif /* HAVE_KRB4 */
#ifdef HAVE_KRB5
-#include "krb5.h"
+#include <krb5.h>
#endif /* HAVE_KRB5 */
+#if defined(HAVE_KRB5) || defined(HAVE_KRB4)
+static void ExpandHost ();
+#endif /* HAVE_KRB5 || HAVE_KRB4 */
+
#ifndef SNAME_SZ
#define SNAME_SZ 30
#define REALM_SZ 30
@@ -228,34 +231,29 @@
/* generate the service name, but concatenating "discuss.instance@realm"
* desired realm. */
-#ifndef HAVE_KRB4
- strcpy (service_id, "discuss@");
- strcpy (&service_id[8], REALM);
+ strcpy (service_id, "discuss");
+#if defined(HAVE_KRB5) || defined(HAVE_KRB4)
+#ifdef HAVE_KRB5
+ strcat (service_id, "/");
#else
-#ifndef HAVE_KRB5
- strcpy (service_id, "discuss.");
+ strcat (service_id, ".");
+#endif
ExpandHost (myhnamep, &service_id[8], realm);
strcat(service_id, "@");
if (realmp)
- strcat (service_id, realmp);
- else
- strcat (service_id, realm);
-#else
- strcpy (service_id, "discuss/");
- ExpandHost (myhnamep, &service_id[8], realm);
- strcat(service_id, "@");
- if (realmp)
strcat (service_id, realmp);
else
strcat (service_id, realm);
-#endif /* HAVE_KRB5 */
-#endif /* HAVE_KRB4 */
+#else /* HAVE_KRB5 || HAVE_KRB4 */
+ strcat (service_id, "@");
+ strcpy (&service_id[8], REALM);
+#endif /* HAVE_KRB5 || HAVE_KRB4 */
*hostp = myhnamep;
*servp = service_id;
*result = 0;
}
-#ifdef HAVE_KRB4
+#if defined(HAVE_KRB4) || defined(HAVE_KRB5)
/*
*
* ExpandHost -- takes a user string alias for a host, and converts it
@@ -284,7 +282,26 @@
* could give the command "menel echo foo" and we will resolve
* it to "menelaus".
*/
+#ifdef HAVE_KRB5
+ krb5_context context;
+ char **hrealms = 0;
+ krb5_error_code retval;
+
+ retval = krb5_init_context(&context);
+ if (!retval)
+ krb5_get_host_realm(context, primary_name, &hrealms);
+ if (!retval && !hrealms[0])
+ strcpy(krb_realm, hrealms[0]);
+ if (retval)
+ strcpy(krb_realm, local_realm());
+
+ if (hrealms)
+ krb5_free_host_realm(context, hrealms);
+ if (context)
+ krb5_free_context(context);
+#else /* HAVE_KRB5 */
(void) strcpy(krb_realm, (char *)krb_realmofhost(primary_name));
+#endif
/* lower case Kerberos host name */
do {
if (isupper(*sp)) *dp=tolower(*sp);
@@ -306,7 +323,7 @@
#endif
return;
}
-#endif
+#endif /* HAVE_KRB4 || HAVE_KRB5 */
const char *local_realm ()
{
@@ -317,6 +334,17 @@
krb_get_lrealm (realm, 1);
return (realm);
+#elif defined(HAVE_KRB5)
+ krb5_context context;
+ static char *realm = NULL;
+
+ if (!realm) {
+ krb5_init_context(&context);
+ krb5_get_default_realm(context, &realm);
+ krb5_free_context(context);
+ }
+
+ return realm;
#else /* HAVE_KRB4 */
return (REALM);
#endif /* HAVE_KRB4 */
Modified: trunk/athena/bin/discuss/libds/rpcall.c
===================================================================
--- trunk/athena/bin/discuss/libds/rpcall.c 2009-05-19 02:06:26 UTC (rev 23814)
+++ trunk/athena/bin/discuss/libds/rpcall.c 2009-05-19 03:50:09 UTC (rev 23815)
@@ -386,6 +386,7 @@
sendshort(*authp++);
}
USP_end_block(us);
+#ifdef HAVE_KRB5
/* Prior to server version 3, Kerberos 5 wasn't an available
* authentication method, so we need to send a Kerberos 4 ticket.
* Unfortunately, there's no way to query the server version sooner. */
@@ -396,7 +397,7 @@
char realm[30];
krb5_context context;
if (get_server_version() < SERVER_3) {
-#if defined(HAVE_KRB5) && defined(HAVE_KRB4)
+#ifdef HAVE_KRB4
kcode = krb5_init_context(&context);
if (kcode) {
com_err("discuss", kcode, "while initializing krb5");
@@ -428,10 +429,11 @@
}
USP_end_block(us);
}
-#else /* HAVE_KRB5 && HAVE_KRB4 */
+#else /* HAVE_KRB4 */
com_err("discuss", RPC_SERVER_TOO_OLD, "while authenticating to discuss server");
-#endif /* HAVE_KRB5 && HAVE_KRB4 */
+#endif /* HAVE_KRB4 */
}
+#endif /* HAVE_KRB5 */
} else {
USP_begin_block(us,KRB_TICKET); /* send blank ticket */
sendshort(0);
Modified: trunk/athena/bin/discuss/mclient/Makefile.in
===================================================================
--- trunk/athena/bin/discuss/mclient/Makefile.in 2009-05-19 02:06:26 UTC (rev 23814)
+++ trunk/athena/bin/discuss/mclient/Makefile.in 2009-05-19 03:50:09 UTC (rev 23815)
@@ -61,7 +61,7 @@
${CC} ${LDFLAGS} -o pmtg pmtg.o ../ets/dsc_et.o ${KLIBS}
dsmail: dsmail.o ../ets/dsc_et.o
- ${CC} ${LDFLAGS} -o dsmail dsmail.o ../ets/dsc_et.o ${NKLIBS}
+ ${CC} ${LDFLAGS} -o dsmail dsmail.o ../ets/dsc_et.o ${KLIBS}
dspipe: dspipe.o ../ets/dsc_et.o
${CC} ${LDFLAGS} -o dspipe dspipe.o ../ets/dsc_et.o ${KLIBS}