Ticket #274: discuss-nokrb4.diff

File discuss-nokrb4.diff, 3.3 KB (added by mitchb, 15 years ago)

Patch to make the server's Kerberos authentication logic workable without krb4, and to actually use said logic

  • server/rpproc.c

    diff -ur ./server/rpproc.c ../debathena-discuss-10.0.8/server/rpproc.c
    old new  
    6464#define ERROR   -1 
    6565#define min(a, b) (a < b ? a : b) 
    6666 
     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) 
     78struct ktext { 
     79    int length; 
     80    unsigned char dat[MAX_KTXT_LEN]; 
     81    unsigned long mbz; 
     82}; 
     83typedef struct ktext KTEXT_ST; 
     84struct 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}; 
     89typedef struct partial_auth_dat AUTH_DAT; 
     90#endif /* HAVE_KRB4 */ 
     91 
    6792/* global */ 
    68 #ifdef HAVE_KRB4 
     93#if defined(HAVE_KRB4) || defined(HAVE_KRB5) 
    6994char rpc_caller[MAX_K_NAME_SZ + 1]; 
    7095#else 
    7196char rpc_caller[50]; 
    72 #endif 
     97#endif /* HAVE_KRB4 || HAVE_KRB5 */ 
    7398static long hostaddr; 
    7499 
    75100extern int numprocs; 
    76101extern struct proc_table procs []; 
    77 #ifdef HAVE_KRB4 
     102#if defined(HAVE_KRB4) || defined(HAVE_KRB5) 
    78103static char serv_name[20]; 
    79 #endif /* HAVE_KRB4 */ 
     104#endif /* HAVE_KRB4 || HAVE_KRB5 */ 
    80105short recvshort(); 
    81106int rpc_err; 
    82107extern tfile net_tfile (); 
     
    113138    int s; 
    114139#endif 
    115140     
    116 #ifdef HAVE_KRB4 
     141#if defined(HAVE_KRB4) || defined(HAVE_KRB5) 
    117142    int fromlen,i; 
    118143    struct sockaddr_in from; 
    119144    char hostname[50]; 
    120145    struct hostent *hp; 
    121146    USPCardinal bt; 
    122 #endif     
     147#endif /* HAVE_KRB4 || HAVE_KRB5 */ 
    123148 
    124149#if defined(__APPLE__) && defined(__MACH__) 
    125150    add_error_table(&et_rpc_error_table); 
     
    211236    strcat (rpc_caller, "@"); 
    212237    strcat (rpc_caller, REALM); 
    213238     
    214 #ifdef HAVE_KRB4 
     239#if defined(HAVE_KRB4) || defined(HAVE_KRB5) 
    215240 
    216241    strcpy(serv_name, service); 
    217242    fromlen = sizeof (from); 
     
    235260    } 
    236261     
    237262    handle_kerberos(bt,serv_name,hostaddr); 
    238 #endif 
     263#endif /* HAVE_KRB4 || HAVE_KRB5 */ 
    239264    *code = 0; 
    240265    return; 
    241266} 
    242267 
    243 #ifdef HAVE_KRB4 
     268#if defined(HAVE_KRB4) || defined(HAVE_KRB5) 
    244269handle_kerberos(bt,service,haddr) 
    245270USPCardinal bt; 
    246271char *service; 
     
    320345        /* First, log the krb5 error. */ 
    321346        com_err(service, result, "while reading request"); 
    322347#endif /* HAVE_KRB5 */ 
     348#ifdef HAVE_KRB4 
    323349        result = krb_rd_req (&ticket, service, instance, haddr, &kdata, 
    324350                             filename); 
    325351        if (result) { 
    326352            result += ERROR_TABLE_BASE_krb; 
    327353            goto punt_kerberos; 
    328354        } 
     355#endif /* HAVE_KRB4 */ 
    329356#ifdef HAVE_KRB5 
    330357    } 
    331358#endif /* HAVE_KRB5 */ 
     
    346373         USP_end_block(us); 
    347374    } 
    348375} 
    349 #endif /* HAVE_KRB4 */ 
     376#endif /* HAVE_KRB4 || HAVE_KRB5 */ 
    350377 
    351378/* 
    352379 * 
     
    367394        return; 
    368395    } 
    369396 
    370 #ifdef HAVE_KRB4 
     397#if defined(HAVE_KRB4) || defined(HAVE_KRB5) 
    371398    if (bt == KRB_TICKET || bt == KRB_TICKET2) { 
    372399         handle_kerberos(bt, serv_name, hostaddr); 
    373400         *code = 0; 
    374401         return; 
    375402    } 
    376 #endif /* HAVE_KRB4 */ 
     403#endif /* HAVE_KRB4 || HAVE_KRB5 */ 
    377404 
    378405    procno = bt - PROC_BASE; 
    379406