aboutsummaryrefslogtreecommitdiff
path: root/src/appl/popper/mh-6.8.patch
blob: ef4090aa23f1ce24e818b1613b2778aa06e9acc7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303

--- zotnet/mts/client.c.orig	Mon Aug 12 00:26:34 1996
+++ zotnet/mts/client.c	Mon Aug 12 01:36:12 1996
@@ -26,6 +26,22 @@
 #include <hesiod.h>
 #endif
 
+#if defined(KPOP) && defined(K5POP)
+#error "You cannot define both KPOP and K5POP"
+#endif
+#ifdef K5POP
+#include "krb5.h"
+/* #include <krb5/ext-proto.h> */
+/* #include <krb5/los-proto.h> */
+#include "com_err.h"
+#include <ctype.h>
+
+static krb5_error_code retval;
+static krb5_ccache ccdef;
+static krb5_principal kclient = NULL, kserver = NULL;
+static krb5_context context;
+#endif
+
 #ifdef KPOP
 #include <krb.h>
 #include <ctype.h>
@@ -76,6 +92,9 @@
 static struct addrent *he, *hz;
 static struct addrent hosts[MAXHOSTS];
 
+#ifdef K5POP
+static char *kservice;		/* "pop" if using kpop */
+#endif
 #ifdef KPOP
 char krb_realm[REALM_SZ];
 char *PrincipalHostname();
@@ -122,7 +141,7 @@
     register struct netent *np;
 #endif
     register struct servent *sp;
-#ifdef	KPOP
+#if	defined(KPOP) || defined(K5POP)
     char *cp;
 
     if (cp = index (kservice = service, '/')) {	/* "pop/kpop" */
@@ -131,12 +150,12 @@
     }
     else
 	kservice = NULL;	/* not using KERBEROS */
-#endif	/* KPOP */
+#endif	/* KPOP || K5POP */
     
 
     if ((sp = getservbyname (service, protocol)) == NULL) {
 #ifdef	HESIOD
-	if ((sp = hes_getservbyname (service, protocol)) == NULL) {
+	if ((sp = (struct servent *) hes_getservbyname (service, protocol)) == NULL) {
 	    (void) sprintf (response, "%s/%s: unknown service",
 		    protocol, service);
 	    return NOTOK;
@@ -219,9 +238,9 @@
     register struct addrent *ap;
     struct sockaddr_in  in_socket;
     register struct sockaddr_in *isock = &in_socket;
-#ifdef KPOP
+#if	defined(KPOP) || defined(K5POP)
     int rem;
-#endif	/* KPOP */
+#endif	/* KPOP || K5POP */
 
     for (ap = nets; ap < ne; ap++)
 	if (ap -> a_addrtype == hp -> h_addrtype && inet (hp, ap -> a_net))
@@ -265,6 +284,65 @@
 		return NOTOK;
 	}
 
+#ifdef K5POP
+    if (kservice) {	/* "pop" */
+	krb5_error *err_ret = NULL;
+	krb5_auth_context auth_context = NULL;
+
+	krb5_init_context(&context);
+	krb5_init_ets(context);
+
+	if (retval = krb5_cc_default(context, &ccdef)) {
+	    sprintf(response, "Post office refused connection: krb5_cc_default: %s",
+		    error_message(retval));
+	    close(sd);
+	    return OOPS2;
+	}
+	if (retval = krb5_cc_get_principal(context, ccdef, &kclient)) {
+	    sprintf(response, "Post office refused connection: krb5_cc_get_principal: %s",
+		    error_message(retval));
+	    close(sd);
+	    return OOPS2;
+	}
+
+	if (retval = krb5_sname_to_principal(context, hp->h_name, kservice,
+					     KRB5_NT_SRV_HST,
+					     &kserver)) {
+	    sprintf(response, "Post office refused connection: krb5_sname_to_principal: %s",
+		    error_message(retval));
+	    close(sd);
+	    return OOPS2;
+	}
+
+	retval = krb5_sendauth(context, &auth_context, (krb5_pointer) &sd,
+			   "KPOPV1.0", kclient, kserver,
+			   AP_OPTS_MUTUAL_REQUIRED,
+			   0,		/* no checksum */
+			   0,		/* no creds, use ccache instead */
+			   ccdef,
+			   &err_ret,
+			   0,
+			   0);		/* don't need reply */
+	krb5_free_principal(context, kserver);
+	if (auth_context)
+	    krb5_auth_con_free(context, auth_context);
+	if (retval) {
+	    if (err_ret && err_ret->text.length) {
+		sprintf(response, "Post office refused connection: %s [server says '%*s'] ",
+		        error_message(retval),
+		        err_ret->text.length,
+		        err_ret->text.data);
+		krb5_free_error(context, err_ret);
+	    } else
+		sprintf(response, "Post office refused connection: %s",
+		        error_message(retval));
+	    close(sd);
+	    krb5_free_context(context);
+	    return OOPS2;
+	}
+	krb5_free_context(context);
+    }
+#endif /* K5POP */
 #ifdef KPOP
     if (kservice) {	/* "pop" */
 	ticket = (KTEXT)malloc( sizeof(KTEXT_ST) );
@@ -311,10 +389,10 @@
 		: "unknown error");
 	return NOTOK;
     }
-#ifdef KPOP
+#if	defined(KPOP) || defined(K5POP)
     if (kservice)	/* "pop" */
 	return(sd);
-#endif	/* KPOP */
+#endif	/* KPOP || K5POP */
     if (!rproto)
 	return sd;
 
--- uip/popsbr.c.orig	Mon Aug 12 00:27:00 1996
+++ uip/popsbr.c	Mon Aug 12 01:20:50 1996
@@ -15,6 +15,7 @@
 #endif /* NNTP */
 #include <stdio.h>
 #include <signal.h>
+#include <errno.h>
 
 #ifndef	POPSERVICE
 #define	POPSERVICE	"pop"
@@ -144,10 +145,15 @@
 #endif	/* APOP */
 
 #ifndef NNTP
-#ifndef	KPOP
+#if	!defined(KPOP) && !defined(K5POP)
     if ((fd1 = client (host, "tcp", POPSERVICE, rpop, response)) == NOTOK)
 #else	/* KPOP */
+#ifdef K5POP
     (void) sprintf (buffer, "%s/%s", POPSERVICE, "kpop");
+#endif
+#ifdef KPOP
+    (void) sprintf (buffer, "%s/%s", POPSERVICE, "kpop");
+#endif
     if ((fd1 = client (host, "tcp", buffer, rpop, response)) == NOTOK)
 #endif
 #else	/* NNTP */
@@ -177,7 +183,7 @@
 		fprintf (stderr, "<--- %s\n", response);
 #ifndef	NNTP
 	    if (*response == '+') {
-#ifndef	KPOP
+#if	!defined(KPOP) && !defined(K5POP)
 #ifdef	APOP
 		if (apop < 0) {
 		    char   *cp = pop_auth (user, pass);
@@ -191,7 +197,7 @@
 		    && command ("%s %s", rpop ? "RPOP" : (pophack++, "PASS"),
 					pass) != NOTOK)
 		return OK;
-#else	/* KPOP */
+#else	/* KPOP || K5POP */
 		if (command ("USER %s", user) != NOTOK
 		    && command ("PASS %s", pass) != NOTOK)
 		return OK;
--- uip/inc.c.orig	Mon Aug 12 00:27:08 1996
+++ uip/inc.c	Mon Aug 12 00:28:27 1996
@@ -19,9 +19,6 @@
 #ifdef	POP
 #include "../h/dropsbr.h"
 #endif
-#ifdef KPOP
-#include <krb.h>
-#endif
 #ifdef HESIOD
 #include <hesiod.h>
 #endif
--- conf/mhconfig.c.orig	Sat Aug 10 00:13:00 1996
+++ conf/mhconfig.c	Mon Aug 12 00:28:29 1996
@@ -134,6 +134,7 @@
     "BSD43", 0,	/* sgid ttys */
     "BSD44", 0, /* manual headings */
     "KPOP", 0, 	/* KERBEROS pop */
+    "K5POP", 0, /* KERBEROS5 pop */
     "HESIOD", 0,
     "MIME", 0,	/* multi-media extensions */
     "MPOP", 0,	/* mobile pop */
--- conf/makefiles/uip.orig	Tue Nov 30 23:00:23 1993
+++ conf/makefiles/uip	Tue Aug 13 14:44:56 1996
@@ -84,6 +84,8 @@
 @BEGIN: KPOP
 KRBLIB  =       -lkrb -ldes
 @END: KPOP
+@BEGIN: K5POP
+KRBLIB  =	-lkrb5 -lcrypto -lcom_err
 @END: POP
 @BEGIN: BPOP
 PSHLIB	=	popsbr.o
@@ -328,7 +330,7 @@
 bbc:		xbbc
 
 xbbc:		bbc.o $(PSHLIB) $(LIBES) 
-		$(LD) $(LDFLAGS) -o $@ bbc.o $(PSHLIB) $(LDLIBS)
+		$(LD) $(LDFLAGS) -o $@ bbc.o $(KRBLIB) $(PSHLIB) $(LDLIBS)
 
 l-bbc:;		$(LINT) $(LFLAGS) bbc.c $(PSHLLIBS) $(LLIBS)
 
@@ -640,7 +642,7 @@
 xmhl:   	mhl.o \
 			mhlsbr.o trmsbr.o $(LIBES) 
 		$(LD) $(LDFLAGS) -o $@ mhl.o \
-			mhlsbr.o trmsbr.o $(LDLIBS) $(LDCURSES)
+			mhlsbr.o trmsbr.o $(KRBLIB) $(LDLIBS) $(LDCURSES)
 
 l-mhl:;		$(LINT) $(LFLAGS) mhl.c \
 			mhlsbr.c trmsbr.c $(LLIBS)
@@ -676,7 +678,7 @@
 
 xmhn:  		mhn.o ftpsbr.o trmsbr.o $(LIBES) 
 		$(LD) $(LDFLAGS) -o $@ mhn.o ftpsbr.o trmsbr.o \
-				$(LDLIBS) $(LDCURSES)
+				$(KRBLIB) $(LDLIBS) $(LDCURSES)
 
 l-mhn:;		$(LINT) $(LFLAGS) mhn.c ftpsbr.c trmsbr.c $(LLIBS)
 
@@ -756,7 +758,7 @@
 			$(PSHLIB) $(LIBES)
 		$(LD) $(LDFLAGS) -o $@ msh.o mshcmds.o vmhsbr.o \
 			picksbr.o scansbr.o dropsbr.o mhlsbr.o trmsbr.o \
-			$(PSHLIB) $(LDLIBS) $(LDCURSES)
+			$(PSHLIB) $(KRBLIB) $(LDLIBS) $(LDCURSES)
 
 l-msh:;		$(LINT) $(LFLAGS) msh.c mshcmds.c vmhsbr.c \
 			picksbr.c scansbr.c dropsbr.c mhlsbr.c trmsbr.c \
@@ -809,8 +811,8 @@
 popi:		xpopi
 
 xpopi:		popi.o $(POPLIB) trmsbr.o $(LIBES)
-		$(LD) $(LDFLAGS) -o $@ popi.o $(POPLIB) trmsbr.o $(LDLIBS) \
-			$(LDCURSES)
+		$(LD) $(LDFLAGS) -o $@ popi.o $(POPLIB) trmsbr.o $(KRBLIB) \
+			$(LDLIBS) $(LDCURSES)
 
 l-popi:;	$(LINT) $(LFLAGS) popi.c $(POPLLIBS) trmsbr.c $(LLIBS)
 
@@ -835,7 +837,7 @@
 
 xpost:   	post.o \
 			aliasbr.o $(MTSBRS) $(TMALIB) $(LIBES)
-		$(LD) $(LDFLAGS) -o $@ post.o \
+		$(LD) $(KRBLIB) $(LDFLAGS) -o $@ post.o \
 			aliasbr.o $(MTSBRS) $(TMALIB) $(LDLIBS)
 
 l-post:;	$(LINT) $(LFLAGS) post.c \
@@ -1096,7 +1098,7 @@
 xshow:		show.o \
 			mhlsbr.o trmsbr.o $(LIBES) 
 		$(LD) $(LDFLAGS) -o $@ show.o \
-			mhlsbr.o trmsbr.o $(LDLIBS) $(LDCURSES)
+			mhlsbr.o trmsbr.o $(KRBLIB) $(LDLIBS) $(LDCURSES)
 
 l-show:;	$(LINT) $(LFLAGS) show.c \
 			mhlsbr.c trmsbr.c $(LLIBS)
@@ -1121,7 +1123,7 @@
 sbboards:	xsbboards
 
 xsbboards:	sbboards.o dropsbr.o $(LIBES)
-		$(LD) $(LDFLAGS) -o $@ sbboards.o dropsbr.o $(LDLIBS)
+		$(LD) $(LDFLAGS) -o $@ sbboards.o dropsbr.o $(KRBLIB) $(LDLIBS)
 
 l-sbboards:;	$(LINT) $(LFLAGS) sbboards.c dropsbr.c $(LLIBS)