Ticket #198: build-without-krb4.4

File build-without-krb4.4, 21.6 KB (added by broder, 15 years ago)
Line 
1Index: debathena-moira-4.0.0+cvs20090409/configure.in
2===================================================================
3--- debathena-moira-4.0.0+cvs20090409.orig/configure.in 2009-04-14 12:34:49.000000000 -0400
4+++ debathena-moira-4.0.0+cvs20090409/configure.in      2009-04-14 12:47:40.000000000 -0400
5@@ -115,24 +115,27 @@
6     [  --with-krb4=PREFIX      Specify location of krb4],
7     [krb4="$withval"], [krb4=no])
8 AC_MSG_RESULT($krb4)
9-if test "$krb4" != yes; then
10-    MR_INCLUDE($krb4/include)
11-    if test -d "$krb4/include/kerberosIV"; then
12-       MR_INCLUDE($krb4/include/kerberosIV)
13+if test "$krb4" != no; then
14+    if test "$krb4" != yes; then
15+       MR_INCLUDE($krb4/include)
16+       if test -d "$krb4/include/kerberosIV"; then
17+           MR_INCLUDE($krb4/include/kerberosIV)
18+       fi
19+       MR_LIBS($krb4/lib)
20+    elif test -d /usr/include/kerberosIV; then
21+       MR_INCLUDE(/usr/include/kerberosIV)
22     fi
23-    MR_LIBS($krb4/lib)
24-elif test -d /usr/include/kerberosIV; then
25-    MR_INCLUDE(/usr/include/kerberosIV)
26+    MR_DEFINE(HAVE_KRB4)
27+    AC_CHECK_LIB(krb4, krb_rd_req,
28+                [KRB4_LIBS="-lkrb4 -ldes425 -lkrb5 -l${crypto} -lresolv"],
29+                [AC_CHECK_LIB(krb, krb_rd_req,
30+                              [KRB4_LIBS="-lkrb -ldes"],
31+                              [AC_MSG_ERROR(Kerberos 4 libraries not found)],
32+                              $LIBPATH -ldes)],
33+                $LIBPATH -ldes425 -lkrb5 -l${crypto} -lcom_err -lresolv)
34 fi
35 AC_CHECK_LIB(k5crypto, main, crypto="k5crypto",
36              [AC_CHECK_LIB(crypto, main, crypto="crypto")])
37-AC_CHECK_LIB(krb4, krb_rd_req,
38-            [KRB4_LIBS="-lkrb4 -ldes425 -lkrb5 -l${crypto} -lresolv"],
39-            [AC_CHECK_LIB(krb, krb_rd_req,
40-                          [KRB4_LIBS="-lkrb -ldes"],
41-                          [AC_MSG_ERROR(Kerberos 4 libraries not found)],
42-                          $LIBPATH -ldes)],
43-            $LIBPATH -ldes425 -lkrb5 -l${crypto} -lcom_err -lresolv)
44 
45 AC_MSG_CHECKING(for Kerberos 5)
46 AC_ARG_WITH(krb5,
47Index: debathena-moira-4.0.0+cvs20090409/lib/mr_et.et
48===================================================================
49--- debathena-moira-4.0.0+cvs20090409.orig/lib/mr_et.et 2009-04-14 12:34:49.000000000 -0400
50+++ debathena-moira-4.0.0+cvs20090409/lib/mr_et.et      2009-04-14 12:35:05.000000000 -0400
51@@ -237,4 +237,7 @@
52 ec     MR_BAD_MAIL_STRING,
53        "Address refers to nonexistent domain or MIT internal mail server"
54 
55+ec     MR_NO_KRB4,
56+       "Unable to complete operation using Kerberos v4"
57+
58        end
59Index: debathena-moira-4.0.0+cvs20090409/update/auth_002.c
60===================================================================
61--- debathena-moira-4.0.0+cvs20090409.orig/update/auth_002.c    2009-04-14 12:34:49.000000000 -0400
62+++ debathena-moira-4.0.0+cvs20090409/update/auth_002.c 2009-04-14 12:35:05.000000000 -0400
63@@ -15,14 +15,18 @@
64 #include <stdio.h>
65 #include <string.h>
66 
67+#ifdef HAVE_KRB4
68 #include <krb.h>
69+#endif
70 
71 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 $");
72 
73 static char service[] = "rcmd";
74 static char master[] = "sms";
75 static char qmark[] = "???";
76+#ifdef HAVE_KRB4
77 extern des_cblock session;
78+#endif
79 
80 /*
81  * authentication request auth_002:
82@@ -39,6 +43,7 @@
83 
84 void auth_002(int conn, char *str)
85 {
86+#ifdef HAVE_KRB4
87   char aname[ANAME_SZ], ainst[INST_SZ], arealm[REALM_SZ];
88   AUTH_DAT ad;
89   char *p, *first, *data;
90@@ -126,4 +131,7 @@
91   com_err(whoami, code, "auth for %s.%s@%s failed",
92          ad.pname, ad.pinst, ad.prealm);
93   send_int(conn, code);
94+#else
95+  return MR_NO_KRB4;
96+#endif
97 }
98Index: debathena-moira-4.0.0+cvs20090409/update/client.c
99===================================================================
100--- debathena-moira-4.0.0+cvs20090409.orig/update/client.c      2009-04-14 12:34:50.000000000 -0400
101+++ debathena-moira-4.0.0+cvs20090409/update/client.c   2009-04-14 12:35:06.000000000 -0400
102@@ -17,13 +17,17 @@
103 #include <stdlib.h>
104 #include <string.h>
105 
106+#ifdef HAVE_KRB4
107 #include <des.h>
108 #include <krb.h>
109+#endif
110 #include <krb5.h>
111 
112 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 $");
113 
114+#ifdef HAVE_KRB4
115 extern des_cblock session;
116+#endif
117 extern char *whoami;
118 extern krb5_context context;
119 
120@@ -71,6 +75,7 @@
121 
122 int mr_send_auth(int conn, char *host_name)
123 {
124+#ifdef HAVE_KRB4
125   KTEXT_ST ticket_st;
126   int code, auth_version = 2;
127   long response;
128@@ -129,6 +134,9 @@
129     }
130 
131   return MR_SUCCESS;
132+#else
133+  return MR_NO_KRB4;
134+#endif
135 }
136 
137 int mr_execute(int conn, char *path)
138Index: debathena-moira-4.0.0+cvs20090409/update/ticket.c
139===================================================================
140--- debathena-moira-4.0.0+cvs20090409.orig/update/ticket.c      2009-04-14 12:34:50.000000000 -0400
141+++ debathena-moira-4.0.0+cvs20090409/update/ticket.c   2009-04-14 12:35:06.000000000 -0400
142@@ -13,19 +13,27 @@
143 #include <stdio.h>
144 #include <string.h>
145 
146+#ifdef HAVE_KRB4
147 #include <krb.h>
148+#else
149+#define KTEXT void*
150+#endif
151 #include <krb5.h>
152 #include <update.h>
153 
154 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 $");
155 
156+#ifdef HAVE_KRB4
157 static char realm[REALM_SZ];
158 static char master[INST_SZ] = "sms";
159 static char service[ANAME_SZ] = "rcmd";
160 des_cblock session;
161+#endif
162 krb5_context context = NULL;
163 
164+#ifdef HAVE_KRB4
165 static int get_mr_tgt(void);
166+#endif
167 
168 int get_mr_krb5_update_ticket(char *host, krb5_data auth)
169 {
170@@ -58,6 +66,7 @@
171 
172 int get_mr_update_ticket(char *host, KTEXT ticket)
173 {
174+#ifdef HAVE_KRB4
175   int code, pass;
176   char phost[BUFSIZ];
177   CREDENTIALS cr;
178@@ -93,8 +102,12 @@
179       memcpy(session, cr.session, sizeof(session));
180     }
181   return code;
182+#else
183+  return MR_NO_KRB4;
184+#endif
185 }
186 
187+#ifdef HAVE_KRB4
188 static int get_mr_tgt(void)
189 {
190   int code;
191@@ -109,3 +122,4 @@
192   else
193     return code + ERROR_TABLE_BASE_krb;
194 }
195+#endif
196Index: debathena-moira-4.0.0+cvs20090409/include/update.h
197===================================================================
198--- debathena-moira-4.0.0+cvs20090409.orig/include/update.h     2009-04-14 12:34:50.000000000 -0400
199+++ debathena-moira-4.0.0+cvs20090409/include/update.h  2009-04-14 12:35:06.000000000 -0400
200@@ -15,7 +15,4 @@
201 int mr_execute(int conn, char *path);
202 void mr_send_quit(int conn);
203 
204-#include <krb.h>
205-int get_mr_update_ticket(char *host, KTEXT ticket);
206-
207 extern char *whoami;
208Index: debathena-moira-4.0.0+cvs20090409/clients/lib/utils.c
209===================================================================
210--- debathena-moira-4.0.0+cvs20090409.orig/clients/lib/utils.c  2009-04-14 12:34:51.000000000 -0400
211+++ debathena-moira-4.0.0+cvs20090409/clients/lib/utils.c       2009-04-14 12:35:06.000000000 -0400
212@@ -12,7 +12,6 @@
213 #include <mrclient.h>
214 
215 #include <com_err.h>
216-#include <krb.h>
217 #include <krb5.h>
218 
219 #include <sys/types.h>
220Index: debathena-moira-4.0.0+cvs20090409/clients/lib/member.c
221===================================================================
222--- debathena-moira-4.0.0+cvs20090409.orig/clients/lib/member.c 2009-04-14 12:34:51.000000000 -0400
223+++ debathena-moira-4.0.0+cvs20090409/clients/lib/member.c      2009-04-14 12:35:06.000000000 -0400
224@@ -17,12 +17,10 @@
225 #include <string.h>
226 #include <ctype.h>
227 
228-#include <krb.h>
229+#include <krb5.h>
230 
231 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 $");
232 
233-static char default_realm[REALM_SZ];
234-
235 int mrcl_validate_string_member(char *str)
236 {
237   char *p, *lname, *ret;
238@@ -69,6 +67,9 @@
239 int mrcl_validate_kerberos_member(char *str, char **ret)
240 {
241   char *p;
242+  int code = 0;
243+  krb5_context context = NULL;
244+  char *default_realm = NULL;
245 
246   mrcl_clear_message();
247 
248@@ -97,14 +98,27 @@
249          return MRCL_SUCCESS;
250        }
251 
252-      if (!*default_realm)
253-       krb_get_lrealm(default_realm, 1);
254+      code = krb5_init_context(&context);
255+      if (!code)
256+        goto out;
257+
258+      code = krb5_get_default_realm(context, &default_realm);
259+      if (!code)
260+        goto out;
261 
262       *ret = malloc(strlen(str) + strlen(default_realm) + 2);
263       sprintf(*ret, "%s@%s", str, default_realm);
264 
265       mrcl_set_message("Warning: default realm \"%s\" added to principal "
266                       "\"%s\"", default_realm, str);
267+
268+    out:
269+      if (default_realm)
270+        free(default_realm);
271+      if (context)
272+        krb5_free_context(context);
273+      if (!code)
274+        return code;
275       return MRCL_SUCCESS;
276     }
277 
278Index: debathena-moira-4.0.0+cvs20090409/lib/mr_auth.c
279===================================================================
280--- debathena-moira-4.0.0+cvs20090409.orig/lib/mr_auth.c        2009-04-14 12:34:49.000000000 -0400
281+++ debathena-moira-4.0.0+cvs20090409/lib/mr_auth.c     2009-04-14 12:35:06.000000000 -0400
282@@ -15,7 +15,9 @@
283 #include <stdio.h>
284 #include <string.h>
285 
286+#ifdef HAVE_KRB4
287 #include <krb.h>
288+#endif
289 #include <krb5.h>
290 
291 krb5_context context = NULL;
292@@ -29,6 +31,7 @@
293 
294 int mr_auth(char *prog)
295 {
296+#ifdef HAVE_KRB4
297   int status;
298   mr_params params, reply;
299   char *args[2];
300@@ -70,6 +73,9 @@
301   mr_destroy_reply(reply);
302 
303   return status;
304+#else
305+  return MR_NO_KRB4;
306+#endif
307 }
308 
309 int mr_proxy(char *principal, char *orig_authtype)
310Index: debathena-moira-4.0.0+cvs20090409/clients/moira/namespace.c
311===================================================================
312--- debathena-moira-4.0.0+cvs20090409.orig/clients/moira/namespace.c    2009-04-14 12:34:51.000000000 -0400
313+++ debathena-moira-4.0.0+cvs20090409/clients/moira/namespace.c 2009-04-14 12:35:06.000000000 -0400
314@@ -23,8 +23,6 @@
315 #include <stdio.h>
316 #include <string.h>
317 
318-#include <krb.h>
319-
320 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 $");
321 
322 static void ErrorExit(char *buf, int status);
323@@ -176,7 +174,6 @@
324   int status;
325   Menu *menu;
326   char *motd, **arg;
327-  char pname[ANAME_SZ];
328   struct sigaction act;
329 
330   if (!(program_name = strrchr(argv[0], '/')))
331Index: debathena-moira-4.0.0+cvs20090409/update/get_file.c
332===================================================================
333--- debathena-moira-4.0.0+cvs20090409.orig/update/get_file.c    2009-04-14 12:34:50.000000000 -0400
334+++ debathena-moira-4.0.0+cvs20090409/update/get_file.c 2009-04-14 12:35:06.000000000 -0400
335@@ -17,7 +17,9 @@
336 #include <string.h>
337 #include <unistd.h>
338 
339+#ifdef HAVE_KRB4
340 #include <des.h>
341+#endif
342 
343 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 $");
344 
345@@ -25,9 +27,11 @@
346 #define MIN(a, b)    (((a) < (b)) ? (a) : (b))
347 #endif /* MIN */
348 
349+#ifdef HAVE_KRB4
350 static des_key_schedule sched;
351 static des_cblock ivec;
352 extern des_cblock session;
353+#endif
354 
355 static int get_block(int conn, int fd, int max_size, int encrypt);
356 
357@@ -123,8 +127,15 @@
358 
359   if (encrypt)
360     {
361+#ifdef HAVE_KRB4
362       des_key_sched(session, sched);
363       memcpy(ivec, session, sizeof(ivec));
364+#else
365+      /* The session key only gets stored if auth happens in krb4 to
366+         begin with. If you don't have krb4, you can't possibly be
367+         coming up with a valid session key. */
368+      return MR_NO_KRB4;
369+#endif
370     }
371 
372   n_written = 0;
373@@ -173,6 +184,7 @@
374 
375   if (encrypt)
376     {
377+#ifdef HAVE_KRB4
378       char *unenc = malloc(len);
379 
380       if (!unenc)
381@@ -186,6 +198,7 @@
382        ivec[i] = data[len - 8 + i] ^ unenc[len - 8 + i];
383       free(data);
384       data = unenc;
385+#endif
386     }
387 
388   n_read = MIN(len, max_size);
389Index: debathena-moira-4.0.0+cvs20090409/update/send_file.c
390===================================================================
391--- debathena-moira-4.0.0+cvs20090409.orig/update/send_file.c   2009-04-14 12:34:50.000000000 -0400
392+++ debathena-moira-4.0.0+cvs20090409/update/send_file.c        2009-04-14 12:35:06.000000000 -0400
393@@ -17,12 +17,16 @@
394 #include <string.h>
395 #include <unistd.h>
396 
397+#ifdef HAVE_KRB4
398 #include <des.h>
399+#endif
400 #include <update.h>
401 
402 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 $");
403 
404+#ifdef HAVE_KRB4
405 extern des_cblock session;
406+#endif
407 
408 /*
409  * syntax:
410@@ -47,8 +51,10 @@
411   char data[UPDATE_BUFSIZ], enc[UPDATE_BUFSIZ];
412   long response;
413   struct stat statb;
414+#ifdef HAVE_KRB4
415   des_key_schedule sched;
416   des_cblock ivec;
417+#endif
418 
419   /* send file over */
420   fd = open(pathname, O_RDONLY, 0);
421@@ -105,8 +111,15 @@
422 
423   if (encrypt)
424     {
425+#ifdef HAVE_KRB4
426       des_key_sched(session, sched);
427       memmove(ivec, session, sizeof(ivec));
428+#else
429+      /* The session key only gets stored if auth happens in krb4 to
430+         begin with. If you don't have krb4, you can't possibly be
431+         coming up with a valid session key. */
432+      return MR_NO_KRB4;
433+#endif
434     }
435 
436   while (n_to_send > 0)
437@@ -120,6 +133,7 @@
438        }
439       if (encrypt)
440        {
441+#ifdef HAVE_KRB4
442          memset(data + n, 0, sizeof(data) -n);
443          des_pcbc_encrypt(data, enc, (n + 7) & ~7, sched, ivec, 0);
444          /* save vector to continue chaining */
445@@ -128,6 +142,7 @@
446          /* round up to multiple of 8 */
447          n = (n + 7) & ~7;
448          code = send_string(conn, enc, n);
449+#endif
450        }
451       else
452        code = send_string(conn, data, n);
453Index: debathena-moira-4.0.0+cvs20090409/update/update_server.c
454===================================================================
455--- debathena-moira-4.0.0+cvs20090409.orig/update/update_server.c       2009-04-14 12:34:50.000000000 -0400
456+++ debathena-moira-4.0.0+cvs20090409/update/update_server.c    2009-04-14 12:35:06.000000000 -0400
457@@ -25,7 +25,9 @@
458 #include <unistd.h>
459 #include <syslog.h>
460 
461+#ifdef HAVE_KRB4
462 #include <des.h>
463+#endif
464 #include "update.h"
465 
466 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 $");
467@@ -33,7 +35,9 @@
468 char *whoami, *hostname;
469 
470 int have_authorization = 0;
471+#ifdef HAVE_KRB4
472 des_cblock session;
473+#endif
474 int uid = 0;
475 
476 void child_handler(int signal);
477@@ -44,7 +48,9 @@
478   char *str;
479   void (*proc)(int, char *);
480 } dispatch_table[] = {
481+#ifdef HAVE_KRB4
482   { "AUTH_002", auth_002 },
483+#endif
484   { "AUTH_003", auth_003 },
485   { "XFER_002", xfer_002 },
486   { "XFER_003", xfer_003 },
487Index: debathena-moira-4.0.0+cvs20090409/clients/mailmaint/mailmaint.c
488===================================================================
489--- debathena-moira-4.0.0+cvs20090409.orig/clients/mailmaint/mailmaint.c        2009-04-14 12:34:51.000000000 -0400
490+++ debathena-moira-4.0.0+cvs20090409/clients/mailmaint/mailmaint.c     2009-04-14 12:35:07.000000000 -0400
491@@ -31,8 +31,6 @@
492 #include <unistd.h>
493 #endif
494 
495-#include <krb.h>
496-
497 #ifdef _WIN32
498 #define INPUT_MASK 0xff
499 #ifdef getchar
500Index: debathena-moira-4.0.0+cvs20090409/update/auth_003.c
501===================================================================
502--- debathena-moira-4.0.0+cvs20090409.orig/update/auth_003.c    2009-04-14 12:34:50.000000000 -0400
503+++ debathena-moira-4.0.0+cvs20090409/update/auth_003.c 2009-04-14 12:35:07.000000000 -0400
504@@ -15,7 +15,11 @@
505 #include <stdio.h>
506 #include <string.h>
507 
508+#ifdef HAVE_KRB4
509 #include <krb.h>
510+#else
511+#include <mr_krb.h>
512+#endif
513 #include <krb5.h>
514 
515 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 $");
516@@ -44,6 +48,7 @@
517   char *p, *first, *data;
518   char name[ANAME_SZ], inst[INST_SZ], realm[REALM_SZ];
519   char aname[ANAME_SZ], ainst[INST_SZ], arealm[REALM_SZ];
520+  char *lrealm = NULL;
521   size_t size;
522   long code;
523   struct utsname uts;
524@@ -143,7 +148,11 @@
525     {
526       strcpy(aname, master);
527       strcpy(ainst, "");
528-      if (krb_get_lrealm(arealm, 1))
529+      if (!krb5_get_default_realm(context, &lrealm))
530+        {
531+          strcpy(arealm, lrealm);
532+        }
533+      else
534        strcpy(arealm, KRB_REALM);
535     }
536   code = EPERM;
537@@ -159,6 +168,8 @@
538   have_authorization = 1;
539 
540  out:
541+  if (lrealm)
542+    free(lrealm);
543   if (client)
544     krb5_free_principal(context, client);
545   if (server)
546Index: debathena-moira-4.0.0+cvs20090409/include/moira.h
547===================================================================
548--- debathena-moira-4.0.0+cvs20090409.orig/include/moira.h      2009-04-14 12:34:50.000000000 -0400
549+++ debathena-moira-4.0.0+cvs20090409/include/moira.h   2009-04-14 12:35:07.000000000 -0400
550@@ -115,6 +115,9 @@
551 /* prototypes from kname_unparse.c */
552 char *mr_kname_unparse(char *p, char *i, char *r);
553 
554+/* prototypes from kname_parse.c */
555+int mr_kname_parse(char *np, char *ip, char *rp, char *fullname);
556+
557 /* prototypes from nfsparttype.c */
558 char *parse_filesys_type(char *fs_type_name);
559 char *format_filesys_type(char *fs_status);
560Index: debathena-moira-4.0.0+cvs20090409/include/mr_krb.h
561===================================================================
562--- /dev/null   1970-01-01 00:00:00.000000000 +0000
563+++ debathena-moira-4.0.0+cvs20090409/include/mr_krb.h  2009-04-14 12:37:49.000000000 -0400
564@@ -0,0 +1,20 @@
565+/* $Id$
566+ *
567+ * Copyright (C) 2009 by the Massachusetts Institute of Technology
568+ *
569+ * Define some useful constants that used to be provided by the krb4
570+ * libraries.
571+ *
572+ */
573+
574+#define ANAME_SZ      40
575+#define INST_SZ       40
576+#define REALM_SZ      40
577+/* include space for '.' and '@' */
578+#define MAX_K_NAME_SZ (ANAME_SZ + INST_SZ + REALM_SZ + 2)
579+
580+#define KRB_REALM "ATHENA.MIT.EDU"
581+
582+#define kname_parse mr_kname_parse
583+
584+#define ERROR_TABLE_BASE_krb                     (39525376L)
585Index: debathena-moira-4.0.0+cvs20090409/lib/Makefile.in
586===================================================================
587--- debathena-moira-4.0.0+cvs20090409.orig/lib/Makefile.in      2009-04-14 12:34:49.000000000 -0400
588+++ debathena-moira-4.0.0+cvs20090409/lib/Makefile.in   2009-04-14 12:35:07.000000000 -0400
589@@ -16,7 +16,7 @@
590 BUILDTOP=..
591 
592 OBJS=  critical.o fixhost.o fixname.o \
593-       hash.o kname_unparse.o krb_et.o mr_access.o mr_auth.o \
594+       hash.o kname_unparse.o kname_parse.o krb_et.o mr_access.o mr_auth.o \
595        mr_call.o mr_connect.o mr_et.o mr_init.o mr_ops.o mr_query.o \
596        nfsparttype.o sq.o strs.o ureg_err.o
597 
598Index: debathena-moira-4.0.0+cvs20090409/lib/kname_parse.c
599===================================================================
600--- /dev/null   1970-01-01 00:00:00.000000000 +0000
601+++ debathena-moira-4.0.0+cvs20090409/lib/kname_parse.c 2009-04-14 12:35:07.000000000 -0400
602@@ -0,0 +1,119 @@
603+/* $Id$
604+ *
605+ * Provide a copy of kname_parse() from krb4 for when krb4 is no
606+ * longer available.
607+ *
608+ * Copyright (C) 2009 by the Massachusetts Institute of Technology
609+ * For copying and distribution information, please see the file
610+ * <mit-copyright.h>.
611+ */
612+
613+#include <mit-copyright.h>
614+#include <moira.h>
615+
616+#include <string.h>
617+
618+#ifdef HAVE_KRB4
619+#include <krb.h>
620+#else
621+#include <mr_krb.h>
622+
623+#define KRBET_KNAME_FMT                          (39525457L)
624+#define KNAME_FMT                                (KRBET_KNAME_FMT - ERROR_TABLE_BASE_krb)
625+#endif
626+
627+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 $");
628+
629+#define NAME    0               /* which field are we in? */
630+#define INST    1
631+#define REALM   2
632+
633+int mr_kname_parse(char *np, char *ip, char *rp, char *fullname)
634+{
635+  char buf[MAX_K_NAME_SZ];
636+  char *rnext, *wnext;        /* next char to read, write */
637+  register char c;
638+  int backslash;
639+  int field;
640+
641+  backslash = 0;
642+  rnext = buf;
643+  wnext = np;
644+  field = NAME;
645+
646+  if (strlen(fullname) > MAX_K_NAME_SZ)
647+    return KNAME_FMT;
648+  (void) strcpy(buf, fullname);
649+
650+  while ((c = *rnext++)) {
651+    if (backslash) {
652+      *wnext++ = c;
653+      backslash = 0;
654+      continue;
655+    }
656+    switch (c) {
657+    case '\\':
658+      backslash++;
659+      break;
660+    case '.':
661+      switch (field) {
662+      case NAME:
663+        if (wnext == np)
664+          return KNAME_FMT;
665+        *wnext = '\0';
666+        field = INST;
667+        wnext = ip;
668+        break;
669+      case INST:          /* We now allow period in instance */
670+      case REALM:
671+        *wnext++ = c;
672+        break;
673+      default:
674+        return KNAME_FMT;
675+      }
676+      break;
677+    case '@':
678+      switch (field) {
679+      case NAME:
680+        if (wnext == np)
681+          return KNAME_FMT;
682+        *ip = '\0';
683+        /* fall through */
684+      case INST:
685+        *wnext = '\0';
686+        field = REALM;
687+        wnext = rp;
688+        break;
689+      case REALM:
690+        return KNAME_FMT;
691+      default:
692+        return KNAME_FMT;
693+      }
694+      break;
695+    default:
696+      *wnext++ = c;
697+    }
698+    /*
699+     * Paranoia: check length each time through to ensure that we
700+     * don't overwrite things.
701+     */
702+    switch (field) {
703+    case NAME:
704+      if (wnext - np >= ANAME_SZ)
705+        return KNAME_FMT;
706+      break;
707+    case INST:
708+      if (wnext - ip >= INST_SZ)
709+        return KNAME_FMT;
710+      break;
711+    case REALM:
712+      if (wnext - rp >= REALM_SZ)
713+        return KNAME_FMT;
714+      break;
715+    default:
716+      return KNAME_FMT;
717+    }
718+  }
719+  *wnext = '\0';
720+  return 0;
721+}
722Index: debathena-moira-4.0.0+cvs20090409/lib/kname_unparse.c
723===================================================================
724--- debathena-moira-4.0.0+cvs20090409.orig/lib/kname_unparse.c  2009-04-14 12:34:49.000000000 -0400
725+++ debathena-moira-4.0.0+cvs20090409/lib/kname_unparse.c       2009-04-14 12:35:07.000000000 -0400
726@@ -13,8 +13,11 @@
727 
728 #include <stdio.h>
729 
730-#include <des.h>
731+#ifdef HAVE_KRB5
732 #include <krb.h>
733+#else
734+#include <mr_krb.h>
735+#endif
736 
737 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 $");
738 
739Index: debathena-moira-4.0.0+cvs20090409/clients/moira/user.c
740===================================================================
741--- debathena-moira-4.0.0+cvs20090409.orig/clients/moira/user.c 2009-03-31 15:13:09.000000000 -0400
742+++ debathena-moira-4.0.0+cvs20090409/clients/moira/user.c      2009-04-14 12:39:50.000000000 -0400
743@@ -25,8 +25,6 @@
744 #include <string.h>
745 #include <time.h>
746 
747-#include <krb.h>
748-
749 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 $");
750 
751 void CorrectCapitalization(char **name);