Ticket #10: krb5-clients-darwin.patch

File krb5-clients-darwin.patch, 8.8 kB (added by quentin, 16 years ago)

Patch to allow building krb5-clients on Darwin

  • krb5-1.6.3/src/appl/bsd/Makefile.in

    old new  
    33mydir=. 
    44BUILDTOP=$(REL)..$(S).. 
    55LOCALINCLUDES=@KRB4_INCLUDES@ 
    6 PROG_LIBPATH=-L$(TOPLIBD) 
     6PROG_LIBPATH= 
    77PROG_RPATH=$(KRB5_LIBDIR) 
    88 
    99SETENVSRC=@SETENVSRC@ 
  • krb5-1.6.3/src/appl/bsd/kcmd.c

    old new  
    382382    return 0; 
    383383} 
    384384 
     385#define SOCKET int 
     386#define SOCKET_ERRNO errno 
     387#define SOCKET_EINTR EINTR 
     388#define SOCKET_READ(a,b,c) read(a,b,c) 
     389#define SOCKET_WRITE(a,b,c) write(a,b,c) 
     390#define krb5_xfree(a) free((char*)(a)) 
     391/* 
     392 * lib/krb5/os/net_read.c 
     393 * 
     394 * Copyright 1987, 1988, 1990 by the Massachusetts Institute of Technology. 
     395 * All Rights Reserved. 
     396 * 
     397 * Export of this software from the United States of America may 
     398 *   require a specific license from the United States Government. 
     399 *   It is the responsibility of any person or organization contemplating 
     400 *   export to obtain such a license before exporting. 
     401 *  
     402 * WITHIN THAT CONSTRAINT, permission to use, copy, modify, and 
     403 * distribute this software and its documentation for any purpose and 
     404 * without fee is hereby granted, provided that the above copyright 
     405 * notice appear in all copies and that both that copyright notice and 
     406 * this permission notice appear in supporting documentation, and that 
     407 * the name of M.I.T. not be used in advertising or publicity pertaining 
     408 * to distribution of the software without specific, written prior 
     409 * permission.  Furthermore if you modify this software you must label 
     410 * your software as modified software and not distribute it in such a 
     411 * fashion that it might be confused with the original M.I.T. software. 
     412 * M.I.T. makes no representations about the suitability of 
     413 * this software for any purpose.  It is provided "as is" without express 
     414 * or implied warranty. 
     415 *  
     416 */ 
     417 
     418/* 
     419 * krb5_net_read() reads from the file descriptor "fd" to the buffer 
     420 * "buf", until either 1) "len" bytes have been read or 2) cannot 
     421 * read anymore from "fd".  It returns the number of bytes read 
     422 * or a read() error.  (The calling interface is identical to 
     423 * read(2).) 
     424 * 
     425 * XXX must not use non-blocking I/O 
     426 */ 
     427 
     428int 
     429krb5_net_read(krb5_context context, int fd, register char *buf, register int len) 
     430{ 
     431    int cc, len2 = 0; 
     432 
     433    do { 
     434        cc = SOCKET_READ((SOCKET)fd, buf, len); 
     435        if (cc < 0) { 
     436            if (SOCKET_ERRNO == SOCKET_EINTR) 
     437                continue; 
     438                 
     439                /* XXX this interface sucks! */ 
     440        errno = SOCKET_ERRNO;     
     441                
     442            return(cc);          /* errno is already set */ 
     443        }                
     444        else if (cc == 0) { 
     445            return(len2); 
     446        } else { 
     447            buf += cc; 
     448            len2 += cc; 
     449            len -= cc; 
     450        } 
     451    } while (len > 0); 
     452    return(len2); 
     453} 
     454/* 
     455 * lib/krb5/os/net_write.c 
     456 * 
     457 * Copyright 1987, 1988, 1990 by the Massachusetts Institute of Technology. 
     458 * All Rights Reserved. 
     459 * 
     460 * Export of this software from the United States of America may 
     461 *   require a specific license from the United States Government. 
     462 *   It is the responsibility of any person or organization contemplating 
     463 *   export to obtain such a license before exporting. 
     464 *  
     465 * WITHIN THAT CONSTRAINT, permission to use, copy, modify, and 
     466 * distribute this software and its documentation for any purpose and 
     467 * without fee is hereby granted, provided that the above copyright 
     468 * notice appear in all copies and that both that copyright notice and 
     469 * this permission notice appear in supporting documentation, and that 
     470 * the name of M.I.T. not be used in advertising or publicity pertaining 
     471 * to distribution of the software without specific, written prior 
     472 * permission.  Furthermore if you modify this software you must label 
     473 * your software as modified software and not distribute it in such a 
     474 * fashion that it might be confused with the original M.I.T. software. 
     475 * M.I.T. makes no representations about the suitability of 
     476 * this software for any purpose.  It is provided "as is" without express 
     477 * or implied warranty. 
     478 *  
     479 */ 
     480 
     481/* 
     482 * krb5_net_write() writes "len" bytes from "buf" to the file 
     483 * descriptor "fd".  It returns the number of bytes written or 
     484 * a write() error.  (The calling interface is identical to 
     485 * write(2).) 
     486 * 
     487 * XXX must not use non-blocking I/O 
     488 */ 
     489 
     490int 
     491krb5_net_write(krb5_context context, int fd, register const char *buf, int len) 
     492{ 
     493    int cc; 
     494    register int wrlen = len; 
     495    do { 
     496        cc = SOCKET_WRITE((SOCKET)fd, buf, wrlen); 
     497        if (cc < 0) { 
     498            if (SOCKET_ERRNO == SOCKET_EINTR) 
     499                continue; 
     500 
     501                /* XXX this interface sucks! */ 
     502        errno = SOCKET_ERRNO;            
     503 
     504            return(cc); 
     505        } 
     506        else { 
     507            buf += cc; 
     508            wrlen -= cc; 
     509        } 
     510    } while (wrlen > 0); 
     511    return(len); 
     512} 
     513/* 
     514 * lib/krb5/os/read_msg.c 
     515 * 
     516 * Copyright 1991 by the Massachusetts Institute of Technology. 
     517 * All Rights Reserved. 
     518 * 
     519 * Export of this software from the United States of America may 
     520 *   require a specific license from the United States Government. 
     521 *   It is the responsibility of any person or organization contemplating 
     522 *   export to obtain such a license before exporting. 
     523 *  
     524 * WITHIN THAT CONSTRAINT, permission to use, copy, modify, and 
     525 * distribute this software and its documentation for any purpose and 
     526 * without fee is hereby granted, provided that the above copyright 
     527 * notice appear in all copies and that both that copyright notice and 
     528 * this permission notice appear in supporting documentation, and that 
     529 * the name of M.I.T. not be used in advertising or publicity pertaining 
     530 * to distribution of the software without specific, written prior 
     531 * permission.  Furthermore if you modify this software you must label 
     532 * your software as modified software and not distribute it in such a 
     533 * fashion that it might be confused with the original M.I.T. software. 
     534 * M.I.T. makes no representations about the suitability of 
     535 * this software for any purpose.  It is provided "as is" without express 
     536 * or implied warranty. 
     537 *  
     538 * 
     539 * Write a message to the network 
     540 */ 
     541 
     542krb5_error_code 
     543krb5_read_message(krb5_context context, krb5_pointer fdp, krb5_data *inbuf) 
     544{ 
     545        krb5_int32      len; 
     546        int             len2, ilen; 
     547        char            *buf = NULL; 
     548        int             fd = *( (int *) fdp); 
     549         
     550        if ((len2 = krb5_net_read(context, fd, (char *)&len, 4)) != 4) 
     551                return((len2 < 0) ? errno : ECONNABORTED); 
     552        len = ntohl(len); 
     553 
     554        if ((len & VALID_UINT_BITS) != len)  /* Overflow size_t??? */ 
     555                return ENOMEM; 
     556 
     557        inbuf->length = ilen = (int) len; 
     558        if (ilen) { 
     559                /* 
     560                 * We may want to include a sanity check here someday.... 
     561                 */ 
     562                if (!(buf = malloc(ilen))) { 
     563                        return(ENOMEM); 
     564                } 
     565                if ((len2 = krb5_net_read(context, fd, buf, ilen)) != ilen) { 
     566                        krb5_xfree(buf); 
     567                        return((len2 < 0) ? errno : ECONNABORTED); 
     568                } 
     569        } 
     570        inbuf->data = buf; 
     571        return(0); 
     572} 
     573/* 
     574 * lib/krb5/os/write_msg.c 
     575 * 
     576 * Copyright 1991 by the Massachusetts Institute of Technology. 
     577 * All Rights Reserved. 
     578 * 
     579 * Export of this software from the United States of America may 
     580 *   require a specific license from the United States Government. 
     581 *   It is the responsibility of any person or organization contemplating 
     582 *   export to obtain such a license before exporting. 
     583 *  
     584 * WITHIN THAT CONSTRAINT, permission to use, copy, modify, and 
     585 * distribute this software and its documentation for any purpose and 
     586 * without fee is hereby granted, provided that the above copyright 
     587 * notice appear in all copies and that both that copyright notice and 
     588 * this permission notice appear in supporting documentation, and that 
     589 * the name of M.I.T. not be used in advertising or publicity pertaining 
     590 * to distribution of the software without specific, written prior 
     591 * permission.  Furthermore if you modify this software you must label 
     592 * your software as modified software and not distribute it in such a 
     593 * fashion that it might be confused with the original M.I.T. software. 
     594 * M.I.T. makes no representations about the suitability of 
     595 * this software for any purpose.  It is provided "as is" without express 
     596 * or implied warranty. 
     597 *  
     598 * 
     599 * convenience sendauth/recvauth functions 
     600 */ 
     601 
     602krb5_error_code 
     603krb5_write_message(krb5_context context, krb5_pointer fdp, krb5_data *outbuf) 
     604{ 
     605        krb5_int32      len; 
     606        int             fd = *( (int *) fdp); 
     607 
     608        len = htonl(outbuf->length); 
     609        if (krb5_net_write(context, fd, (char *)&len, 4) < 0) { 
     610                return(errno); 
     611        } 
     612        if (outbuf->length && (krb5_net_write(context, fd, outbuf->data, outbuf->length) < 0)) { 
     613                return(errno); 
     614        } 
     615        return(0); 
     616} 
     617 
     618 
    385619int 
    386620kcmd(sock, ahost, rport, locuser, remuser, cmd, fd2p, service, realm, 
    387621     cred, seqno, server_seqno, laddr, faddr, authconp, authopts, anyport,