home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #1 / NN_1993_1.iso / spool / comp / mail / mh / 1464 < prev    next >
Encoding:
Internet Message Format  |  1993-01-05  |  26.2 KB

  1. Xref: sparky comp.mail.mh:1464 comp.protocols.kerberos:983
  2. Path: sparky!uunet!dtix!mimsy!mojo.eng.umd.edu!enterpoop.mit.edu!senator-bedfellow.mit.edu!aktis.com!jik
  3. From: jik@Aktis.COM (Jonathan I. Kamens)
  4. Newsgroups: comp.mail.mh,comp.protocols.kerberos
  5. Subject: mh 6.8 changes: Kerberos V5 & NeXT support
  6. Message-ID: <1icua0INN8r7@senator-bedfellow.MIT.EDU>
  7. Date: 5 Jan 93 21:24:16 GMT
  8. Sender: jik@athena.mit.edu (Jonathan I. Kamens)
  9. Followup-To: comp.mail.mh
  10. Organization: Aktis, Inc.
  11. Lines: 1053
  12. NNTP-Posting-Host: pit-manager.mit.edu
  13.  
  14. The patches below do four things:
  15.  
  16. 1) Add support for Kerberos V5, rather than Kerberos V4, by adding the K5POP
  17. option, which should be used instead of (rather than in addition to) the KPOP
  18. option.
  19.  
  20. 2) Clean up the Kerberos V4 configuration stuff (some of which is used for
  21. Kerberos V5 as well).  The two biggest elements in the cleanup were making some
  22. global variables that didn't need to be global local in some files, and fixing
  23. the linking order of libraries when linking against Kerberos libraries.
  24.  
  25. 3) Add support for compiling under NeXTSTEP 3 with gcc2.  This involved only a
  26. minor change to h/strings.h.
  27.  
  28. 4) Add a "dldflag" configuration parameter, defaulting to "dldflag: -pic". 
  29. This is necessary, for example, when building shared libraries using gcc2 under
  30. SunOS; in that case, it would be "dldflag: -fPIC".
  31.  
  32. I haven't updated the documentation, but the changes are straightforward.
  33.  
  34. NOTE: We're using the popper that was shipped with the Kerberos V5 beta release
  35. (after fixing it to make it actually work; eventually, we'll be posting those
  36. patches as well), not the one that's in the MH distribution.  I've patched the
  37. MH popd so that it looks like the one in the Kerberos V5 distribution and so
  38. that it compiles, but I haven't tested it.  I have, however, tested the client
  39. Kerberos patches (inc, msgchk), and they appear to work just fine.
  40.  
  41. *** 1.1    1992/12/31 20:25:48
  42. --- conf/config/mts.c    1992/12/31 21:25:44
  43. ***************
  44. *** 475,481 ****
  45.   char   *getusr () {
  46.       register char  *cp,
  47.                      *np;
  48. ! #ifdef KPOP
  49.       int uid;
  50.   #endif /* KPOP */
  51.       register struct passwd *pw;
  52. --- 475,481 ----
  53.   char   *getusr () {
  54.       register char  *cp,
  55.                      *np;
  56. ! #if defined(KPOP) || defined(K5POP)
  57.       int uid;
  58.   #endif /* KPOP */
  59.       register struct passwd *pw;
  60. ***************
  61. *** 483,493 ****
  62.       if (username[0])
  63.       return username;
  64.   
  65. ! #ifndef KPOP
  66.       if ((pw = getpwuid (getuid ())) == NULL
  67.           || pw -> pw_name == NULL
  68.           || *pw -> pw_name == NULL) {
  69. ! #else /* KPOP */
  70.       uid = getuid ();
  71.       if (uid == geteuid () && (cp = getenv ("USER")) != NULL
  72.       && (pw = getpwnam (cp)) != NULL)
  73. --- 483,493 ----
  74.       if (username[0])
  75.       return username;
  76.   
  77. ! #if !defined(KPOP) && !defined(K5POP)
  78.       if ((pw = getpwuid (getuid ())) == NULL
  79.           || pw -> pw_name == NULL
  80.           || *pw -> pw_name == NULL) {
  81. ! #else /* KPOP || K5POP */
  82.       uid = getuid ();
  83.       if (uid == geteuid () && (cp = getenv ("USER")) != NULL
  84.       && (pw = getpwnam (cp)) != NULL)
  85. ***************
  86. *** 495,501 ****
  87.       else if ((pw = getpwuid (uid)) == NULL
  88.            || pw -> pw_name == NULL
  89.            || *pw -> pw_name == '\0') {
  90. ! #endif /* KPOP */
  91.       (void) strcpy (username, "unknown");
  92.       (void) sprintf (fullname, "The Unknown User-ID (%d)", getuid ());
  93.       return username;
  94. --- 495,501 ----
  95.       else if ((pw = getpwuid (uid)) == NULL
  96.            || pw -> pw_name == NULL
  97.            || *pw -> pw_name == '\0') {
  98. ! #endif /* KPOP || K5POP */
  99.       (void) strcpy (username, "unknown");
  100.       (void) sprintf (fullname, "The Unknown User-ID (%d)", getuid ());
  101.       return username;
  102. *** 1.1    1992/12/31 19:39:55
  103. --- conf/makefiles/support/pop    1992/12/31 21:21:57
  104. ***************
  105. *** 12,17 ****
  106. --- 12,23 ----
  107.   OPTIONS    =    @(MHOPTIONS) @(POPUUMBOX) -I..
  108.   LDOPTIONS=    @(LDOPTIONS)
  109.   LDOPTLIB=    @(LDOPTLIB)
  110. + @BEGIN: KPOP
  111. + KRBLIB=        -lkrb -ldes
  112. + @END: KPOP
  113. + @BEGIN: K5POP
  114. + KRBLIB=        -lkrb5 -lcrypto -lisode -lcom_err
  115. + @END: K5POP
  116.   @BEGIN: MPOP
  117.   LDCURSES=    @(LDCURSES)
  118.   @END: MPOP
  119. ***************
  120. *** 51,57 ****
  121.   @BEGIN: STDLIB
  122.   LIBES2    =    ../../config/config.o ../../sbr/libmh.a $(LIBES1)
  123.   LDLIBS1    =    $(LIBES1) $(LDOPTLIB)
  124. ! LDLIBS2    =    $(LIBES2) ../../config/version.o $(LDOPTLIB)
  125.   @END: STDLIB
  126.   @BEGIN: SUN4SHLIB
  127.   SLIBVER    =    .@(SLIBVER)
  128. --- 57,63 ----
  129.   @BEGIN: STDLIB
  130.   LIBES2    =    ../../config/config.o ../../sbr/libmh.a $(LIBES1)
  131.   LDLIBS1    =    $(LIBES1) $(LDOPTLIB)
  132. ! LDLIBS2    =    $(LIBES2) ../../config/version.o $(KRBLIB) $(LDOPTLIB)
  133.   @END: STDLIB
  134.   @BEGIN: SUN4SHLIB
  135.   SLIBVER    =    .@(SLIBVER)
  136. ***************
  137. *** 60,66 ****
  138.   LIBES2    =    ../../config/config.o ../../sbr/libmh.so $(LIBES1)
  139.   LDLIBS1    =    $(LIBES1) $(LDOPTLIB)
  140.   LDLIBS2    =    ../../config/config.o ../../config/version.o \
  141. !         -Bdynamic @(SLDFLAG) -lmh$(SLIBVER) $(LIBES1) $(LDOPTLIB)
  142.   @END: SHAREDLIB
  143.   
  144.   LINT    =    lint
  145. --- 66,73 ----
  146.   LIBES2    =    ../../config/config.o ../../sbr/libmh.so $(LIBES1)
  147.   LDLIBS1    =    $(LIBES1) $(LDOPTLIB)
  148.   LDLIBS2    =    ../../config/config.o ../../config/version.o \
  149. !         @(DLDFLAG) @(SLDFLAG) -lmh$(SLIBVER) $(LIBES1) \
  150. !         $(KRBLIB) $(LDOPTLIB)
  151.   @END: SHAREDLIB
  152.   
  153.   LINT    =    lint
  154. *** 1.1    1992/12/31 19:51:18
  155. --- conf/makefiles/support/bboards    1992/12/31 19:52:04
  156. ***************
  157. *** 55,61 ****
  158.   LDLIBS1    =    $(LIBES1) $(LDOPTLIB)
  159.   LDLIBS2    =    $(LIBES2) $(LDOPTLIB)
  160.   LDLIBS2    =    ../../config/config.o ../../config/version.o \
  161. !         -Bdynamic @(SLDFLAG) -lmh$(SLIBVER) $(LIBES1) $(LDOPTLIB)
  162.   @END: SHAREDLIB
  163.   
  164.   LINT    =    lint
  165. --- 55,61 ----
  166.   LDLIBS1    =    $(LIBES1) $(LDOPTLIB)
  167.   LDLIBS2    =    $(LIBES2) $(LDOPTLIB)
  168.   LDLIBS2    =    ../../config/config.o ../../config/version.o \
  169. !         @(DLDFLAG) @(SLDFLAG) -lmh$(SLIBVER) $(LIBES1) $(LDOPTLIB)
  170.   @END: SHAREDLIB
  171.   
  172.   LINT    =    lint
  173. *** 1.1    1992/12/31 19:28:03
  174. --- conf/makefiles/uip    1992/12/31 21:21:16
  175. ***************
  176. *** 84,89 ****
  177. --- 84,92 ----
  178.   @BEGIN: KPOP
  179.   KRBLIB  =       -lkrb -ldes
  180.   @END: KPOP
  181. + @BEGIN: K5POP
  182. + KRBLIB=        -lkrb5 -lcrypto -lisode -lcom_err
  183. + @END: K5POP
  184.   @BEGIN: BPOP
  185.   PSHLIB    =    popsbr.o
  186.   PSHLLIBS=    popsbr.c 
  187. ***************
  188. *** 132,138 ****
  189.   @BEGIN: STDLIB
  190.   LIBES    =    ../config/config.o ../sbr/libmh.a ../mts/libmts.a \
  191.           ../zotnet/libzot.a
  192. ! LDLIBS    =    $(LIBES) ../config/version.o $(LDOPTLIB)
  193.   @END: STDLIB
  194.   @BEGIN: SUN4SHLIB
  195.   SLIBVER    =    .@(SLIBVER)
  196. --- 135,141 ----
  197.   @BEGIN: STDLIB
  198.   LIBES    =    ../config/config.o ../sbr/libmh.a ../mts/libmts.a \
  199.           ../zotnet/libzot.a
  200. ! LDLIBS    =    $(LIBES) ../config/version.o $(KRBLIB) $(HESLIB) $(LDOPTLIB)
  201.   @END: STDLIB
  202.   @BEGIN: SUN4SHLIB
  203.   SLIBVER    =    .@(SLIBVER)
  204. ***************
  205. *** 140,148 ****
  206.   @BEGIN: SHAREDLIB
  207.   LIBES    =    ../config/config.o ../sbr/libmh.so ../mts/libmts.a \
  208.           ../zotnet/libzot.a
  209. ! LDLIBES    =    ../config/config.o -Bdynamic @(SLDFLAG) -lmh$(SLIBVER) \
  210.           ../mts/libmts.a  ../zotnet/libzot.a
  211. ! LDLIBS    =    $(LDLIBES) ../config/version.o $(LDOPTLIB)
  212.   @END: SHAREDLIB
  213.   LINT    =    lint
  214.   LFLAGS    =    -bhu $(OPTIONS) $(TMAOPTS)
  215. --- 143,151 ----
  216.   @BEGIN: SHAREDLIB
  217.   LIBES    =    ../config/config.o ../sbr/libmh.so ../mts/libmts.a \
  218.           ../zotnet/libzot.a
  219. ! LDLIBES    =    ../config/config.o @(DLDFLAG) @(SLDFLAG) -lmh$(SLIBVER) \
  220.           ../mts/libmts.a  ../zotnet/libzot.a
  221. ! LDLIBS    =    $(LDLIBES) ../config/version.o $(KRBLIB) $(HESLIB) $(LDOPTLIB)
  222.   @END: SHAREDLIB
  223.   LINT    =    lint
  224.   LFLAGS    =    -bhu $(OPTIONS) $(TMAOPTS)
  225. ***************
  226. *** 568,574 ****
  227.   xinc:        inc.o scansbr.o dropsbr.o trmsbr.o \
  228.               $(POPLIB) $(TMALIB) $(LIBES)
  229.           $(LD) $(LDFLAGS) -o $@ inc.o scansbr.o dropsbr.o \
  230. !             trmsbr.o $(POPLIB) $(TMALIB) $(KRBLIB) $(HESLIB) \
  231.               $(LDLIBS) $(LDCURSES)
  232.   
  233.   l-inc:;        $(LINT) $(LFLAGS) inc.c scansbr.c \
  234. --- 571,577 ----
  235.   xinc:        inc.o scansbr.o dropsbr.o trmsbr.o \
  236.               $(POPLIB) $(TMALIB) $(LIBES)
  237.           $(LD) $(LDFLAGS) -o $@ inc.o scansbr.o dropsbr.o \
  238. !             trmsbr.o $(POPLIB) $(TMALIB) \
  239.               $(LDLIBS) $(LDCURSES)
  240.   
  241.   l-inc:;        $(LINT) $(LFLAGS) inc.c scansbr.c \
  242. ***************
  243. *** 734,741 ****
  244.   msgchk:        xmsgchk
  245.   
  246.   xmsgchk:    msgchk.o $(POPLIB) $(LIBES)
  247. !         $(LD) $(LDFLAGS) -o $@ msgchk.o $(POPLIB) \
  248. !                     $(KRBLIB) $(HESLIB) $(LDLIBS)
  249.   
  250.   l-msgchk:;    $(LINT) $(LFLAGS) msgchk.c $(POPLLIBS) $(LLIBS)
  251.   
  252. --- 737,743 ----
  253.   msgchk:        xmsgchk
  254.   
  255.   xmsgchk:    msgchk.o $(POPLIB) $(LIBES)
  256. !         $(LD) $(LDFLAGS) -o $@ msgchk.o $(POPLIB) $(LDLIBS)
  257.   
  258.   l-msgchk:;    $(LINT) $(LFLAGS) msgchk.c $(POPLLIBS) $(LLIBS)
  259.   
  260. *** 1.1    1992/12/31 19:52:28
  261. --- conf/mhconfig.c    1992/12/31 20:23:19
  262. ***************
  263. *** 91,96 ****
  264. --- 91,97 ----
  265.   static char *signl = "int";
  266.   static char *slibdir = "/usr/local/lib";
  267.   static char *slflags = "-pic";
  268. + static char *dldflag = "-Bdynamic";
  269.   static char *sprntf = NULL;
  270.   
  271.   /*   */
  272. ***************
  273. *** 132,137 ****
  274. --- 133,139 ----
  275.       "APOP", 0,    /* authenticated pop */
  276.       "BSD43", 0,    /* sgid ttys */
  277.       "KPOP", 0,     /* KERBEROS pop */
  278. +     "K5POP", 0, /* KERBEROS V5 pop */
  279.       "HESIOD", 0,
  280.       "MIME", 0,    /* multi-media extensions */
  281.       "MPOP", 0,    /* mobile pop */
  282. ***************
  283. *** 187,192 ****
  284. --- 189,195 ----
  285.               "sharedlib", &sharedlib, BD_NIL,
  286.               "signal", &signl, BD_NIL,
  287.               "slflags", &slflags, BD_NIL,
  288. +             "dldflag", &dldflag, BD_NIL,
  289.               "slibdir", &slibdir, BD_NIL,
  290.               "sprintf", &sprntf, BD_NIL,
  291.                           NULL
  292. ***************
  293. *** 433,438 ****
  294. --- 436,442 ----
  295.       fprintf (fp, "s%%@(SLIBDIR)%%%s%%g\n", slibdir);
  296.       fprintf (fp, "s%%@(SLIBVER)%%%s%%g\n", MHSLIBVER);
  297.       fprintf (fp, "s%%@(SLFLAGS)%%%s%%g\n", SVAL(slflags));
  298. +     fprintf (fp, "s%%@(DLDFLAG)%%%s%%g\n", SVAL(dldflag));
  299.       if (strcmp (sharedlib, "secure") == 0)
  300.           fprintf (fp, "s%%@(SLDFLAG)%%-L%s%%g\n",slibdir);
  301.       else
  302. *** 1.1    1993/01/04 20:15:17
  303. --- h/strings.h    1993/01/05 01:21:01
  304. ***************
  305. *** 3,10 ****
  306.   
  307.   #ifndef    _STRINGS        /* once-only... */
  308.   #define    _STRINGS
  309.   
  310. ! #ifdef AUX
  311.   #include <stdlib.h>
  312.   #endif
  313.   
  314. --- 3,10 ----
  315.   
  316.   #ifndef    _STRINGS        /* once-only... */
  317.   #define    _STRINGS
  318.   
  319. ! #if defined(AUX) || defined(NeXT)
  320.   #include <stdlib.h>
  321.   #endif
  322.   
  323. ***************
  324. *** 51,57 ****
  325.   char   *strncpy ();
  326.   #endif
  327.   
  328. ! #ifndef    SVR4
  329.   char   *getenv ();
  330.   char   *calloc (), *malloc (), *realloc ();
  331.   #endif    /* SVR4 */
  332. --- 51,57 ----
  333.   char   *strncpy ();
  334.   #endif
  335.   
  336. ! #if !(defined(SVR4)  || defined(NeXT))
  337.   char   *getenv ();
  338.   char   *calloc (), *malloc (), *realloc ();
  339.   #endif    /* SVR4 */
  340. *** 1.1    1992/12/31 20:15:28
  341. --- uip/inc.c    1992/12/31 20:24:02
  342. ***************
  343. *** 18,26 ****
  344.   #include "../h/mh.h"
  345.   #ifdef    POP
  346.   #include "../h/dropsbr.h"
  347. - #endif
  348. - #ifdef KPOP
  349. - #include <krb.h>
  350.   #endif
  351.   #ifdef HESIOD
  352.   #include <hesiod.h>
  353. --- 18,23 ----
  354. *** 1.1    1992/12/31 21:48:15
  355. --- uip/popsbr.c    1992/12/31 21:48:57
  356. ***************
  357. *** 142,148 ****
  358.   #endif    /* APOP */
  359.   
  360.   #ifndef NNTP
  361. ! #ifndef    KPOP
  362.       if ((fd1 = client (host, "tcp", POPSERVICE, rpop, response)) == NOTOK)
  363.   #else    /* KPOP */
  364.       (void) sprintf (buffer, "%s/%s", POPSERVICE, "kpop");
  365. --- 142,148 ----
  366.   #endif    /* APOP */
  367.   
  368.   #ifndef NNTP
  369. ! #if !defined(KPOP) && !defined(K5POP)
  370.       if ((fd1 = client (host, "tcp", POPSERVICE, rpop, response)) == NOTOK)
  371.   #else    /* KPOP */
  372.       (void) sprintf (buffer, "%s/%s", POPSERVICE, "kpop");
  373. *** 1.1    1992/12/31 21:48:15
  374. --- uip/pshsbr.c    1992/12/31 21:48:58
  375. ***************
  376. *** 142,148 ****
  377.   #endif    /* APOP */
  378.   
  379.   #ifndef NNTP
  380. ! #ifndef    KPOP
  381.       if ((fd1 = client (host, "tcp", POPSERVICE, rpop, response)) == NOTOK)
  382.   #else    /* KPOP */
  383.       (void) sprintf (buffer, "%s/%s", POPSERVICE, "kpop");
  384. --- 142,148 ----
  385.   #endif    /* APOP */
  386.   
  387.   #ifndef NNTP
  388. ! #if !defined(KPOP) && !defined(K5POP)
  389.       if ((fd1 = client (host, "tcp", POPSERVICE, rpop, response)) == NOTOK)
  390.   #else    /* KPOP */
  391.       (void) sprintf (buffer, "%s/%s", POPSERVICE, "kpop");
  392. *** 1.1    1992/12/31 21:04:34
  393. --- zotnet/mts/client.c    1992/12/31 21:39:01
  394. ***************
  395. *** 27,32 ****
  396. --- 27,35 ----
  397.   #endif
  398.   
  399.   #ifdef KPOP
  400. + #ifdef K5POP
  401. + "Can't use both KPOP and K5POP!"
  402. + #endif
  403.   #include <krb.h>
  404.   #include <ctype.h>
  405.   
  406. ***************
  407. *** 35,40 ****
  408. --- 38,51 ----
  409.   static KTEXT ticket = (KTEXT)NULL;
  410.   static Key_schedule schedule;
  411.   #endif    /* KPOP */
  412. + #ifdef K5POP
  413. + #include <krb5/krb5.h>
  414. + #include <krb5/ext-proto.h>
  415. + #include <ctype.h>
  416. + #endif /* K5POP */
  417. + #if defined(KPOP) || defined(K5POP)
  418. + static char *kservice;        /* "pop" if using kpop */
  419. + #endif
  420.   
  421.   #define    NOTOK    (-1)
  422.   #define    OK    0
  423. ***************
  424. *** 74,85 ****
  425.   static struct addrent *he, *hz;
  426.   static struct addrent hosts[MAXHOSTS];
  427.   
  428. - #ifdef KPOP
  429. - char krb_realm[REALM_SZ];
  430. - char *PrincipalHostname();
  431. - static char *kservice;        /* "pop" if using kpop */
  432. - #endif /* KPOP */
  433.   #ifdef __STDC__
  434.   static int rcaux (struct servent *, struct hostent *, int, char *);
  435.   static int getport (int, int, char *);
  436. --- 85,90 ----
  437. ***************
  438. *** 108,114 ****
  439.       register struct netent *np;
  440.   #endif
  441.       register struct servent *sp;
  442. ! #ifdef    KPOP
  443.       char *cp;
  444.   
  445.       if (cp = index (kservice = service, '/')) {    /* "pop/kpop" */
  446. --- 113,119 ----
  447.       register struct netent *np;
  448.   #endif
  449.       register struct servent *sp;
  450. ! #if defined(KPOP) || defined(K5POP)
  451.       char *cp;
  452.   
  453.       if (cp = index (kservice = service, '/')) {    /* "pop/kpop" */
  454. ***************
  455. *** 117,123 ****
  456.       }
  457.       else
  458.       kservice = NULL;    /* not using KERBEROS */
  459. ! #endif    /* KPOP */
  460.       
  461.   
  462.       if ((sp = getservbyname (service, protocol)) == NULL) {
  463. --- 122,128 ----
  464.       }
  465.       else
  466.       kservice = NULL;    /* not using KERBEROS */
  467. ! #endif    /* KPOP || K5POP */
  468.       
  469.   
  470.       if ((sp = getservbyname (service, protocol)) == NULL) {
  471. ***************
  472. *** 208,213 ****
  473. --- 213,226 ----
  474.   #ifdef KPOP
  475.       int rem;
  476.   #endif    /* KPOP */
  477. + #ifdef K5POP
  478. +      krb5_error_code rem;
  479. +      krb5_ccache ccdef;
  480. +      krb5_principal client, server;
  481. +      krb5_error *err_ret;
  482. +      register char *cp;
  483. + #endif /* K5POP */
  484. +     char *error_string = "Post office refused connection: ";
  485.   
  486.       for (ap = nets; ap < ne; ap++)
  487.       if (ap -> a_addrtype == hp -> h_addrtype && inet (hp, ap -> a_net))
  488. ***************
  489. *** 262,274 ****
  490.                  "KPOPV0.1");
  491.       if (rem != KSUCCESS) {
  492.           close(sd);
  493. !         (void) strcpy(response, "Post office refused connection: ");
  494.           (void) strcat(response, krb_err_txt[rem]);
  495.           return OOPS2;
  496.       }
  497.       }
  498.   #endif    /* KPOP */
  499.   
  500.       return sd;
  501.   }
  502.   
  503. --- 275,344 ----
  504.                  "KPOPV0.1");
  505.       if (rem != KSUCCESS) {
  506.           close(sd);
  507. !         (void) strcpy(response, error_string);
  508.           (void) strcat(response, krb_err_txt[rem]);
  509.           return OOPS2;
  510.       }
  511.       }
  512.   #endif    /* KPOP */
  513. + #ifdef K5POP
  514. +     if (kservice) {
  515. +     krb5_init_ets();
  516. +     if (rem = krb5_cc_default(&ccdef)) {
  517. +     krb5error:
  518. +         close(sd);
  519. +         (void) strcpy(response, error_string);
  520. +         (void) strcat(response, error_message(rem));
  521. +         return OOPS2;
  522. +     }
  523. +     if (rem = krb5_cc_get_principal(ccdef, &client)) {
  524. +         goto krb5error;
  525. +     }
  526. +     for (cp = hp->h_name; *cp; cp++) {
  527. +         if (isupper(*cp)) {
  528. +         *cp = tolower(*cp);
  529. +         }
  530. +     }
  531.   
  532. +     if (rem = krb5_sname_to_principal(hp->h_name, kservice,
  533. +                       FALSE, &server)) {
  534. +         goto krb5error;
  535. +     }
  536. +     rem = krb5_sendauth((krb5_pointer) &sd, "KPOPV1.0", client, server,
  537. +                 AP_OPTS_MUTUAL_REQUIRED,
  538. +                 0,    /* no checksum */
  539. +                 0,    /* no creds, use ccache instead */
  540. +                 ccdef,
  541. +                 0,    /* don't need seq # */
  542. +                 0,    /* don't need subsession key */
  543. +                 &err_ret,
  544. +                 0); /* don't need reply */
  545. +     krb5_free_principal(server);
  546. +         /* XXX It's really stupid to assume that response is */
  547. +         /* big enough to hold errors, but I wasn't the first */
  548. +         /* person to do that in this code, so I'm following  */
  549. +         /* the other guy's lead.                 */
  550. +     if (rem) {
  551. +         (void) strcpy(response, error_string);
  552. +         (void) strcat(response, error_message(rem));
  553. +         if (err_ret && err_ret->text.length) {
  554. +         (void) strcat(response, " [server says '");
  555. +         (void) strncat(response, err_ret->text.data,
  556. +                    err_ret->text.length);
  557. +         (void) strcat(response, "']");
  558. +         }
  559. +         if (err_ret) {
  560. +         krb5_free_error(err_ret);
  561. +         }
  562. +         (void) close(sd);
  563. +         return OOPS2;
  564. +     }
  565. +     }
  566. + #endif /* K5POP */
  567.       return sd;
  568.   }
  569.   
  570. ***************
  571. *** 297,306 ****
  572.           : "unknown error");
  573.       return NOTOK;
  574.       }
  575. ! #ifdef KPOP
  576.       if (kservice)    /* "pop" */
  577.       return(sd);
  578. ! #endif    /* KPOP */
  579.       if (!rproto)
  580.       return sd;
  581.   
  582. --- 367,376 ----
  583.           : "unknown error");
  584.       return NOTOK;
  585.       }
  586. ! #if defined(KPOP) || defined(K5POP)
  587.       if (kservice)    /* "pop" */
  588.       return(sd);
  589. ! #endif    /* KPOP || K5POP */
  590.       if (!rproto)
  591.       return sd;
  592.   
  593. *** 1.1    1992/12/31 20:29:21
  594. --- support/pop/popd.c    1992/12/31 21:43:23
  595. ***************
  596. *** 32,43 ****
  597.   #include <netdb.h>
  598.   #include <arpa/inet.h>
  599.   #ifdef KPOP
  600.   #include <krb.h>
  601. - static Key_schedule schedule;
  602. - static KTEXT_ST ticket;
  603. - static AUTH_DAT kdata;
  604.   #endif
  605.   #ifdef    SYS5
  606.   #include <fcntl.h>
  607.   #endif
  608. --- 32,48 ----
  609.   #include <netdb.h>
  610.   #include <arpa/inet.h>
  611.   #ifdef KPOP
  612. + #ifdef K5POP
  613. + "Can't use both KPOP and K5POP!"
  614. + #endif /* K5POP */
  615.   #include <krb.h>
  616.   #endif
  617. + #ifdef K5POP
  618. + #include <krb5/krb5.h>
  619. + #include <krb5/ext-proto.h>
  620. + #include <com_err.h>
  621. + #include <ctype.h>
  622. + #endif /* K5POP */
  623.   #ifdef    SYS5
  624.   #include <fcntl.h>
  625.   #endif
  626. ***************
  627. *** 79,88 ****
  628.   static struct sockaddr_in   in_socket;
  629.   static struct sockaddr_in  *isock = &in_socket;
  630.   
  631. - #ifdef KPOP
  632. - static AUTH_DAT kdata;
  633. - #endif
  634.   static int    chldser ();
  635.   void    padios (), padvise ();
  636.   
  637. --- 84,89 ----
  638. ***************
  639. *** 96,102 ****
  640.   char  **argv,
  641.         **envp;
  642.   {
  643. ! #ifdef KPOP
  644.       int     i;
  645.   #else
  646.       int     fd,
  647. --- 97,103 ----
  648.   char  **argv,
  649.         **envp;
  650.   {
  651. ! #if defined(KPOP) || defined(K5POP)
  652.       int     i;
  653.   #else
  654.       int     fd,
  655. ***************
  656. *** 107,113 ****
  657.                          *osock = &out_socket;
  658.   #endif
  659.   
  660. ! #ifdef KPOP
  661.       i = sizeof(in_socket);
  662.       if (getpeername(0, &in_socket, &i) < 0)
  663.         padios("getpeername", "bad status");
  664. --- 108,114 ----
  665.                          *osock = &out_socket;
  666.   #endif
  667.   
  668. ! #if defined(KPOP) || defined(K5POP)
  669.       i = sizeof(in_socket);
  670.       if (getpeername(0, &in_socket, &i) < 0)
  671.         padios("getpeername", "bad status");
  672. ***************
  673. *** 121,127 ****
  674.       arginit (argv);
  675.       envinit ();
  676.   
  677. ! #ifndef KPOP
  678.   #ifdef    RESTART
  679.       for (;;) {
  680.       char    reason[BUFSIZ];
  681. --- 122,128 ----
  682.       arginit (argv);
  683.       envinit ();
  684.   
  685. ! #if !defined(KPOP) && !defined(K5POP)
  686.   #ifdef    RESTART
  687.       for (;;) {
  688.       char    reason[BUFSIZ];
  689. ***************
  690. *** 192,202 ****
  691.       (void) signal (SIGCHLD, chldser);
  692.   #endif    /* SIGCHLD */
  693.       (void) listen (sd, SOMAXCONN);
  694. ! #endif /* KPOP */
  695.   #ifdef    FAST
  696.       popinit ();
  697.   #endif    /* FAST */
  698. ! #ifndef KPOP
  699.       for (;;) {
  700.       int     i = sizeof *osock;
  701.   
  702. --- 193,203 ----
  703.       (void) signal (SIGCHLD, chldser);
  704.   #endif    /* SIGCHLD */
  705.       (void) listen (sd, SOMAXCONN);
  706. ! #endif /* ! (KPOP || K5POP) */
  707.   #ifdef    FAST
  708.       popinit ();
  709.   #endif    /* FAST */
  710. ! #if !defined(KPOP) && !defined(K5POP)
  711.       for (;;) {
  712.       int     i = sizeof *osock;
  713.   
  714. ***************
  715. *** 210,216 ****
  716.   #ifdef    FAST
  717.       popassert ();
  718.   #endif    /* FAST */
  719. ! #ifndef KPOP
  720.       switch (fork ()) {
  721.           case OK: 
  722.           (void) close (sd);
  723. --- 211,217 ----
  724.   #ifdef    FAST
  725.       popassert ();
  726.   #endif    /* FAST */
  727. ! #if !defined(KPOP) && !defined(K5POP)
  728.       switch (fork ()) {
  729.           case OK: 
  730.           (void) close (sd);
  731. ***************
  732. *** 248,253 ****
  733. --- 249,268 ----
  734.       char instance[INST_SZ];
  735.       char version[9];
  736.       char user[ANAME_SZ];
  737. +     KTEXT_ST ticket;
  738. +     Key_schedule schedule;
  739. +     AUTH_DAT kdata;
  740. + #endif
  741. + #ifdef K5POP
  742. +     int retval;
  743. +     int sock = 0;
  744. +     krb5_principal server, ext_client;
  745. +     krb5_data *tmpdata;
  746. +     char user[100]; /* I can't find anywhere in the V5 sources a       */
  747. +             /* constant that sets the maximum length of a      */
  748. +             /* component in a principal. XXX I'm assuming that */
  749. +             /* there's nobody out there with a username longer */
  750. +             /* than 99 characters.  So shoot me.               */
  751.   #endif
  752.   
  753.       closelog ();
  754. ***************
  755. *** 288,296 ****
  756.         kpop (0, 1, user, (hp ? hp -> h_name : NULLCP), 0);
  757.       }
  758.   #else
  759.       pop (0, 1, sin -> sin_family == AF_INET && port < IPPORT_RESERVED && hp,
  760.           hp ? hp -> h_name : NULLCP);
  761. ! #endif
  762.   }
  763.       
  764.   /*   */
  765. --- 303,349 ----
  766.         kpop (0, 1, user, (hp ? hp -> h_name : NULLCP), 0);
  767.       }
  768.   #else
  769. + #ifdef K5POP
  770. +     krb5_init_ets();
  771. +     if (retval = krb5_sname_to_principal(myhost, "pop", KRB5_NT_SRV_HST,
  772. +                      &server)) {
  773. +     padvise(NULLCP, LOG_ERR,
  774. +         "server mis-configured, can't get principal--%s",
  775. +         error_message(retval));
  776. +     kpop(0, 1, NULLCP, NULLCP, retval);
  777. +     return;
  778. +     }
  779. +     if (retval = krb5_recvauth((krb5_pointer)&sock,
  780. +                    "KPOPV1.0",
  781. +                    server,
  782. +                    0,    /* ignore peer address */
  783. +                    0, 0, 0,    /* no fetchfrom, keyproc or arg */
  784. +                    0,    /* default rc type */
  785. +                    0,    /* don't need seq number */
  786. +                    &ext_client,
  787. +                    0, 0    /* don't care about ticket or
  788. +                        authenticator */
  789. +                    )) {
  790. +     padvise(NULLCP, LOG_INFO, "bad kerberos data, not ok'ing");
  791. +     kpop(0, 1, NULLCP, NULLCP, retval);
  792. +     return;
  793. +     }
  794. +     krb5_free_principal(server);
  795. +     tmpdata = krb5_princ_component(ext_client, 0);
  796. +     if (tmpdata->length >= sizeof(user)) {
  797. +     tmpdata->length - sizeof(user) - 1;
  798. +     }
  799. +     strncpy(user, tmpdata->data, tmpdata->length);
  800. +     user[tmpdata->length] = '\0';
  801. +     kpop(0, 1, user, (hp ? hp->h_name : NULLCP), 0);
  802. + #else
  803.       pop (0, 1, sin -> sin_family == AF_INET && port < IPPORT_RESERVED && hp,
  804.           hp ? hp -> h_name : NULLCP);
  805. ! #endif /* K5POP */
  806. ! #endif /* KPOP */
  807.   }
  808.       
  809.   /*   */
  810. ***************
  811. *** 342,348 ****
  812.   /*   */
  813.   
  814.   static  envinit () {
  815. ! #ifndef KPOP
  816.       int     i,
  817.               sd;
  818.   
  819. --- 395,401 ----
  820.   /*   */
  821.   
  822.   static  envinit () {
  823. ! #if !defined(KPOP) && !defined(K5POP)
  824.       int     i,
  825.               sd;
  826.   
  827. ***************
  828. *** 381,387 ****
  829.   
  830.       for (sd = 3; sd < nbits; sd++)
  831.       (void) close (sd);
  832. ! #endif /* KPOP */
  833.   
  834.       (void) signal (SIGPIPE, SIG_IGN);
  835.   
  836. --- 434,440 ----
  837.   
  838.       for (sd = 3; sd < nbits; sd++)
  839.       (void) close (sd);
  840. ! #endif /* ! (KPOP || K5POP) */
  841.   
  842.       (void) signal (SIGPIPE, SIG_IGN);
  843.   
  844. ***************
  845. *** 398,404 ****
  846.   
  847.   /*   */
  848.   
  849. ! #ifndef KPOP
  850.   
  851.   /* ARGSUSED */
  852.   
  853. --- 451,457 ----
  854.   
  855.   /*   */
  856.   
  857. ! #if !defined(KPOP) && !defined(K5POP)
  858.   
  859.   /* ARGSUSED */
  860.   
  861. ***************
  862. *** 420,426 ****
  863.   }
  864.   
  865.   #endif /* SIGCHLD */
  866. ! #endif /* KPOP */
  867.   
  868.   /*   */
  869.   
  870. --- 473,479 ----
  871.   }
  872.   
  873.   #endif /* SIGCHLD */
  874. ! #endif /* ! (KPOP || K5POP) */
  875.   
  876.   /*   */
  877.   
  878. *** 1.1    1992/12/31 20:29:21
  879. --- support/pop/popser.c    1992/12/31 21:04:19
  880. ***************
  881. *** 22,29 ****
  882. --- 22,38 ----
  883.   #include <sys/types.h>
  884.   #include <sys/stat.h>
  885.   #ifdef KPOP
  886. + #ifdef K5POP
  887. + "Can't use both KPOP and K5POP!"
  888. + #endif
  889.   #include <krb.h>
  890.   #endif    /* KPOP */
  891. + #ifdef K5POP
  892. + #include <krb5/krb5.h>
  893. + #include <krb5/ext-proto.h>
  894. + #include <com_err.h>
  895. + #include <ctype.h>
  896. + #endif /* K5POP */
  897.   #ifdef    SYS5
  898.   #include <fcntl.h>
  899.   #endif    /* SYS5 */
  900. ***************
  901. *** 313,319 ****
  902.   
  903.   /*   */
  904.   
  905. ! #ifdef KPOP
  906.   static char *kusername;
  907.   
  908.   kpop (in, out, principal, rhost, auth)
  909. --- 322,328 ----
  910.   
  911.   /*   */
  912.   
  913. ! #if defined(KPOP) || defined(K5POP)
  914.   static char *kusername;
  915.   
  916.   kpop (in, out, principal, rhost, auth)
  917. ***************
  918. *** 340,352 ****
  919.       mts_init (myname);
  920.   
  921.       hostname = rhost;
  922. ! #ifdef KPOP
  923.       rproto = 1;
  924.       (void) sprintf (server, "%s KPOP server", myhost);
  925.   #else
  926.       rproto = priv;
  927.       (void) sprintf (server, "%s server", priv ? "RPOP" : "POP");
  928. ! #endif    /* KPOP */
  929.   
  930.       if ((input = fdopen (in, "r")) == NULL
  931.           || (output = fdopen (out, "w")) == NULL) {/* you lose big */
  932. --- 349,361 ----
  933.       mts_init (myname);
  934.   
  935.       hostname = rhost;
  936. ! #if defined(KPOP) || defined(K5POP)
  937.       rproto = 1;
  938.       (void) sprintf (server, "%s KPOP server", myhost);
  939.   #else
  940.       rproto = priv;
  941.       (void) sprintf (server, "%s server", priv ? "RPOP" : "POP");
  942. ! #endif    /* KPOP || K5POP */
  943.   
  944.       if ((input = fdopen (in, "r")) == NULL
  945.           || (output = fdopen (out, "w")) == NULL) {/* you lose big */
  946. ***************
  947. *** 354,369 ****
  948.       return;
  949.       }
  950.       (void) signal (SIGPIPE, pipeser);
  951. ! #ifdef KPOP
  952.       if (principal == NULLCP) {
  953.       char buf[512];
  954.       strcpy(buf,  "Authentication failed: ");
  955.       strcat(buf, krb_err_txt[auth]);
  956.       (void) respond (NOTOK, buf);
  957.       return;
  958.       }
  959.       kusername = principal;
  960. ! #endif    /* KPOP */
  961.   
  962.   #ifdef    DPOP
  963.       if ((pw = getpwnam (POPUID)) == NULL || !setpwinfo (pw, POPDB, 1)) {
  964. --- 363,382 ----
  965.       return;
  966.       }
  967.       (void) signal (SIGPIPE, pipeser);
  968. ! #if defined(KPOP) || defined(K5POP)
  969.       if (principal == NULLCP) {
  970.       char buf[512];
  971.       strcpy(buf,  "Authentication failed: ");
  972. + #ifdef KPOP
  973.       strcat(buf, krb_err_txt[auth]);
  974. + #else
  975. +     strcat(buf, error_message(auth));
  976. + #endif
  977.       (void) respond (NOTOK, buf);
  978.       return;
  979.       }
  980.       kusername = principal;
  981. ! #endif    /* KPOP || K5POP */
  982.   
  983.   #ifdef    DPOP
  984.       if ((pw = getpwnam (POPUID)) == NULL || !setpwinfo (pw, POPDB, 1)) {
  985. ***************
  986. *** 425,431 ****
  987.   register char  **vec;
  988.   {
  989.       make_lower (username, vec[1]);
  990. ! #ifdef KPOP
  991.       if (!strcmp(username, kusername))
  992.         return respond (OK, "Kerberos authentication succeeded. Send username as password (%s)", username);
  993.       else {
  994. --- 438,444 ----
  995.   register char  **vec;
  996.   {
  997.       make_lower (username, vec[1]);
  998. ! #if defined(KPOP) || defined(K5POP)
  999.       if (!strcmp(username, kusername))
  1000.         return respond (OK, "Kerberos authentication succeeded. Send username as password (%s)", username);
  1001.       else {
  1002. ***************
  1003. *** 453,459 ****
  1004.       register struct bboard *pw;
  1005.   #endif    /* DPOP */
  1006.   
  1007. ! #ifdef KPOP
  1008.   #ifndef DPOP
  1009.       if ((pw = getpwnam (username)) != NULL)
  1010.         return setup(pw, FALSE);
  1011. --- 466,472 ----
  1012.       register struct bboard *pw;
  1013.   #endif    /* DPOP */
  1014.   
  1015. ! #if defined(KPOP) || defined(K5POP)
  1016.   #ifndef DPOP
  1017.       if ((pw = getpwnam (username)) != NULL)
  1018.         return setup(pw, FALSE);
  1019. ***************
  1020. *** 471,477 ****
  1021.         return setup(pw, FALSE);
  1022.       }
  1023.   #endif
  1024. ! #else    /* KPOP */
  1025.   
  1026.   #ifndef    DPOP
  1027.   #ifdef    BPOP
  1028. --- 484,490 ----
  1029.         return setup(pw, FALSE);
  1030.       }
  1031.   #endif
  1032. ! #else    /* KPOP || K5POP */
  1033.   
  1034.   #ifndef    DPOP
  1035.   #ifdef    BPOP
  1036. ***************
  1037. *** 540,546 ****
  1038.       return respond (NOTOK, "permission denied");
  1039.   #endif    /* TRUSTED */
  1040.       return setup (pw, guest);
  1041. ! #endif /* KPOP */
  1042.   }
  1043.   
  1044.   /*   */
  1045. --- 553,559 ----
  1046.       return respond (NOTOK, "permission denied");
  1047.   #endif    /* TRUSTED */
  1048.       return setup (pw, guest);
  1049. ! #endif /* KPOP || K5POP */
  1050.   }
  1051.   
  1052.   /*   */
  1053.  
  1054. -- 
  1055. Jonathan Kamens                                       jik@Aktis.COM
  1056. Aktis, Inc.                                 Moderator, news.answers
  1057.