[5419] in Moira
Building Moira without krb4
daemon@ATHENA.MIT.EDU (Evan Broder)
Wed Apr 15 15:37:49 2009
Message-ID: <49E6377B.3000304@mit.edu>
Date: Wed, 15 Apr 2009 15:37:31 -0400
From: Evan Broder <broder@MIT.EDU>
MIME-Version: 1.0
To: moiradev@mit.edu
Content-Type: multipart/mixed;
boundary="------------070207060000090709010709"
This is a multi-part message in MIME format.
--------------070207060000090709010709
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
Debathena recently discovered that Moira can not currently build without
the krb4 libraries available. Debian Squeeze (the current testing
release) recently removed the krb4 build environment in anticipation of
the krb5 1.7 release, which will not include krb4 at all. Once Ubuntu
Jaunty releases, Ubuntu Karmic is likely to sync in this change
relatively quickly, which means that this will be an issue for the IAP
2010 Debathena cluster release as well.
Attached is a patch which removes the Moira clients' and library's
strict dependency on krb4. The patch adds support for building
--without-krb4 by defining HAVE_KRB4 when it's available, and using a
bunch of #ifdefs to disable the krb4 code when it's not available. I
added a new error code, MR_NO_KRB4, which is returned by functions that
previously would have required krb4. I also added mr_kname_parse, as a
parallel to mr_kname_unparse, and an internal header file which defines
the necessary missing constants.
Since Debathena can't build Moira for Debian Squeeze without this patch,
I intend to start building with it immediately, but we're always
interested in minimizing our skew from your source tree.
- Evan
--------------070207060000090709010709
Content-Type: text/plain; x-mac-type="0"; x-mac-creator="0";
name="build-without-krb4.patch"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename="build-without-krb4.patch"
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);
--------------070207060000090709010709--