The following patch contains source code copied from the MIT Kerberos distribution. This source provides definitions of krb5_read_message and krb5_write_message, functions which are used by LPRng's Kerberos authentication code but which are private to the Kerberos library and thus not available on MacOS X platforms. This patch was written against LPRng 3.8.28, but since it is a single hunk inserted near the top of the file it shouldn't be very difficult to merge in by hand should it reject. Hopefully in the future the LPRng authors will correct their own code and stop using these private Kerberos functions. --- LPRng-3.8.28/src/common/krb5_auth.c 2004-09-24 16:19:57.000000000 -0400 +++ LPRng-3.8.28-spearce/src/common/krb5_auth.c 2005-08-25 20:40:24.000000000 -0400 @@ -61,6 +61,239 @@ KRB5_PROTOTYPE((krb5_context, krb5_pointer, krb5_data *)); + +#define SOCKET int +#define SOCKET_ERRNO errno +#define SOCKET_EINTR EINTR +#define SOCKET_READ(a,b,c) read(a,b,c) +#define SOCKET_WRITE(a,b,c) write(a,b,c) +#define krb5_xfree(a) free((char*)(a)) +/* + * lib/krb5/os/net_read.c + * + * Copyright 1987, 1988, 1990 by the Massachusetts Institute of Technology. + * All Rights Reserved. + * + * Export of this software from the United States of America may + * require a specific license from the United States Government. + * It is the responsibility of any person or organization contemplating + * export to obtain such a license before exporting. + * + * WITHIN THAT CONSTRAINT, permission to use, copy, modify, and + * distribute this software and its documentation for any purpose and + * without fee is hereby granted, provided that the above copyright + * notice appear in all copies and that both that copyright notice and + * this permission notice appear in supporting documentation, and that + * the name of M.I.T. not be used in advertising or publicity pertaining + * to distribution of the software without specific, written prior + * permission. Furthermore if you modify this software you must label + * your software as modified software and not distribute it in such a + * fashion that it might be confused with the original M.I.T. software. + * M.I.T. makes no representations about the suitability of + * this software for any purpose. It is provided "as is" without express + * or implied warranty. + * + */ + +/* + * krb5_net_read() reads from the file descriptor "fd" to the buffer + * "buf", until either 1) "len" bytes have been read or 2) cannot + * read anymore from "fd". It returns the number of bytes read + * or a read() error. (The calling interface is identical to + * read(2).) + * + * XXX must not use non-blocking I/O + */ + +int +krb5_net_read(krb5_context context, int fd, register char *buf, register int len) +{ + int cc, len2 = 0; + + do { + cc = SOCKET_READ((SOCKET)fd, buf, len); + if (cc < 0) { + if (SOCKET_ERRNO == SOCKET_EINTR) + continue; + + /* XXX this interface sucks! */ + errno = SOCKET_ERRNO; + + return(cc); /* errno is already set */ + } + else if (cc == 0) { + return(len2); + } else { + buf += cc; + len2 += cc; + len -= cc; + } + } while (len > 0); + return(len2); +} +/* + * lib/krb5/os/net_write.c + * + * Copyright 1987, 1988, 1990 by the Massachusetts Institute of Technology. + * All Rights Reserved. + * + * Export of this software from the United States of America may + * require a specific license from the United States Government. + * It is the responsibility of any person or organization contemplating + * export to obtain such a license before exporting. + * + * WITHIN THAT CONSTRAINT, permission to use, copy, modify, and + * distribute this software and its documentation for any purpose and + * without fee is hereby granted, provided that the above copyright + * notice appear in all copies and that both that copyright notice and + * this permission notice appear in supporting documentation, and that + * the name of M.I.T. not be used in advertising or publicity pertaining + * to distribution of the software without specific, written prior + * permission. Furthermore if you modify this software you must label + * your software as modified software and not distribute it in such a + * fashion that it might be confused with the original M.I.T. software. + * M.I.T. makes no representations about the suitability of + * this software for any purpose. It is provided "as is" without express + * or implied warranty. + * + */ + +/* + * krb5_net_write() writes "len" bytes from "buf" to the file + * descriptor "fd". It returns the number of bytes written or + * a write() error. (The calling interface is identical to + * write(2).) + * + * XXX must not use non-blocking I/O + */ + +int +krb5_net_write(krb5_context context, int fd, register const char *buf, int len) +{ + int cc; + register int wrlen = len; + do { + cc = SOCKET_WRITE((SOCKET)fd, buf, wrlen); + if (cc < 0) { + if (SOCKET_ERRNO == SOCKET_EINTR) + continue; + + /* XXX this interface sucks! */ + errno = SOCKET_ERRNO; + + return(cc); + } + else { + buf += cc; + wrlen -= cc; + } + } while (wrlen > 0); + return(len); +} +/* + * lib/krb5/os/read_msg.c + * + * Copyright 1991 by the Massachusetts Institute of Technology. + * All Rights Reserved. + * + * Export of this software from the United States of America may + * require a specific license from the United States Government. + * It is the responsibility of any person or organization contemplating + * export to obtain such a license before exporting. + * + * WITHIN THAT CONSTRAINT, permission to use, copy, modify, and + * distribute this software and its documentation for any purpose and + * without fee is hereby granted, provided that the above copyright + * notice appear in all copies and that both that copyright notice and + * this permission notice appear in supporting documentation, and that + * the name of M.I.T. not be used in advertising or publicity pertaining + * to distribution of the software without specific, written prior + * permission. Furthermore if you modify this software you must label + * your software as modified software and not distribute it in such a + * fashion that it might be confused with the original M.I.T. software. + * M.I.T. makes no representations about the suitability of + * this software for any purpose. It is provided "as is" without express + * or implied warranty. + * + * + * Write a message to the network + */ + +krb5_error_code +krb5_read_message(krb5_context context, krb5_pointer fdp, krb5_data *inbuf) +{ + krb5_int32 len; + int len2, ilen; + char *buf = NULL; + int fd = *( (int *) fdp); + + if ((len2 = krb5_net_read(context, fd, (char *)&len, 4)) != 4) + return((len2 < 0) ? errno : ECONNABORTED); + len = ntohl(len); + + if ((len & VALID_UINT_BITS) != len) /* Overflow size_t??? */ + return ENOMEM; + + inbuf->length = ilen = (int) len; + if (ilen) { + /* + * We may want to include a sanity check here someday.... + */ + if (!(buf = malloc(ilen))) { + return(ENOMEM); + } + if ((len2 = krb5_net_read(context, fd, buf, ilen)) != ilen) { + krb5_xfree(buf); + return((len2 < 0) ? errno : ECONNABORTED); + } + } + inbuf->data = buf; + return(0); +} +/* + * lib/krb5/os/write_msg.c + * + * Copyright 1991 by the Massachusetts Institute of Technology. + * All Rights Reserved. + * + * Export of this software from the United States of America may + * require a specific license from the United States Government. + * It is the responsibility of any person or organization contemplating + * export to obtain such a license before exporting. + * + * WITHIN THAT CONSTRAINT, permission to use, copy, modify, and + * distribute this software and its documentation for any purpose and + * without fee is hereby granted, provided that the above copyright + * notice appear in all copies and that both that copyright notice and + * this permission notice appear in supporting documentation, and that + * the name of M.I.T. not be used in advertising or publicity pertaining + * to distribution of the software without specific, written prior + * permission. Furthermore if you modify this software you must label + * your software as modified software and not distribute it in such a + * fashion that it might be confused with the original M.I.T. software. + * M.I.T. makes no representations about the suitability of + * this software for any purpose. It is provided "as is" without express + * or implied warranty. + * + * + * convenience sendauth/recvauth functions + */ + +krb5_error_code +krb5_write_message(krb5_context context, krb5_pointer fdp, krb5_data *outbuf) +{ + krb5_int32 len; + int fd = *( (int *) fdp); + + len = htonl(outbuf->length); + if (krb5_net_write(context, fd, (char *)&len, 4) < 0) { + return(errno); + } + if (outbuf->length && (krb5_net_write(context, fd, outbuf->data, outbuf->length) < 0)) { + return(errno); + } + return(0); +} /* * server_krb5_auth( * char *keytabfile, server key tab file - /etc/lpr.keytab --- LPRng-3.8.28/configure 2004-09-24 16:16:30.000000000 -0400 +++ LPRng-3.8.28-spearce/configure 2005-08-25 19:03:48.000000000 -0400 @@ -18816,7 +18816,7 @@ int main () { -krb5_read_message (); +/* krb5_read_message (); */ ; return 0; } @@ -18910,7 +18910,7 @@ int main () { -krb5_read_message (); +/* krb5_read_message (); */ ; return 0; } --- LPRng-3.8.28/src/common/proctitle.c 2008-03-07 17:13:03.000000000 -0500 +++ LPRng-3.8.28-broder/src/common/proctitle.c 2008-03-07 17:19:05.000000000 -0500 @@ -174,7 +174,7 @@ # endif # if SPT_TYPE == SPT_PSSTRINGS # include -# include +//# include # ifndef PS_STRINGS /* hmmmm.... apparently not available after all */ # undef SPT_TYPE # define SPT_TYPE SPT_REUSEARGV --- LPRng-3.8.28/src/common/lpc.c 2008-03-07 19:44:31.000000000 -0500 +++ LPRng-3.8.28-broder/src/common/lpc.c 2008-03-07 19:44:18.000000000 -0500 @@ -352,7 +352,10 @@ Full_user_perms(); /* this would now be the same as executing LPQ as user */ close_on_exec(3); - execvp( args->list[0],args->list ); + if (action==OP_LPQ) + execvp("mit-lpq" ,args->list); + else + execvp("mit-lprm", args->list); DIEMSG( _("execvp failed - '%s'"), Errormsg(errno) ); exit(0); } else if( pid < 0 ) {