--- debathena-moira-4.0.0+cvs20090409.orig/debian/control
+++ debathena-moira-4.0.0+cvs20090409/debian/control
@@ -0,0 +1,39 @@
+Source: debathena-moira
+Section: debathena/net
+Priority: extra
+Maintainer: Debathena Project <debathena@mit.edu>
+Build-Depends: cdbs (>= 0.4.23-1.1), autotools-dev, debhelper (>= 4.2.0), autoconf, quilt, patchutils (>= 0.2.25), cdbs (>= 0.4.27), comerr-dev, libkrb5-dev, libhesiod-dev, libzephyr-dev, libzephyr3-krb, libreadline-dev, libncurses-dev
+Standards-Version: 3.7.2
+
+Package: debathena-moira-clients
+Architecture: any
+Depends: ${shlibs:Depends}, ${misc:Depends}
+Description: Clients for the Moira database
+ Moira is the Athena Service Management system.  It serves as the 
+ central repository for information about users, groups hosts, print 
+ queues, and several other aspects of the Athena environment.
+ .
+ This package contains clients such as moira, stella, blanche, etc.
+
+Package: debathena-moira-update-server
+Architecture: any
+Depends: ${shlibs:Depends}, ${misc:Depends}
+Description: Athena update_server
+ Moira is the Athena Service Management system.  It serves as the 
+ central repository for information about users, groups hosts, print 
+ queues, and several other aspects of the Athena environment.
+ .
+ This package contains the update_server daemon, which is used for
+ servers that automatically receive information dumps from moira.
+
+Package: debathena-libmoira-dev
+Section: debathena/libdevel
+Architecture: any
+Provides: libmoira-dev
+Depends: ${shlibs:Depends}, ${misc:Depends}, comerr-dev, libkrb5-dev, libhesiod-dev, libzephyr-dev, libzephyr3-krb
+Description: Development files for Moira library
+ Moira is the Athena Service Management system.  It serves as the 
+ central repository for information about users, groups hosts, print 
+ queues, and several other aspects of the Athena environment.
+ .
+ This package contains headers and static libraries for development.
--- debathena-moira-4.0.0+cvs20090409.orig/debian/compat
+++ debathena-moira-4.0.0+cvs20090409/debian/compat
@@ -0,0 +1 @@
+4
--- debathena-moira-4.0.0+cvs20090409.orig/debian/control.in
+++ debathena-moira-4.0.0+cvs20090409/debian/control.in
@@ -0,0 +1,39 @@
+Source: debathena-moira
+Section: debathena/net
+Priority: extra
+Maintainer: Debathena Project <debathena@mit.edu>
+Build-Depends: @cdbs@, comerr-dev, libkrb5-dev, libhesiod-dev, libzephyr-dev, libzephyr3-krb, libreadline-dev, libncurses-dev
+Standards-Version: 3.7.2
+
+Package: debathena-moira-clients
+Architecture: any
+Depends: ${shlibs:Depends}, ${misc:Depends}
+Description: Clients for the Moira database
+ Moira is the Athena Service Management system.  It serves as the 
+ central repository for information about users, groups hosts, print 
+ queues, and several other aspects of the Athena environment.
+ .
+ This package contains clients such as moira, stella, blanche, etc.
+
+Package: debathena-moira-update-server
+Architecture: any
+Depends: ${shlibs:Depends}, ${misc:Depends}
+Description: Athena update_server
+ Moira is the Athena Service Management system.  It serves as the 
+ central repository for information about users, groups hosts, print 
+ queues, and several other aspects of the Athena environment.
+ .
+ This package contains the update_server daemon, which is used for
+ servers that automatically receive information dumps from moira.
+
+Package: debathena-libmoira-dev
+Section: debathena/libdevel
+Architecture: any
+Provides: libmoira-dev
+Depends: ${shlibs:Depends}, ${misc:Depends}, comerr-dev, libkrb5-dev, libhesiod-dev, libzephyr-dev, libzephyr3-krb
+Description: Development files for Moira library
+ Moira is the Athena Service Management system.  It serves as the 
+ central repository for information about users, groups hosts, print 
+ queues, and several other aspects of the Athena environment.
+ .
+ This package contains headers and static libraries for development.
--- debathena-moira-4.0.0+cvs20090409.orig/debian/changelog
+++ debathena-moira-4.0.0+cvs20090409/debian/changelog
@@ -0,0 +1,69 @@
+debathena-moira (4.0.0+cvs20090409-0debathena1) unstable; urgency=low
+
+  * New CVS snapshot (Trac: #195)
+  * Drop patches that have been incorporated upstream.
+  * Add patch to allow building on systems without krb4. (Trac: #198)
+
+ -- Evan Broder <broder@mit.edu>  Sun, 12 Apr 2009 14:03:22 -0400
+
+debathena-moira (4.0.0+cvs20080830-0debathena2) unstable; urgency=low
+
+  * Remove DEB_AUTO_UPDATE_DEBIAN_CONTROL.
+  * Change "Debian-Athena Project" to "Debathena Project".
+  * Remove debian/control from version control.
+
+ -- Tim Abbott <tabbott@mit.edu>  Sat, 24 Jan 2009 15:32:35 -0500
+
+debathena-moira (4.0.0+cvs20080830-0debathena1) unstable; urgency=low
+
+  * New CVS snapshot
+  * Add a debathena-moira-update-server package that installs
+    update_server
+
+ -- Evan Broder <broder@mit.edu>  Fri, 01 Aug 2008 10:54:26 -0400
+
+debathena-moira (4.0.0+cvs20080701-0debathena1) unstable; urgency=low
+
+  * New CVS snapshot
+  * Move Moira header files from /usr/share/include to /usr/include/moira
+
+ -- Evan Broder <broder@mit.edu>  Tue, 01 Jul 2008 20:38:13 -0400
+
+debathena-moira (4.0.0+cvs20080304-0debathena1) unstable; urgency=low
+
+  * New CVS snapshot to fix chsh.
+
+ -- Anders Kaseorg <andersk@mit.edu>  Tue, 04 Mar 2008 15:50:31 -0500
+
+debathena-moira (4.0.0+cvs20080301-0debathena1) unstable; urgency=low
+
+  * New CVS snapshot.
+  * Remove mrtest segfault patch from last release (fixed in upstream)
+
+ -- Tim Abbott <tabbott@mit.edu>  Sat,  1 Mar 2008 18:51:40 -0500
+
+debathena-moira (4.0.0+cvs20070817-0debathena1) unstable; urgency=low
+
+  * New CVS snapshot.
+  * Patch an mrtest segfault with too many command line arguments.
+
+ -- Anders Kaseorg <andersk@mit.edu>  Fri, 24 Aug 2007 19:53:49 -0400
+
+debathena-moira (4.0.0+cvs20070129-0debathena3) unstable; urgency=low
+
+  * Move chsh.debathena to chsh.moira and chfn.debathena to chfn.moira.
+
+ -- Anders Kaseorg <andersk@mit.edu>  Mon, 06 Aug 2007 03:17:10 -0400
+
+debathena-moira (4.0.0+cvs20070129-0debathena2) unstable; urgency=low
+
+  * Add missing build dependencies to libmoira-dev.
+  * Section: debathena/net.
+
+ -- Anders Kaseorg <andersk@mit.edu>  Tue, 17 Jul 2007 06:34:07 -0400
+
+debathena-moira (4.0.0+cvs20070129-0debathena1) unstable; urgency=low
+
+  * Initial release.
+
+ -- Anders Kaseorg <andersk@mit.edu>  Wed, 14 Feb 2007 00:53:24 -0500
--- debathena-moira-4.0.0+cvs20090409.orig/debian/debathena-moira-clients.install
+++ debathena-moira-4.0.0+cvs20090409/debian/debathena-moira-clients.install
@@ -0,0 +1,18 @@
+usr/bin/addusr
+usr/bin/blanche
+usr/bin/chfn.moira
+usr/bin/chpobox
+usr/bin/chsh.moira
+usr/bin/mitch
+usr/bin/namespace
+usr/bin/moira
+usr/bin/mrcheck
+usr/bin/mrtest
+usr/bin/stanley
+usr/bin/stella
+usr/bin/mailmaint
+usr/bin/listmaint
+usr/bin/dcmmaint
+usr/bin/usermaint
+usr/share/man/man1/*
+usr/share/man/man8/mrtest.8
--- debathena-moira-4.0.0+cvs20090409.orig/debian/copyright
+++ debathena-moira-4.0.0+cvs20090409/debian/copyright
@@ -0,0 +1,23 @@
+This package was debianized as part of the Debathena Project
+<http://debathena.mit.edu/> of the MIT Student Information Processing
+Board.
+
+The Moria source code was obtained from the Moira CVS repository at 
+/afs/athena.mit.edu/astaff/project/moiradev, and is licensed as follows:
+
+  Copyright © 1987-1998 by the Massachusetts Institute of Technology
+  
+  Permission to use, copy, modify, and distribute this
+  software and its documentation for any purpose and without
+  fee is hereby granted, provided that the above copyright
+  notice appear in all copies and that both that copyright
+  notice and this permission notice appear in supporting
+  documentation, and that the name of M.I.T. not be used in
+  advertising or publicity pertaining to distribution of the
+  software without specific, written prior permission.
+  M.I.T. makes no representations about the suitability of
+  this software for any purpose.  It is provided "as is"
+  without express or implied warranty.
+
+The Debian packaging is Copyright © 2007-2008 Tim Abbott and Anders
+Kaseorg, and has the same license as the original software.
--- debathena-moira-4.0.0+cvs20090409.orig/debian/rules
+++ debathena-moira-4.0.0+cvs20090409/debian/rules
@@ -0,0 +1,31 @@
+#!/usr/bin/make -f
+
+DEB_AUTO_UPDATE_AUTOCONF=2.59
+
+include /usr/share/cdbs/1/rules/debhelper.mk
+include /usr/share/cdbs/1/class/autotools.mk
+include /usr/share/cdbs/1/rules/patchsys-quilt.mk
+
+KRB5_VERSION=$(shell dpkg-query -W -f '$${Version}\n' libkrb5-dev)
+ifeq (yes,$(shell dpkg --compare-versions '$(KRB5_VERSION)' lt '1.6.dfsg.4~beta1-7' && echo yes))
+    DEB_CONFIGURE_EXTRA_FLAGS += --with-krb4=$(shell krb5-config --prefix krb4)
+else
+    DEB_CONFIGURE_EXTRA_FLAGS += --without-krb4
+endif
+
+DEB_CONFIGURE_EXTRA_FLAGS += --with-krb5 --with-hesiod --with-zephyr --with-com_err=/usr --without-oracle --without-afs
+DEB_DH_INSTALL_SOURCEDIR = $(DEB_DESTDIR)
+
+common-install-impl::
+	mv $(DEB_DESTDIR)/usr/bin/chfn $(DEB_DESTDIR)/usr/bin/chfn.moira
+	mv $(DEB_DESTDIR)/usr/bin/chsh $(DEB_DESTDIR)/usr/bin/chsh.moira
+	mv $(DEB_DESTDIR)/usr/share/man/man1/chsh.1 \
+		$(DEB_DESTDIR)/usr/share/man/man1/chsh.moira.1
+	mv $(DEB_DESTDIR)/usr/share/man/man1/chfn.1 \
+		$(DEB_DESTDIR)/usr/share/man/man1/chfn.moira.1
+	dh_install -pdebathena-libmoira-dev include/moira.h lib/mr_et.h \
+		lib/krb_et.h lib/ureg_err.h /usr/include/moira
+	dh_install -pdebathena-libmoira-dev lib/libmoira.a /usr/lib
+
+clean::
+	rm -f util/rsaref/Makefile
--- debathena-moira-4.0.0+cvs20090409.orig/debian/debathena-moira-update-server.init
+++ debathena-moira-4.0.0+cvs20090409/debian/debathena-moira-update-server.init
@@ -0,0 +1,126 @@
+#! /bin/sh
+### BEGIN INIT INFO
+# Provides:          debathena-moira-update-server
+# Required-Start:    $local_fs $remote_fs
+# Required-Stop:     $local_fs $remote_fs
+# Default-Start:     2 3 4 5
+# Default-Stop:      0 1 6
+# Short-Description: Moira update_server
+# Description:       The moira update_server program for taking updates from
+#                    moira
+### END INIT INFO
+
+# Author: Evan Broder <broder@mit.edu>
+
+# Do NOT "set -e"
+
+# PATH should only include /usr/* if it runs after the mountnfs.sh script
+PATH=/usr/sbin:/usr/bin:/sbin:/bin
+DESC="Moira update_server"
+NAME=debathena-moira-update-server
+DAEMON=/usr/sbin/update_server
+DAEMON_ARGS=""
+SCRIPTNAME=/etc/init.d/$NAME
+
+# Exit if the package is not installed
+[ -x "$DAEMON" ] || exit 0
+
+# Read configuration variable file if it is present
+[ -r /etc/default/$NAME ] && . /etc/default/$NAME
+
+# Load the VERBOSE setting and other rcS variables
+[ -f /etc/default/rcS ] && . /etc/default/rcS
+
+# Define LSB log_* functions.
+# Depend on lsb-base (>= 3.0-6) to ensure that this file is present.
+. /lib/lsb/init-functions
+
+#
+# Function that starts the daemon/service
+#
+do_start()
+{
+	# Return
+	#   0 if daemon has been started
+	#   1 if daemon was already running
+	#   2 if daemon could not be started
+	start-stop-daemon --start --quiet --exec $DAEMON --test > /dev/null \
+		|| return 1
+	start-stop-daemon --start --quiet --exec $DAEMON -- \
+		$DAEMON_ARGS \
+		|| return 2
+	# Add code here, if necessary, that waits for the process to be ready
+	# to handle requests from services started subsequently which depend
+	# on this one.  As a last resort, sleep for some time.
+}
+
+#
+# Function that stops the daemon/service
+#
+do_stop()
+{
+	# Return
+	#   0 if daemon has been stopped
+	#   1 if daemon was already stopped
+	#   2 if daemon could not be stopped
+	#   other if a failure occurred
+	start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 --name $NAME
+	RETVAL="$?"
+	[ "$RETVAL" = 2 ] && return 2
+	# Wait for children to finish too if this is a daemon that forks
+	# and if the daemon is only ever run from this initscript.
+	# If the above conditions are not satisfied then add some other code
+	# that waits for the process to drop all resources that could be
+	# needed by services started subsequently.  A last resort is to
+	# sleep for some time.
+	start-stop-daemon --stop --quiet --oknodo --retry=0/30/KILL/5 --exec $DAEMON
+	[ "$?" = 2 ] && return 2
+	return "$RETVAL"
+}
+
+case "$1" in
+  start)
+	[ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME"
+	do_start
+	case "$?" in
+		0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
+		2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
+	esac
+	;;
+  stop)
+	[ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME"
+	do_stop
+	case "$?" in
+		0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
+		2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
+	esac
+	;;
+  restart|force-reload)
+	#
+	# If the "reload" option is implemented then remove the
+	# 'force-reload' alias
+	#
+	log_daemon_msg "Restarting $DESC" "$NAME"
+	do_stop
+	case "$?" in
+	  0|1)
+		do_start
+		case "$?" in
+			0) log_end_msg 0 ;;
+			1) log_end_msg 1 ;; # Old process is still running
+			*) log_end_msg 1 ;; # Failed to start
+		esac
+		;;
+	  *)
+	  	# Failed to stop
+		log_end_msg 1
+		;;
+	esac
+	;;
+  *)
+	echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload}" >&2
+	exit 3
+	;;
+esac
+
+:
--- debathena-moira-4.0.0+cvs20090409.orig/debian/debathena-libmoira-dev.install
+++ debathena-moira-4.0.0+cvs20090409/debian/debathena-libmoira-dev.install
@@ -0,0 +1 @@
+usr/share/man/man3/*
--- debathena-moira-4.0.0+cvs20090409.orig/debian/debathena-moira-update-server.install
+++ debathena-moira-4.0.0+cvs20090409/debian/debathena-moira-update-server.install
@@ -0,0 +1,4 @@
+usr/bin/update_test
+usr/sbin/update_server
+usr/share/man/man8/update_server.8
+etc/athena/moira.conf
--- debathena-moira-4.0.0+cvs20090409.orig/debian/patches/build-without-krb4
+++ debathena-moira-4.0.0+cvs20090409/debian/patches/build-without-krb4
@@ -0,0 +1,760 @@
+Index: debathena-moira-4.0.0+cvs20090409/configure.in
+===================================================================
+--- debathena-moira-4.0.0+cvs20090409.orig/configure.in	2009-04-14 17:55:59.000000000 -0400
++++ debathena-moira-4.0.0+cvs20090409/configure.in	2009-04-14 18:14:08.000000000 -0400
+@@ -109,30 +109,34 @@
+ AC_SUBST(COM_ERR_SUBDIR)
+ AC_SUBST(COMPILE_ET)
+ 
++AC_CHECK_LIB(k5crypto, main, crypto="k5crypto",
++             [AC_CHECK_LIB(crypto, main, crypto="crypto")])
++
+ # Kerberos (Kerberos 4 required, Kerberos 5 optional for reg_svr)
+ AC_MSG_CHECKING(for Kerberos 4)
+ AC_ARG_WITH(krb4,
+     [  --with-krb4=PREFIX      Specify location of krb4],
+     [krb4="$withval"], [krb4=no])
+ AC_MSG_RESULT($krb4)
+-if test "$krb4" != yes; then
+-    MR_INCLUDE($krb4/include)
+-    if test -d "$krb4/include/kerberosIV"; then
+-	MR_INCLUDE($krb4/include/kerberosIV)
++if test "$krb4" != no; then
++    if test "$krb4" != yes; then
++	MR_INCLUDE($krb4/include)
++	if test -d "$krb4/include/kerberosIV"; then
++	    MR_INCLUDE($krb4/include/kerberosIV)
++	fi
++	MR_LIBS($krb4/lib)
++    elif test -d /usr/include/kerberosIV; then
++	MR_INCLUDE(/usr/include/kerberosIV)
+     fi
+-    MR_LIBS($krb4/lib)
+-elif test -d /usr/include/kerberosIV; then
+-    MR_INCLUDE(/usr/include/kerberosIV)
++    MR_DEFINE(HAVE_KRB4)
++    AC_CHECK_LIB(krb4, krb_rd_req,
++		 [KRB4_LIBS="-lkrb4 -ldes425 -lkrb5 -l${crypto} -lresolv"],
++		 [AC_CHECK_LIB(krb, krb_rd_req,
++			       [KRB4_LIBS="-lkrb -ldes"],
++			       [AC_MSG_ERROR(Kerberos 4 libraries not found)],
++			       $LIBPATH -ldes)],
++		 $LIBPATH -ldes425 -lkrb5 -l${crypto} -lcom_err -lresolv)
+ fi
+-AC_CHECK_LIB(k5crypto, main, crypto="k5crypto",
+-             [AC_CHECK_LIB(crypto, main, crypto="crypto")])
+-AC_CHECK_LIB(krb4, krb_rd_req,
+-	     [KRB4_LIBS="-lkrb4 -ldes425 -lkrb5 -l${crypto} -lresolv"],
+-	     [AC_CHECK_LIB(krb, krb_rd_req,
+-			   [KRB4_LIBS="-lkrb -ldes"],
+-			   [AC_MSG_ERROR(Kerberos 4 libraries not found)],
+-			   $LIBPATH -ldes)],
+-	     $LIBPATH -ldes425 -lkrb5 -l${crypto} -lcom_err -lresolv)
+ 
+ AC_MSG_CHECKING(for Kerberos 5)
+ AC_ARG_WITH(krb5,
+Index: debathena-moira-4.0.0+cvs20090409/lib/mr_et.et
+===================================================================
+--- debathena-moira-4.0.0+cvs20090409.orig/lib/mr_et.et	2009-04-14 17:55:59.000000000 -0400
++++ debathena-moira-4.0.0+cvs20090409/lib/mr_et.et	2009-04-14 18:04:03.000000000 -0400
+@@ -237,4 +237,7 @@
+ ec	MR_BAD_MAIL_STRING,
+ 	"Address refers to nonexistent domain or MIT internal mail server"
+ 
++ec	MR_NO_KRB4,
++	"Unable to complete operation using Kerberos v4"
++
+ 	end
+Index: debathena-moira-4.0.0+cvs20090409/update/auth_002.c
+===================================================================
+--- debathena-moira-4.0.0+cvs20090409.orig/update/auth_002.c	2009-04-14 17:55:59.000000000 -0400
++++ debathena-moira-4.0.0+cvs20090409/update/auth_002.c	2009-04-14 18:04:03.000000000 -0400
+@@ -15,14 +15,18 @@
+ #include <stdio.h>
+ #include <string.h>
+ 
++#ifdef HAVE_KRB4
+ #include <krb.h>
++#endif
+ 
+ RCSID("$Header: /afs/athena.mit.edu/astaff/project/moiradev/repository/moira/update/auth_002.c,v 1.9 1998-10-21 19:27:29 danw Exp $");
+ 
+ static char service[] = "rcmd";
+ static char master[] = "sms";
+ static char qmark[] = "???";
++#ifdef HAVE_KRB4
+ extern des_cblock session;
++#endif
+ 
+ /*
+  * authentication request auth_002:
+@@ -39,6 +43,7 @@
+ 
+ void auth_002(int conn, char *str)
+ {
++#ifdef HAVE_KRB4
+   char aname[ANAME_SZ], ainst[INST_SZ], arealm[REALM_SZ];
+   AUTH_DAT ad;
+   char *p, *first, *data;
+@@ -126,4 +131,7 @@
+   com_err(whoami, code, "auth for %s.%s@%s failed",
+ 	  ad.pname, ad.pinst, ad.prealm);
+   send_int(conn, code);
++#else
++  return MR_NO_KRB4;
++#endif
+ }
+Index: debathena-moira-4.0.0+cvs20090409/update/client.c
+===================================================================
+--- debathena-moira-4.0.0+cvs20090409.orig/update/client.c	2009-04-14 17:55:59.000000000 -0400
++++ debathena-moira-4.0.0+cvs20090409/update/client.c	2009-04-14 18:04:03.000000000 -0400
+@@ -17,13 +17,17 @@
+ #include <stdlib.h>
+ #include <string.h>
+ 
++#ifdef HAVE_KRB4
+ #include <des.h>
+ #include <krb.h>
++#endif
+ #include <krb5.h>
+ 
+ RCSID("$Header: /afs/athena.mit.edu/astaff/project/moiradev/repository/moira/update/client.c,v 1.27 2006-08-22 17:36:26 zacheiss Exp $");
+ 
++#ifdef HAVE_KRB4
+ extern des_cblock session;
++#endif
+ extern char *whoami;
+ extern krb5_context context;
+ 
+@@ -71,6 +75,7 @@
+ 
+ int mr_send_auth(int conn, char *host_name)
+ {
++#ifdef HAVE_KRB4
+   KTEXT_ST ticket_st;
+   int code, auth_version = 2;
+   long response;
+@@ -129,6 +134,9 @@
+     }
+ 
+   return MR_SUCCESS;
++#else
++  return MR_NO_KRB4;
++#endif
+ }
+ 
+ int mr_execute(int conn, char *path)
+Index: debathena-moira-4.0.0+cvs20090409/update/ticket.c
+===================================================================
+--- debathena-moira-4.0.0+cvs20090409.orig/update/ticket.c	2009-04-14 17:55:59.000000000 -0400
++++ debathena-moira-4.0.0+cvs20090409/update/ticket.c	2009-04-14 18:04:03.000000000 -0400
+@@ -13,19 +13,27 @@
+ #include <stdio.h>
+ #include <string.h>
+ 
++#ifdef HAVE_KRB4
+ #include <krb.h>
++#else
++#define KTEXT void*
++#endif
+ #include <krb5.h>
+ #include <update.h>
+ 
+ RCSID("$Header: /afs/athena.mit.edu/astaff/project/moiradev/repository/moira/update/ticket.c,v 1.23 2007-07-25 15:39:01 zacheiss Exp $");
+ 
++#ifdef HAVE_KRB4
+ static char realm[REALM_SZ];
+ static char master[INST_SZ] = "sms";
+ static char service[ANAME_SZ] = "rcmd";
+ des_cblock session;
++#endif
+ krb5_context context = NULL;
+ 
++#ifdef HAVE_KRB4
+ static int get_mr_tgt(void);
++#endif
+ 
+ int get_mr_krb5_update_ticket(char *host, krb5_data auth)
+ {
+@@ -58,6 +66,7 @@
+ 
+ int get_mr_update_ticket(char *host, KTEXT ticket)
+ {
++#ifdef HAVE_KRB4
+   int code, pass;
+   char phost[BUFSIZ];
+   CREDENTIALS cr;
+@@ -93,8 +102,12 @@
+       memcpy(session, cr.session, sizeof(session));
+     }
+   return code;
++#else
++  return MR_NO_KRB4;
++#endif
+ }
+ 
++#ifdef HAVE_KRB4
+ static int get_mr_tgt(void)
+ {
+   int code;
+@@ -109,3 +122,4 @@
+   else
+     return code + ERROR_TABLE_BASE_krb;
+ }
++#endif
+Index: debathena-moira-4.0.0+cvs20090409/include/update.h
+===================================================================
+--- debathena-moira-4.0.0+cvs20090409.orig/include/update.h	2009-04-14 17:55:59.000000000 -0400
++++ debathena-moira-4.0.0+cvs20090409/include/update.h	2009-04-14 18:04:03.000000000 -0400
+@@ -15,7 +15,4 @@
+ int mr_execute(int conn, char *path);
+ void mr_send_quit(int conn);
+ 
+-#include <krb.h>
+-int get_mr_update_ticket(char *host, KTEXT ticket);
+-
+ extern char *whoami;
+Index: debathena-moira-4.0.0+cvs20090409/clients/lib/utils.c
+===================================================================
+--- debathena-moira-4.0.0+cvs20090409.orig/clients/lib/utils.c	2009-04-14 17:55:59.000000000 -0400
++++ debathena-moira-4.0.0+cvs20090409/clients/lib/utils.c	2009-04-14 18:04:03.000000000 -0400
+@@ -12,7 +12,6 @@
+ #include <mrclient.h>
+ 
+ #include <com_err.h>
+-#include <krb.h>
+ #include <krb5.h>
+ 
+ #include <sys/types.h>
+Index: debathena-moira-4.0.0+cvs20090409/clients/lib/member.c
+===================================================================
+--- debathena-moira-4.0.0+cvs20090409.orig/clients/lib/member.c	2009-04-14 17:55:59.000000000 -0400
++++ debathena-moira-4.0.0+cvs20090409/clients/lib/member.c	2009-04-14 18:04:03.000000000 -0400
+@@ -17,12 +17,10 @@
+ #include <string.h>
+ #include <ctype.h>
+ 
+-#include <krb.h>
++#include <krb5.h>
+ 
+ RCSID("$Header: /afs/athena.mit.edu/astaff/project/moiradev/repository/moira/clients/lib/member.c,v 1.5 2002-09-25 20:44:54 zacheiss Exp $");
+ 
+-static char default_realm[REALM_SZ];
+-
+ int mrcl_validate_string_member(char *str)
+ {
+   char *p, *lname, *ret;
+@@ -69,6 +67,9 @@
+ int mrcl_validate_kerberos_member(char *str, char **ret)
+ {
+   char *p;
++  int code = 0;
++  krb5_context context = NULL;
++  char *default_realm = NULL;
+ 
+   mrcl_clear_message();
+ 
+@@ -97,14 +98,27 @@
+ 	  return MRCL_SUCCESS;
+ 	}
+ 
+-      if (!*default_realm)
+-	krb_get_lrealm(default_realm, 1);
++      code = krb5_init_context(&context);
++      if (!code)
++        goto out;
++
++      code = krb5_get_default_realm(context, &default_realm);
++      if (!code)
++        goto out;
+ 
+       *ret = malloc(strlen(str) + strlen(default_realm) + 2);
+       sprintf(*ret, "%s@%s", str, default_realm);
+ 
+       mrcl_set_message("Warning: default realm \"%s\" added to principal "
+ 		       "\"%s\"", default_realm, str);
++
++    out:
++      if (default_realm)
++        free(default_realm);
++      if (context)
++        krb5_free_context(context);
++      if (!code)
++        return code;
+       return MRCL_SUCCESS;
+     }
+ 
+Index: debathena-moira-4.0.0+cvs20090409/lib/mr_auth.c
+===================================================================
+--- debathena-moira-4.0.0+cvs20090409.orig/lib/mr_auth.c	2009-04-14 17:55:59.000000000 -0400
++++ debathena-moira-4.0.0+cvs20090409/lib/mr_auth.c	2009-04-14 18:04:03.000000000 -0400
+@@ -15,7 +15,9 @@
+ #include <stdio.h>
+ #include <string.h>
+ 
++#ifdef HAVE_KRB4
+ #include <krb.h>
++#endif
+ #include <krb5.h>
+ 
+ krb5_context context = NULL;
+@@ -29,6 +31,7 @@
+ 
+ int mr_auth(char *prog)
+ {
++#ifdef HAVE_KRB4
+   int status;
+   mr_params params, reply;
+   char *args[2];
+@@ -70,6 +73,9 @@
+   mr_destroy_reply(reply);
+ 
+   return status;
++#else
++  return MR_NO_KRB4;
++#endif
+ }
+ 
+ int mr_proxy(char *principal, char *orig_authtype)
+Index: debathena-moira-4.0.0+cvs20090409/clients/moira/namespace.c
+===================================================================
+--- debathena-moira-4.0.0+cvs20090409.orig/clients/moira/namespace.c	2009-04-14 17:55:59.000000000 -0400
++++ debathena-moira-4.0.0+cvs20090409/clients/moira/namespace.c	2009-04-14 18:04:03.000000000 -0400
+@@ -23,8 +23,6 @@
+ #include <stdio.h>
+ #include <string.h>
+ 
+-#include <krb.h>
+-
+ RCSID("$Header: /afs/athena.mit.edu/astaff/project/moiradev/repository/moira/clients/moira/namespace.c,v 1.16 2006-08-23 19:02:27 zacheiss Exp $");
+ 
+ static void ErrorExit(char *buf, int status);
+@@ -176,7 +174,6 @@
+   int status;
+   Menu *menu;
+   char *motd, **arg;
+-  char pname[ANAME_SZ];
+   struct sigaction act;
+ 
+   if (!(program_name = strrchr(argv[0], '/')))
+Index: debathena-moira-4.0.0+cvs20090409/update/get_file.c
+===================================================================
+--- debathena-moira-4.0.0+cvs20090409.orig/update/get_file.c	2009-04-14 17:55:59.000000000 -0400
++++ debathena-moira-4.0.0+cvs20090409/update/get_file.c	2009-04-14 18:04:03.000000000 -0400
+@@ -17,7 +17,9 @@
+ #include <string.h>
+ #include <unistd.h>
+ 
++#ifdef HAVE_KRB4
+ #include <des.h>
++#endif
+ 
+ RCSID("$Header: /afs/athena.mit.edu/astaff/project/moiradev/repository/moira/update/get_file.c,v 1.20 2007-07-11 16:06:31 zacheiss Exp $");
+ 
+@@ -25,9 +27,11 @@
+ #define MIN(a, b)    (((a) < (b)) ? (a) : (b))
+ #endif /* MIN */
+ 
++#ifdef HAVE_KRB4
+ static des_key_schedule sched;
+ static des_cblock ivec;
+ extern des_cblock session;
++#endif
+ 
+ static int get_block(int conn, int fd, int max_size, int encrypt);
+ 
+@@ -123,8 +127,15 @@
+ 
+   if (encrypt)
+     {
++#ifdef HAVE_KRB4
+       des_key_sched(session, sched);
+       memcpy(ivec, session, sizeof(ivec));
++#else
++      /* The session key only gets stored if auth happens in krb4 to
++         begin with. If you don't have krb4, you can't possibly be
++         coming up with a valid session key. */
++      return MR_NO_KRB4;
++#endif
+     }
+ 
+   n_written = 0;
+@@ -173,6 +184,7 @@
+ 
+   if (encrypt)
+     {
++#ifdef HAVE_KRB4
+       char *unenc = malloc(len);
+ 
+       if (!unenc)
+@@ -186,6 +198,7 @@
+ 	ivec[i] = data[len - 8 + i] ^ unenc[len - 8 + i];
+       free(data);
+       data = unenc;
++#endif
+     }
+ 
+   n_read = MIN(len, max_size);
+Index: debathena-moira-4.0.0+cvs20090409/update/send_file.c
+===================================================================
+--- debathena-moira-4.0.0+cvs20090409.orig/update/send_file.c	2009-04-14 17:55:59.000000000 -0400
++++ debathena-moira-4.0.0+cvs20090409/update/send_file.c	2009-04-14 18:04:03.000000000 -0400
+@@ -17,12 +17,16 @@
+ #include <string.h>
+ #include <unistd.h>
+ 
++#ifdef HAVE_KRB4
+ #include <des.h>
++#endif
+ #include <update.h>
+ 
+ RCSID("$Header: /afs/athena.mit.edu/astaff/project/moiradev/repository/moira/update/send_file.c,v 1.16 2001-09-04 19:46:21 zacheiss Exp $");
+ 
++#ifdef HAVE_KRB4
+ extern des_cblock session;
++#endif
+ 
+ /*
+  * syntax:
+@@ -47,8 +51,10 @@
+   char data[UPDATE_BUFSIZ], enc[UPDATE_BUFSIZ];
+   long response;
+   struct stat statb;
++#ifdef HAVE_KRB4
+   des_key_schedule sched;
+   des_cblock ivec;
++#endif
+ 
+   /* send file over */
+   fd = open(pathname, O_RDONLY, 0);
+@@ -105,8 +111,15 @@
+ 
+   if (encrypt)
+     {
++#ifdef HAVE_KRB4
+       des_key_sched(session, sched);
+       memmove(ivec, session, sizeof(ivec));
++#else
++      /* The session key only gets stored if auth happens in krb4 to
++         begin with. If you don't have krb4, you can't possibly be
++         coming up with a valid session key. */
++      return MR_NO_KRB4;
++#endif
+     }
+ 
+   while (n_to_send > 0)
+@@ -120,6 +133,7 @@
+ 	}
+       if (encrypt)
+ 	{
++#ifdef HAVE_KRB4
+ 	  memset(data + n, 0, sizeof(data) -n);
+ 	  des_pcbc_encrypt(data, enc, (n + 7) & ~7, sched, ivec, 0);
+ 	  /* save vector to continue chaining */
+@@ -128,6 +142,7 @@
+ 	  /* round up to multiple of 8 */
+ 	  n = (n + 7) & ~7;
+ 	  code = send_string(conn, enc, n);
++#endif
+ 	}
+       else
+ 	code = send_string(conn, data, n);
+Index: debathena-moira-4.0.0+cvs20090409/update/update_server.c
+===================================================================
+--- debathena-moira-4.0.0+cvs20090409.orig/update/update_server.c	2009-04-14 17:55:59.000000000 -0400
++++ debathena-moira-4.0.0+cvs20090409/update/update_server.c	2009-04-14 18:04:03.000000000 -0400
+@@ -25,7 +25,9 @@
+ #include <unistd.h>
+ #include <syslog.h>
+ 
++#ifdef HAVE_KRB4
+ #include <des.h>
++#endif
+ #include "update.h"
+ 
+ RCSID("$Header: /afs/athena.mit.edu/astaff/project/moiradev/repository/moira/update/update_server.c,v 1.26 2006-08-22 17:36:26 zacheiss Exp $");
+@@ -33,7 +35,9 @@
+ char *whoami, *hostname;
+ 
+ int have_authorization = 0;
++#ifdef HAVE_KRB4
+ des_cblock session;
++#endif
+ int uid = 0;
+ 
+ void child_handler(int signal);
+@@ -44,7 +48,9 @@
+   char *str;
+   void (*proc)(int, char *);
+ } dispatch_table[] = {
++#ifdef HAVE_KRB4
+   { "AUTH_002", auth_002 },
++#endif
+   { "AUTH_003", auth_003 },
+   { "XFER_002", xfer_002 },
+   { "XFER_003", xfer_003 },
+Index: debathena-moira-4.0.0+cvs20090409/clients/mailmaint/mailmaint.c
+===================================================================
+--- debathena-moira-4.0.0+cvs20090409.orig/clients/mailmaint/mailmaint.c	2009-04-14 17:55:59.000000000 -0400
++++ debathena-moira-4.0.0+cvs20090409/clients/mailmaint/mailmaint.c	2009-04-14 18:04:03.000000000 -0400
+@@ -31,8 +31,6 @@
+ #include <unistd.h>
+ #endif
+ 
+-#include <krb.h>
+-
+ #ifdef _WIN32
+ #define INPUT_MASK 0xff
+ #ifdef getchar
+Index: debathena-moira-4.0.0+cvs20090409/update/auth_003.c
+===================================================================
+--- debathena-moira-4.0.0+cvs20090409.orig/update/auth_003.c	2009-04-14 17:55:59.000000000 -0400
++++ debathena-moira-4.0.0+cvs20090409/update/auth_003.c	2009-04-14 18:04:03.000000000 -0400
+@@ -15,7 +15,11 @@
+ #include <stdio.h>
+ #include <string.h>
+ 
++#ifdef HAVE_KRB4
+ #include <krb.h>
++#else
++#include <mr_krb.h>
++#endif
+ #include <krb5.h>
+ 
+ RCSID("$Header: /afs/athena.mit.edu/astaff/project/moiradev/repository/moira/update/auth_003.c,v 1.2 2006-08-22 17:36:26 zacheiss Exp $");
+@@ -44,6 +48,7 @@
+   char *p, *first, *data;
+   char name[ANAME_SZ], inst[INST_SZ], realm[REALM_SZ];
+   char aname[ANAME_SZ], ainst[INST_SZ], arealm[REALM_SZ];
++  char *lrealm = NULL;
+   size_t size;
+   long code;
+   struct utsname uts;
+@@ -143,7 +148,11 @@
+     {
+       strcpy(aname, master);
+       strcpy(ainst, "");
+-      if (krb_get_lrealm(arealm, 1))
++      if (!krb5_get_default_realm(context, &lrealm))
++        {
++          strcpy(arealm, lrealm);
++        }
++      else
+ 	strcpy(arealm, KRB_REALM);
+     }
+   code = EPERM;
+@@ -159,6 +168,8 @@
+   have_authorization = 1;
+ 
+  out:
++  if (lrealm)
++    free(lrealm);
+   if (client)
+     krb5_free_principal(context, client);
+   if (server)
+Index: debathena-moira-4.0.0+cvs20090409/include/moira.h
+===================================================================
+--- debathena-moira-4.0.0+cvs20090409.orig/include/moira.h	2009-04-14 17:55:59.000000000 -0400
++++ debathena-moira-4.0.0+cvs20090409/include/moira.h	2009-04-14 18:04:03.000000000 -0400
+@@ -115,6 +115,9 @@
+ /* prototypes from kname_unparse.c */
+ char *mr_kname_unparse(char *p, char *i, char *r);
+ 
++/* prototypes from kname_parse.c */
++int mr_kname_parse(char *np, char *ip, char *rp, char *fullname);
++
+ /* prototypes from nfsparttype.c */
+ char *parse_filesys_type(char *fs_type_name);
+ char *format_filesys_type(char *fs_status);
+Index: debathena-moira-4.0.0+cvs20090409/include/mr_krb.h
+===================================================================
+--- /dev/null	1970-01-01 00:00:00.000000000 +0000
++++ debathena-moira-4.0.0+cvs20090409/include/mr_krb.h	2009-04-14 18:04:03.000000000 -0400
+@@ -0,0 +1,20 @@
++/* $Id$
++ *
++ * Copyright (C) 2009 by the Massachusetts Institute of Technology
++ *
++ * Define some useful constants that used to be provided by the krb4
++ * libraries.
++ *
++ */
++
++#define ANAME_SZ      40
++#define INST_SZ       40
++#define REALM_SZ      40
++/* include space for '.' and '@' */
++#define MAX_K_NAME_SZ (ANAME_SZ + INST_SZ + REALM_SZ + 2)
++
++#define KRB_REALM "ATHENA.MIT.EDU"
++
++#define kname_parse mr_kname_parse
++
++#define ERROR_TABLE_BASE_krb                     (39525376L)
+Index: debathena-moira-4.0.0+cvs20090409/lib/Makefile.in
+===================================================================
+--- debathena-moira-4.0.0+cvs20090409.orig/lib/Makefile.in	2009-04-14 17:55:59.000000000 -0400
++++ debathena-moira-4.0.0+cvs20090409/lib/Makefile.in	2009-04-14 18:04:03.000000000 -0400
+@@ -16,7 +16,7 @@
+ BUILDTOP=..
+ 
+ OBJS=	critical.o fixhost.o fixname.o \
+-	hash.o kname_unparse.o krb_et.o mr_access.o mr_auth.o \
++	hash.o kname_unparse.o kname_parse.o krb_et.o mr_access.o mr_auth.o \
+ 	mr_call.o mr_connect.o mr_et.o mr_init.o mr_ops.o mr_query.o \
+ 	nfsparttype.o sq.o strs.o ureg_err.o
+ 
+Index: debathena-moira-4.0.0+cvs20090409/lib/kname_parse.c
+===================================================================
+--- /dev/null	1970-01-01 00:00:00.000000000 +0000
++++ debathena-moira-4.0.0+cvs20090409/lib/kname_parse.c	2009-04-14 18:04:03.000000000 -0400
+@@ -0,0 +1,119 @@
++/* $Id$
++ *
++ * Provide a copy of kname_parse() from krb4 for when krb4 is no
++ * longer available.
++ *
++ * Copyright (C) 2009 by the Massachusetts Institute of Technology
++ * For copying and distribution information, please see the file
++ * <mit-copyright.h>.
++ */
++
++#include <mit-copyright.h>
++#include <moira.h>
++
++#include <string.h>
++
++#ifdef HAVE_KRB4
++#include <krb.h>
++#else
++#include <mr_krb.h>
++
++#define KRBET_KNAME_FMT                          (39525457L)
++#define KNAME_FMT                                (KRBET_KNAME_FMT - ERROR_TABLE_BASE_krb)
++#endif
++
++RCSID("$Header: /afs/athena.mit.edu/astaff/project/moiradev/repository/moira/lib/kname_parse.c,v 1.0 2009-04-14 00:00:00 broder Exp $");
++
++#define NAME    0               /* which field are we in? */
++#define INST    1
++#define REALM   2
++
++int mr_kname_parse(char *np, char *ip, char *rp, char *fullname)
++{
++  char buf[MAX_K_NAME_SZ];
++  char *rnext, *wnext;        /* next char to read, write */
++  register char c;
++  int backslash;
++  int field;
++
++  backslash = 0;
++  rnext = buf;
++  wnext = np;
++  field = NAME;
++
++  if (strlen(fullname) > MAX_K_NAME_SZ)
++    return KNAME_FMT;
++  (void) strcpy(buf, fullname);
++
++  while ((c = *rnext++)) {
++    if (backslash) {
++      *wnext++ = c;
++      backslash = 0;
++      continue;
++    }
++    switch (c) {
++    case '\\':
++      backslash++;
++      break;
++    case '.':
++      switch (field) {
++      case NAME:
++        if (wnext == np)
++          return KNAME_FMT;
++        *wnext = '\0';
++        field = INST;
++        wnext = ip;
++        break;
++      case INST:          /* We now allow period in instance */
++      case REALM:
++        *wnext++ = c;
++        break;
++      default:
++        return KNAME_FMT;
++      }
++      break;
++    case '@':
++      switch (field) {
++      case NAME:
++        if (wnext == np)
++          return KNAME_FMT;
++        *ip = '\0';
++        /* fall through */
++      case INST:
++        *wnext = '\0';
++        field = REALM;
++        wnext = rp;
++        break;
++      case REALM:
++        return KNAME_FMT;
++      default:
++        return KNAME_FMT;
++      }
++      break;
++    default:
++      *wnext++ = c;
++    }
++    /*
++     * Paranoia: check length each time through to ensure that we
++     * don't overwrite things.
++     */
++    switch (field) {
++    case NAME:
++      if (wnext - np >= ANAME_SZ)
++        return KNAME_FMT;
++      break;
++    case INST:
++      if (wnext - ip >= INST_SZ)
++        return KNAME_FMT;
++      break;
++    case REALM:
++      if (wnext - rp >= REALM_SZ)
++        return KNAME_FMT;
++      break;
++    default:
++      return KNAME_FMT;
++    }
++  }
++  *wnext = '\0';
++  return 0;
++}
+Index: debathena-moira-4.0.0+cvs20090409/lib/kname_unparse.c
+===================================================================
+--- debathena-moira-4.0.0+cvs20090409.orig/lib/kname_unparse.c	2009-04-14 17:55:59.000000000 -0400
++++ debathena-moira-4.0.0+cvs20090409/lib/kname_unparse.c	2009-04-14 18:04:03.000000000 -0400
+@@ -13,8 +13,11 @@
+ 
+ #include <stdio.h>
+ 
+-#include <des.h>
++#ifdef HAVE_KRB5
+ #include <krb.h>
++#else
++#include <mr_krb.h>
++#endif
+ 
+ RCSID("$Header: /afs/athena.mit.edu/astaff/project/moiradev/repository/moira/lib/kname_unparse.c,v 1.5 2004-07-20 06:47:46 zacheiss Exp $");
+ 
+Index: debathena-moira-4.0.0+cvs20090409/clients/moira/user.c
+===================================================================
+--- debathena-moira-4.0.0+cvs20090409.orig/clients/moira/user.c	2009-04-14 17:55:59.000000000 -0400
++++ debathena-moira-4.0.0+cvs20090409/clients/moira/user.c	2009-04-14 18:04:03.000000000 -0400
+@@ -25,8 +25,6 @@
+ #include <string.h>
+ #include <time.h>
+ 
+-#include <krb.h>
+-
+ RCSID("$Header: /afs/athena.mit.edu/astaff/project/moiradev/repository/moira/clients/moira/user.c,v 1.74 2009-03-31 19:13:09 zacheiss Exp $");
+ 
+ void CorrectCapitalization(char **name);
--- debathena-moira-4.0.0+cvs20090409.orig/debian/patches/series
+++ debathena-moira-4.0.0+cvs20090409/debian/patches/series
@@ -0,0 +1 @@
+build-without-krb4
