diff -ur ./server/rpproc.c ../debathena-discuss-10.0.8/server/rpproc.c
old
|
new
|
|
64 | 64 | #define ERROR -1 |
65 | 65 | #define min(a, b) (a < b ? a : b) |
66 | 66 | |
| 67 | /* When both krb4 and krb5 are available, the server will try to |
| 68 | * authenticate clients with krb5 and then fall back to krb4. To |
| 69 | * avoid writing entirely separate code for the case where krb4 is |
| 70 | * not available, we fake some of the constants and data structures. |
| 71 | */ |
| 72 | #ifndef HAVE_KRB4 |
| 73 | #define ANAME_SZ 40 |
| 74 | #define REALM_SZ 40 |
| 75 | #define INST_SZ 40 |
| 76 | #define MAX_KTXT_LEN 1250 |
| 77 | #define MAX_K_NAME_SZ (ANAME_SZ + INST_SZ + REALM_SZ + 2) |
| 78 | struct ktext { |
| 79 | int length; |
| 80 | unsigned char dat[MAX_KTXT_LEN]; |
| 81 | unsigned long mbz; |
| 82 | }; |
| 83 | typedef struct ktext KTEXT_ST; |
| 84 | struct partial_auth_dat { /* Just enough of the struct for our purposes */ |
| 85 | char pname[ANAME_SZ]; |
| 86 | char pinst[INST_SZ]; |
| 87 | char prealm[REALM_SZ]; |
| 88 | }; |
| 89 | typedef struct partial_auth_dat AUTH_DAT; |
| 90 | #endif /* HAVE_KRB4 */ |
| 91 | |
67 | 92 | /* global */ |
68 | | #ifdef HAVE_KRB4 |
| 93 | #if defined(HAVE_KRB4) || defined(HAVE_KRB5) |
69 | 94 | char rpc_caller[MAX_K_NAME_SZ + 1]; |
70 | 95 | #else |
71 | 96 | char rpc_caller[50]; |
72 | | #endif |
| 97 | #endif /* HAVE_KRB4 || HAVE_KRB5 */ |
73 | 98 | static long hostaddr; |
74 | 99 | |
75 | 100 | extern int numprocs; |
76 | 101 | extern struct proc_table procs []; |
77 | | #ifdef HAVE_KRB4 |
| 102 | #if defined(HAVE_KRB4) || defined(HAVE_KRB5) |
78 | 103 | static char serv_name[20]; |
79 | | #endif /* HAVE_KRB4 */ |
| 104 | #endif /* HAVE_KRB4 || HAVE_KRB5 */ |
80 | 105 | short recvshort(); |
81 | 106 | int rpc_err; |
82 | 107 | extern tfile net_tfile (); |
… |
… |
|
113 | 138 | int s; |
114 | 139 | #endif |
115 | 140 | |
116 | | #ifdef HAVE_KRB4 |
| 141 | #if defined(HAVE_KRB4) || defined(HAVE_KRB5) |
117 | 142 | int fromlen,i; |
118 | 143 | struct sockaddr_in from; |
119 | 144 | char hostname[50]; |
120 | 145 | struct hostent *hp; |
121 | 146 | USPCardinal bt; |
122 | | #endif |
| 147 | #endif /* HAVE_KRB4 || HAVE_KRB5 */ |
123 | 148 | |
124 | 149 | #if defined(__APPLE__) && defined(__MACH__) |
125 | 150 | add_error_table(&et_rpc_error_table); |
… |
… |
|
211 | 236 | strcat (rpc_caller, "@"); |
212 | 237 | strcat (rpc_caller, REALM); |
213 | 238 | |
214 | | #ifdef HAVE_KRB4 |
| 239 | #if defined(HAVE_KRB4) || defined(HAVE_KRB5) |
215 | 240 | |
216 | 241 | strcpy(serv_name, service); |
217 | 242 | fromlen = sizeof (from); |
… |
… |
|
235 | 260 | } |
236 | 261 | |
237 | 262 | handle_kerberos(bt,serv_name,hostaddr); |
238 | | #endif |
| 263 | #endif /* HAVE_KRB4 || HAVE_KRB5 */ |
239 | 264 | *code = 0; |
240 | 265 | return; |
241 | 266 | } |
242 | 267 | |
243 | | #ifdef HAVE_KRB4 |
| 268 | #if defined(HAVE_KRB4) || defined(HAVE_KRB5) |
244 | 269 | handle_kerberos(bt,service,haddr) |
245 | 270 | USPCardinal bt; |
246 | 271 | char *service; |
… |
… |
|
320 | 345 | /* First, log the krb5 error. */ |
321 | 346 | com_err(service, result, "while reading request"); |
322 | 347 | #endif /* HAVE_KRB5 */ |
| 348 | #ifdef HAVE_KRB4 |
323 | 349 | result = krb_rd_req (&ticket, service, instance, haddr, &kdata, |
324 | 350 | filename); |
325 | 351 | if (result) { |
326 | 352 | result += ERROR_TABLE_BASE_krb; |
327 | 353 | goto punt_kerberos; |
328 | 354 | } |
| 355 | #endif /* HAVE_KRB4 */ |
329 | 356 | #ifdef HAVE_KRB5 |
330 | 357 | } |
331 | 358 | #endif /* HAVE_KRB5 */ |
… |
… |
|
346 | 373 | USP_end_block(us); |
347 | 374 | } |
348 | 375 | } |
349 | | #endif /* HAVE_KRB4 */ |
| 376 | #endif /* HAVE_KRB4 || HAVE_KRB5 */ |
350 | 377 | |
351 | 378 | /* |
352 | 379 | * |
… |
… |
|
367 | 394 | return; |
368 | 395 | } |
369 | 396 | |
370 | | #ifdef HAVE_KRB4 |
| 397 | #if defined(HAVE_KRB4) || defined(HAVE_KRB5) |
371 | 398 | if (bt == KRB_TICKET || bt == KRB_TICKET2) { |
372 | 399 | handle_kerberos(bt, serv_name, hostaddr); |
373 | 400 | *code = 0; |
374 | 401 | return; |
375 | 402 | } |
376 | | #endif /* HAVE_KRB4 */ |
| 403 | #endif /* HAVE_KRB4 || HAVE_KRB5 */ |
377 | 404 | |
378 | 405 | procno = bt - PROC_BASE; |
379 | 406 | |