diff options
author | Greg Hudson <ghudson@mit.edu> | 1997-09-14 17:50:06 +0000 |
---|---|---|
committer | Greg Hudson <ghudson@mit.edu> | 1997-09-14 17:50:06 +0000 |
commit | ac16f380e349fa39ec7e26bccb5456cb300006a5 (patch) | |
tree | c07ca88af97b4f6b77d28a2dc723d2e4621ed302 /lib | |
parent | d33e482744fad80d95cdd89ed380c5b8401e49bf (diff) |
Pull in sources from zephyr locker. See /mit/zephyr/repository for
detailed change information.
Diffstat (limited to 'lib')
61 files changed, 624 insertions, 2323 deletions
diff --git a/lib/Imakefile b/lib/Imakefile deleted file mode 100644 index 6dbe246..0000000 --- a/lib/Imakefile +++ /dev/null @@ -1,133 +0,0 @@ -/**/# Copyright 1988, 1993 Massachusetts Institute of Technology. -/**/# -/**/# For copying and distribution information, see the file -/**/# "mit-copyright.h". -/**/# -/**/# $Id$ - -#ifdef KERBEROS -K_O = krb_err.o ZFmtAuth.o -K_C = krb_err.c ZFmtAuth.c -#endif - -OBJS = ${K_O} \ - zephyr_err.o \ - ZAsyncLocate.o \ - ZCkAuth.o \ - ZCkIfNot.o \ - ZClosePort.o \ - ZCmpUID.o \ - ZCmpUIDP.o \ - ZFlsLocs.o \ - ZFlsSubs.o \ - ZFmtList.o \ - ZFmtNotice.o \ - ZFmtRaw.o \ - ZFmtRawLst.o \ - ZFmtSmRLst.o \ - ZFmtSmRaw.o \ - ZFreeNot.o \ - ZGetLocs.o \ - ZGetSender.o \ - ZGetSubs.o \ - ZGetWGPort.o \ - ZIfNotice.o \ - ZInit.o \ - ZLocations.o \ - ZMakeAscii.o \ - ZMkAuth.o \ - ZNewLocU.o \ - ZOpenPort.o \ - ZParseNot.o \ - ZPeekIfNot.o \ - ZPeekNot.o \ - ZPeekPkt.o \ - ZPending.o \ - ZReadAscii.o \ - ZRecvNot.o \ - ZRecvPkt.o \ - ZRetSubs.o \ - ZSendList.o \ - ZSendNot.o \ - ZSendPkt.o \ - ZSendRaw.o \ - ZSendRLst.o \ - ZSetDest.o \ - ZSetFD.o \ - ZSetSrv.o \ - ZSubs.o \ - ZVariables.o \ - ZWait4Not.o \ - Zinternal.o \ - acl_files.o - -SRCS = ${K_C} \ - zephyr_err.c \ - ZAsyncLocate.c \ - ZCkAuth.c \ - ZCkIfNot.c \ - ZClosePort.c \ - ZCmpUID.c \ - ZCmpUIDP.c \ - ZFlsLocs.c \ - ZFlsSubs.c \ - ZFmtList.c \ - ZFmtNotice.c \ - ZFmtRaw.c \ - ZFmtRawLst.c \ - ZFmtSmRLst.c \ - ZFmtSmRaw.c \ - ZFreeNot.c \ - ZGetLocs.c \ - ZGetSender.c \ - ZGetSubs.c \ - ZGetWGPort.c \ - ZIfNotice.c \ - ZInit.c \ - ZLocations.c \ - ZMakeAscii.c \ - ZMkAuth.c \ - ZNewLocU.c \ - ZOpenPort.c \ - ZParseNot.c \ - ZPeekIfNot.c \ - ZPeekNot.c \ - ZPeekPkt.c \ - ZPending.c \ - ZReadAscii.c \ - ZRecvNot.c \ - ZRecvPkt.c \ - ZRetSubs.c \ - ZSendList.c \ - ZSendNot.c \ - ZSendPkt.c \ - ZSendRaw.c \ - ZSendRLst.c \ - ZSetDest.c \ - ZSetFD.c \ - ZSetSrv.c \ - ZSubs.c \ - ZVariables.c \ - ZWait4Not.c \ - Zinternal.c \ - acl_files.c - -SimpleLibrary(zephyr,$(OBJS),$(ATHLIBDIR)) -create_depend($(SRCS)) - -install_man(zephyr.1,zephyr.1) - -make_err(zephyr_err) - -#ifdef KERBEROS -make_err(krb_err) -install_file($(BINC)/zephyr/krb_err.h,$(ZINCDIR)/krb_err.h) -#endif - -create_dir($(ZINCDIR)) -install_file($(BINC)/zephyr/zephyr.h,$(ZINCDIR)/zephyr.h) -install_file($(BINC)/zephyr/zephyr_conf.h,$(ZINCDIR)/zephyr_conf.h) -install_file($(BINC)/zephyr/zephyr_paths.h,$(ZINCDIR)/zephyr_paths.h) -install_file($(BINC)/zephyr/zephyr_internal.h,$(ZINCDIR)/zephyr_internal.h) -install_file($(BINC)/zephyr/zephyr_err.h,$(ZINCDIR)/zephyr_err.h) -install_file($(BINC)/zephyr/mit-copyright.h,$(ZINCDIR)/mit-copyright.h) diff --git a/lib/Makefile.in b/lib/Makefile.in new file mode 100644 index 0000000..294c8d0 --- /dev/null +++ b/lib/Makefile.in @@ -0,0 +1,61 @@ +SHELL = /bin/sh + +prefix=@prefix@ +exec_prefix=@exec_prefix@ +datadir=@datadir@ +confdir=@confdir@ +sbindir=@sbindir@ +lsbindir=@lsbindir@ + +includedir=${prefix}/include +mandir=${prefix}/man +libdir=${exec_prefix}/lib + +srcdir=@srcdir@ +top_srcdir=@top_srcdir@ +BUILDTOP=../.. +VPATH=@srcdir@ +CC=@CC@ +INSTALL=@INSTALL@ +RANLIB=@RANLIB@ +COMPILE_ET=@COMPILE_ET@ + +DEBUG=-O +CFLAGS=${DEBUG} -DCONFDIR=\"${confdir}\" -I${top_srcdir}/h \ + -I${BUILDTOP}/h @CPPFLAGS@ + +OBJS = zephyr_err.o ZAsyncLocate.o ZCkAuth.o ZCkIfNot.o ZClosePort.o \ + ZCmpUID.o ZCmpUIDP.o ZFlsLocs.o ZFlsSubs.o ZFmtAuth.o ZFmtList.o \ + ZFmtNotice.o ZFmtRaw.o ZFmtRawLst.o ZFmtSmRLst.o ZFmtSmRaw.o \ + ZFreeNot.o ZGetLocs.o ZGetSender.o ZGetSubs.o ZGetWGPort.o ZhmStat.o \ + ZIfNotice.o ZInit.o ZLocations.o ZMakeAscii.o ZMkAuth.o ZNewLocU.o \ + ZOpenPort.o ZParseNot.o ZPeekIfNot.o ZPeekNot.o ZPeekPkt.o ZPending.o \ + ZReadAscii.o ZRecvNot.o ZRecvPkt.o ZRetSubs.o ZSendList.o ZSendNot.o \ + ZSendPkt.o ZSendRaw.o ZSendRLst.o ZSetDest.o ZSetFD.o ZSetSrv.o \ + ZSubs.o ZVariables.o ZWait4Not.o Zinternal.o + +all: libzephyr.a + +libzephyr.a: ${OBJS} + ar cru $@ ${OBJS} + ${RANLIB} $@ + +zephyr_err.c ${BUILDTOP}/h/zephyr/zephyr_err.h: zephyr_err.et + ${COMPILE_ET} ${srcdir}/zephyr_err.et + mv zephyr_err.h ${BUILDTOP}/h/zephyr + +check: + +install: libzephyr.a + ${INSTALL} -m 644 libzephyr.a ${DESTDIR}${libdir} + ${INSTALL} -m 644 ${srcdir}/zephyr.1 ${DESTDIR}${mandir}/man1 + +clean: + rm -f ${OBJS} libzephyr.a zephyr_err.c zephyr_err.h + +${OBJS}: ${top_srcdir}/h/internal.h ${top_srcdir}/h/sysdep.h +${OBJS}: ${BUILDTOP}/h/config.h ${BUILDTOP}/h/zephyr/zephyr.h +${OBJS}: ${BUILDTOP}/h/zephyr/zephyr_err.h + +.PHONY: all check install clean + diff --git a/lib/ZAsyncLocate.c b/lib/ZAsyncLocate.c index 37f61fa..78b3f2a 100644 --- a/lib/ZAsyncLocate.c +++ b/lib/ZAsyncLocate.c @@ -12,12 +12,12 @@ */ /* $Header$ */ +#include <internal.h> + #ifndef lint -static char rcsid_ZAsyncLocate_c[] = "$Id$"; +static const char rcsid_ZAsyncLocate_c[] = "$Id$"; #endif -#include <zephyr/zephyr_internal.h> - Code_t ZRequestLocations(user, zald, kind, auth) char *user; register ZAsyncLocateData_t *zald; @@ -153,7 +153,7 @@ Code_t ZParseLocations(notice,zald,nlocs,user) int ZCompareALDPred(notice, zald) ZNotice_t *notice; - char *zald; + void *zald; { return(ZCompareUID(&(notice->z_multiuid), &(((ZAsyncLocateData_t *) zald)->uid))); diff --git a/lib/ZCkAuth.c b/lib/ZCkAuth.c index 999950b..8f4816e 100644 --- a/lib/ZCkAuth.c +++ b/lib/ZCkAuth.c @@ -17,27 +17,22 @@ static char rcsid_ZCheckAuthentication_c[] = "$Zephyr: /mit/zephyr/src/lib/RCS/ZCheckAuthentication.c,v 1.14 89/03/24 14:17:38 jtkohl Exp Locker: raeburn $"; #endif -#include <zephyr/mit-copyright.h> -#include <sys/param.h> -#include <zephyr/zephyr_internal.h> +#include <internal.h> /* Check authentication of the notice. If it looks authentic but fails the Kerberos check, return -1. If it looks authentic and passes the Kerberos check, return 1. If it doesn't look authentic, return 0 - When not using Kerberos, return (looks-authentic-p) + When not using Kerberos, return true if the notice claims to be authentic. Only used by clients; the server uses its own routine. */ -int ZCheckAuthentication(notice, from) +Code_t ZCheckAuthentication(notice, from) ZNotice_t *notice; struct sockaddr_in *from; { -#ifdef Z_HaveKerberos +#ifdef ZEPHYR_USES_KERBEROS int result; - char srcprincipal[ANAME_SZ+INST_SZ+REALM_SZ+4]; - KTEXT_ST authent; - AUTH_DAT dat; ZChecksum_t our_checksum; CREDENTIALS cred; @@ -48,17 +43,17 @@ int ZCheckAuthentication(notice, from) if (!notice->z_auth) return (ZAUTH_NO); - if (result = krb_get_cred(SERVER_SERVICE, SERVER_INSTANCE, - __Zephyr_realm, &cred)) + if ((result = krb_get_cred(SERVER_SERVICE, SERVER_INSTANCE, + __Zephyr_realm, &cred)) != 0) return (ZAUTH_NO); #ifdef NOENCRYPTION our_checksum = 0; #else - our_checksum = (ZChecksum_t)des_quad_cksum(notice->z_packet, NULL, - notice->z_default_format+ - strlen(notice->z_default_format)+1- - notice->z_packet, 0, cred.session); + our_checksum = des_quad_cksum(notice->z_packet, NULL, + notice->z_default_format+ + strlen(notice->z_default_format)+1- + notice->z_packet, 0, cred.session); #endif /* if mismatched checksum, then the packet was corrupted */ return ((our_checksum == notice->z_checksum) ? ZAUTH_YES : ZAUTH_FAILED); diff --git a/lib/ZCkIfNot.c b/lib/ZCkIfNot.c index 6ca5ef7..39b0eed 100644 --- a/lib/ZCkIfNot.c +++ b/lib/ZCkIfNot.c @@ -12,17 +12,17 @@ */ /* $Header$ */ +#include <internal.h> + #ifndef lint -static char rcsid_ZCheckIfNotice_c[] = "$Id$"; +static const char rcsid_ZCheckIfNotice_c[] = "$Id$"; #endif -#include <zephyr/zephyr_internal.h> - Code_t ZCheckIfNotice(notice, from, predicate, args) ZNotice_t *notice; struct sockaddr_in *from; - register int (*predicate)(); - char *args; + register int (*predicate) __P((ZNotice_t *, void *)); + void *args; { ZNotice_t tmpnotice; Code_t retval; diff --git a/lib/ZClosePort.c b/lib/ZClosePort.c index 64e110d..ea39f6f 100644 --- a/lib/ZClosePort.c +++ b/lib/ZClosePort.c @@ -12,14 +12,12 @@ */ /* $Header$ */ +#include <internal.h> + #ifndef lint -static char rcsid_ZClosePort_c[] = "$Id$"; +static const char rcsid_ZClosePort_c[] = "$Id$"; #endif -#include <zephyr/mit-copyright.h> - -#include <zephyr/zephyr_internal.h> - Code_t ZClosePort() { if (__Zephyr_fd >= 0 && __Zephyr_open) diff --git a/lib/ZCmpUID.c b/lib/ZCmpUID.c index 85f2b66..ffd065a 100644 --- a/lib/ZCmpUID.c +++ b/lib/ZCmpUID.c @@ -16,9 +16,7 @@ static char rcsid_ZCompareUID_c[] = "$Id$"; #endif -#include <zephyr/mit-copyright.h> - -#include <zephyr/zephyr_internal.h> +#include <internal.h> int ZCompareUID(uid1, uid2) ZUnique_Id_t *uid1, *uid2; diff --git a/lib/ZCmpUIDP.c b/lib/ZCmpUIDP.c index 29bb69b..ca4466a 100644 --- a/lib/ZCmpUIDP.c +++ b/lib/ZCmpUIDP.c @@ -16,20 +16,18 @@ static char rcsid_ZCompareUIDPred_c[] = "$Header$"; #endif -#include <zephyr/mit-copyright.h> - -#include <zephyr/zephyr_internal.h> +#include <internal.h> int ZCompareUIDPred(notice, uid) ZNotice_t *notice; - ZUnique_Id_t *uid; + void *uid; { - return (ZCompareUID(¬ice->z_uid, uid)); + return (ZCompareUID(¬ice->z_uid, (ZUnique_Id_t *) uid)); } int ZCompareMultiUIDPred(notice, uid) ZNotice_t *notice; - ZUnique_Id_t *uid; + void *uid; { - return (ZCompareUID(¬ice->z_multiuid, uid)); + return (ZCompareUID(¬ice->z_multiuid, (ZUnique_Id_t *) uid)); } diff --git a/lib/ZFlsLocs.c b/lib/ZFlsLocs.c index b5110f8..66c5cbc 100644 --- a/lib/ZFlsLocs.c +++ b/lib/ZFlsLocs.c @@ -16,9 +16,7 @@ static char rcsid_ZFlushLocations_c[] = "$Header$"; #endif -#include <zephyr/mit-copyright.h> - -#include <zephyr/zephyr_internal.h> +#include <internal.h> Code_t ZFlushLocations() { diff --git a/lib/ZFlsSubs.c b/lib/ZFlsSubs.c index 3552ee3..ae0ddb5 100644 --- a/lib/ZFlsSubs.c +++ b/lib/ZFlsSubs.c @@ -12,12 +12,12 @@ */ /* $Header$ */ +#include <internal.h> + #ifndef lint -static char rcsid_ZFlushSubscriptions_c[] = "$Id$"; +static const char rcsid_ZFlushSubscriptions_c[] = "$Id$"; #endif -#include <zephyr/zephyr_internal.h> - Code_t ZFlushSubscriptions() { register int i; diff --git a/lib/ZFmtAuth.c b/lib/ZFmtAuth.c index 42af25a..5ac708a 100644 --- a/lib/ZFmtAuth.c +++ b/lib/ZFmtAuth.c @@ -16,10 +16,9 @@ static char rcsid_ZFormatAuthenticNotice_c[] = "$Header$"; #endif -#include <zephyr/mit-copyright.h> -#include <zephyr/zephyr_internal.h> +#include <internal.h> -#ifdef Z_HaveKerberos +#ifdef ZEPHYR_USES_KERBEROS Code_t ZFormatAuthenticNotice(notice, buffer, buffer_len, len, session) ZNotice_t *notice; register char *buffer; diff --git a/lib/ZFmtList.c b/lib/ZFmtList.c index baf2dda..7c4ab93 100644 --- a/lib/ZFmtList.c +++ b/lib/ZFmtList.c @@ -12,13 +12,13 @@ */ /* $Header$ */ +#include <internal.h> + #ifndef lint -static char rcsid_ZFormatNoticeList_c[] = +static const char rcsid_ZFormatNoticeList_c[] = "$Id$"; #endif -#include <zephyr/zephyr_internal.h> - Code_t ZFormatNoticeList(notice, list, nitems, buffer, ret_len, cert_routine) ZNotice_t *notice; diff --git a/lib/ZFmtNotice.c b/lib/ZFmtNotice.c index 96147f8..386630d 100644 --- a/lib/ZFmtNotice.c +++ b/lib/ZFmtNotice.c @@ -16,7 +16,7 @@ static char rcsid_ZFormatNotice_c[] = "$Id$"; #endif -#include <zephyr/zephyr_internal.h> +#include <internal.h> Code_t ZFormatNotice(notice, buffer, ret_len, cert_routine) register ZNotice_t *notice; diff --git a/lib/ZFmtRaw.c b/lib/ZFmtRaw.c index 49d82db..d0921e7 100644 --- a/lib/ZFmtRaw.c +++ b/lib/ZFmtRaw.c @@ -16,7 +16,7 @@ static char rcsid_ZFormatRawNotice_c[] = "$Id$"; #endif -#include <zephyr/zephyr_internal.h> +#include <internal.h> Code_t ZFormatRawNotice(notice, buffer, ret_len) register ZNotice_t *notice; diff --git a/lib/ZFmtRawLst.c b/lib/ZFmtRawLst.c index 2773f50..7bfa169 100644 --- a/lib/ZFmtRawLst.c +++ b/lib/ZFmtRawLst.c @@ -16,9 +16,7 @@ static char rcsid_ZFormatRawNoticeList_c[] = "$Header$"; #endif -#include <zephyr/mit-copyright.h> - -#include <zephyr/zephyr_internal.h> +#include <internal.h> Code_t ZFormatRawNoticeList(notice, list, nitems, buffer, ret_len) ZNotice_t *notice; diff --git a/lib/ZFmtSmRLst.c b/lib/ZFmtSmRLst.c index 67d50a9..421c76c 100644 --- a/lib/ZFmtSmRLst.c +++ b/lib/ZFmtSmRLst.c @@ -16,9 +16,7 @@ static char rcsid_ZFormatRawNoticeList_c[] = "$Header$"; #endif -#include <zephyr/mit-copyright.h> - -#include <zephyr/zephyr_internal.h> +#include <internal.h> Code_t ZFormatSmallRawNoticeList(notice, list, nitems, buffer, ret_len) ZNotice_t *notice; diff --git a/lib/ZFmtSmRaw.c b/lib/ZFmtSmRaw.c index aa6ac60..4fa554f 100644 --- a/lib/ZFmtSmRaw.c +++ b/lib/ZFmtSmRaw.c @@ -16,9 +16,7 @@ static char rcsid_ZFormatRawNotice_c[] = "$Header$"; #endif -#include <zephyr/mit-copyright.h> - -#include <zephyr/zephyr_internal.h> +#include <internal.h> Code_t ZFormatSmallRawNotice(notice, buffer, ret_len) ZNotice_t *notice; diff --git a/lib/ZFreeNot.c b/lib/ZFreeNot.c index 02622eb..537194d 100644 --- a/lib/ZFreeNot.c +++ b/lib/ZFreeNot.c @@ -16,9 +16,7 @@ static char rcsid_ZFreeNotice_c[] = "$Header$"; #endif -#include <zephyr/mit-copyright.h> - -#include <zephyr/zephyr_internal.h> +#include <internal.h> Code_t ZFreeNotice(notice) ZNotice_t *notice; diff --git a/lib/ZGetLocs.c b/lib/ZGetLocs.c index 57e5842..b322a37 100644 --- a/lib/ZGetLocs.c +++ b/lib/ZGetLocs.c @@ -16,9 +16,7 @@ static char rcsid_ZGetLocations_c[] = "$Header$"; #endif -#include <zephyr/mit-copyright.h> - -#include <zephyr/zephyr_internal.h> +#include <internal.h> #define min(a,b) ((a)<(b)?(a):(b)) diff --git a/lib/ZGetSender.c b/lib/ZGetSender.c index acff9e0..4b8d0ba 100644 --- a/lib/ZGetSender.c +++ b/lib/ZGetSender.c @@ -12,20 +12,19 @@ */ /* $Header$ */ +#include <internal.h> + #ifndef lint -static char rcsid_ZGetSender_c[] = +static const char rcsid_ZGetSender_c[] = "$Id$"; #endif -#include <zephyr/mit-copyright.h> -#include <zephyr/zephyr_internal.h> - #include <pwd.h> char *ZGetSender() { struct passwd *pw; -#ifdef Z_HaveKerberos +#ifdef ZEPHYR_USES_KERBEROS char pname[ANAME_SZ], pinst[INST_SZ], prealm[REALM_SZ]; static char sender[ANAME_SZ+INST_SZ+REALM_SZ+3] = ""; #else @@ -36,7 +35,7 @@ char *ZGetSender() if (*sender) return (sender); -#ifdef Z_HaveKerberos +#ifdef ZEPHYR_USES_KERBEROS if (krb_get_tf_fullname((char *)TKT_FILE, pname, pinst, prealm) == KSUCCESS) { (void) sprintf(sender, "%s%s%s@%s", pname, (pinst[0]?".":""), diff --git a/lib/ZGetSubs.c b/lib/ZGetSubs.c index 5dd92c7..c3ed5aa 100644 --- a/lib/ZGetSubs.c +++ b/lib/ZGetSubs.c @@ -16,9 +16,7 @@ static char rcsid_ZGetSubscriptions_c[] = "$Header$"; #endif -#include <zephyr/mit-copyright.h> - -#include <zephyr/zephyr_internal.h> +#include <internal.h> #define min(a,b) ((a)<(b)?(a):(b)) diff --git a/lib/ZGetWGPort.c b/lib/ZGetWGPort.c index 500a146..1c5ac06 100644 --- a/lib/ZGetWGPort.c +++ b/lib/ZGetWGPort.c @@ -16,8 +16,7 @@ static char rcsid_ZGetWGPort_c[] = "$Header$"; #endif -#include <zephyr/mit-copyright.h> -#include <zephyr/zephyr_internal.h> +#include <internal.h> int ZGetWGPort() { diff --git a/lib/ZIfNotice.c b/lib/ZIfNotice.c index e49e6bb..80f5a20 100644 --- a/lib/ZIfNotice.c +++ b/lib/ZIfNotice.c @@ -12,19 +12,17 @@ */ /* $Header$ */ +#include <internal.h> + #ifndef lint -static char rcsid_ZIfNotice_c[] = "$Id$"; +static const char rcsid_ZIfNotice_c[] = "$Id$"; #endif -#include <zephyr/mit-copyright.h> - -#include <zephyr/zephyr_internal.h> - Code_t ZIfNotice(notice, from, predicate, args) ZNotice_t *notice; struct sockaddr_in *from; - int (*predicate)(); - char *args; + int (*predicate) __P((ZNotice_t *, void *)); + void *args; { ZNotice_t tmpnotice; Code_t retval; diff --git a/lib/ZInit.c b/lib/ZInit.c index 6082664..6cdd486 100644 --- a/lib/ZInit.c +++ b/lib/ZInit.c @@ -17,22 +17,23 @@ static char rcsid_ZInitialize_c[] = "$Zephyr: /afs/athena.mit.edu/astaff/project/zephyr/src/lib/RCS/ZInitialize.c,v 1.17 89/05/30 18:11:25 jtkohl Exp $"; #endif -#include <zephyr/mit-copyright.h> -#include <zephyr/zephyr_internal.h> +#include <internal.h> -#include <netdb.h> #include <sys/socket.h> -#include <sys/param.h> -#ifdef Z_HaveKerberos -#include "krb_err.h" +#ifdef ZEPHYR_USES_KERBEROS +#include <krb_err.h> #endif Code_t ZInitialize() { struct servent *hmserv; char addr[4]; -#ifdef Z_HaveKerberos +#ifdef ZEPHYR_USES_KERBEROS + Code_t code; + ZNotice_t notice; + char *krealm; int krbval; + char d1[ANAME_SZ], d2[INST_SZ]; initialize_krb_error_table(); #endif @@ -50,26 +51,54 @@ Code_t ZInitialize() addr[3] = 1; hmserv = (struct servent *)getservbyname(HM_SVCNAME, "udp"); - if (!hmserv) - return (ZERR_HMPORT); - - __HM_addr.sin_port = hmserv->s_port; + __HM_addr.sin_port = (hmserv) ? hmserv->s_port : HM_SVC_FALLBACK; (void) memcpy((char *)&__HM_addr.sin_addr, addr, 4); __HM_set = 0; -#ifdef Z_HaveKerberos - if ((krbval = krb_get_lrealm(__Zephyr_realm, 1)) != KSUCCESS) + /* Initialize the input queue */ + __Q_Tail = NULL; + __Q_Head = NULL; + +#ifdef ZEPHYR_USES_KERBEROS + + /* if the application is a server, there might not be a zhm. The + code will fall back to something which might not be "right", + but this is is ok, since none of the servers call krb_rd_req. */ + + if (! __Zephyr_server) { + if ((code = ZOpenPort(NULL)) != ZERR_NONE) + return(code); + + if ((code = ZhmStat(NULL, ¬ice)) != ZERR_NONE) + return(code); + + ZClosePort(); + + /* the first field, which is NUL-terminated, is the server name. + If this code ever support a multiplexing zhm, this will have to + be made smarter, and probably per-message */ + + krealm = krb_realmofhost(notice.z_message); + + ZFreeNotice(¬ice); + } else { + krealm = NULL; + } + + if (krealm) { + strcpy(__Zephyr_realm, krealm); + } else if ((krb_get_tf_fullname(TKT_FILE, d1, d2, __Zephyr_realm) + != KSUCCESS) && + ((krbval = krb_get_lrealm(__Zephyr_realm, 1)) != KSUCCESS)) { return (krbval); + } #endif /* Get the sender so we can cache it */ (void) ZGetSender(); - /* Initialize the input queue */ - __Q_Tail = NULL; - __Q_Head = NULL; - return (ZERR_NONE); } + diff --git a/lib/ZLocateU.c b/lib/ZLocateU.c index 6b10ccd..87c2713 100644 --- a/lib/ZLocateU.c +++ b/lib/ZLocateU.c @@ -16,9 +16,7 @@ static char rcsid_ZLocateUser_c[] = "$Header$"; #endif -#include <zephyr/mit-copyright.h> - -#include <zephyr/zephyr_internal.h> +#include <internal.h> Code_t ZLocateUser(user, nlocs) char *user; diff --git a/lib/ZLocations.c b/lib/ZLocations.c index 7701a8d..a0a2d4f 100644 --- a/lib/ZLocations.c +++ b/lib/ZLocations.c @@ -18,17 +18,43 @@ static char rcsid_ZLocations_c[] = "$Zephyr: /afs/athena.mit.edu/astaff/project/zephyr/src/lib/RCS/ZLocations.c,v 1.30 90/12/20 03:04:39 raeburn Exp $"; #endif -#include <zephyr/mit-copyright.h> - -#include <zephyr/zephyr_internal.h> +#include <internal.h> #include <pwd.h> -#include <sys/file.h> -#include <sys/param.h> -#include <netdb.h> -extern char *getenv(); -extern int errno; +static char host[MAXHOSTNAMELEN], mytty[MAXPATHLEN]; +static int location_info_set = 0; + +Code_t ZInitLocationInfo(hostname, tty) + char *hostname; + char *tty; +{ + char *ttyp, *p; + struct hostent *hent; + + if (hostname) { + strcpy(host, hostname); + } else { + if (gethostname(host, MAXHOSTNAMELEN) < 0) + return (errno); + hent = gethostbyname(host); + if (hent) + (void) strcpy(host, hent->h_name); + } + if (tty) { + strcpy(mytty, tty); + } else { + ttyp = ttyname(0); + if (ttyp) { + p = strrchr(ttyp, '/'); + strcpy(mytty, (p) ? p + 1 : ttyp); + } else { + strcpy(mytty, "unknown"); + } + } + location_info_set = 1; + return (ZERR_NONE); +} Code_t ZSetLocation(exposure) char *exposure; @@ -48,29 +74,42 @@ Code_t ZFlushMyLocations() return (Z_SendLocation(LOGIN_CLASS, LOGIN_USER_FLUSH, ZAUTH, "")); } -static char host[MAXHOSTNAMELEN], mytty[MAXPATHLEN]; -static int reenter = 0; +char *ZParseExposureLevel(text) + char *text; +{ + if (!strcasecmp(text, EXPOSE_NONE)) + return (EXPOSE_NONE); + else if (!strcasecmp(text, EXPOSE_OPSTAFF)) + return (EXPOSE_OPSTAFF); + else if (!strcasecmp(text, EXPOSE_REALMVIS)) + return (EXPOSE_REALMVIS); + else if (!strcasecmp(text, EXPOSE_REALMANN)) + return (EXPOSE_REALMANN); + else if (!strcasecmp(text, EXPOSE_NETVIS)) + return (EXPOSE_NETVIS); + else if (!strcasecmp(text, EXPOSE_NETANN)) + return (EXPOSE_NETANN); + else + return(NULL); +} -Z_SendLocation(class, opcode, auth, format) +Code_t Z_SendLocation(class, opcode, auth, format) char *class; char *opcode; - int (*auth)(); + Z_AuthProc auth; char *format; { - char *ttyname(), *ctime(); - int retval; - long ourtime; + time_t ourtime; ZNotice_t notice, retnotice; char *bptr[3]; -#ifdef X11 - char *display; -#endif /* X11 */ - char *ttyp; struct hostent *hent; short wg_port = ZGetWGPort(); - (void) memset((char *)¬ice, 0, sizeof(notice)); + if (!location_info_set) + ZInitLocationInfo(NULL, NULL); + + memset((char *)¬ice, 0, sizeof(notice)); notice.z_kind = ACKED; notice.z_port = (u_short) ((wg_port == -1) ? 0 : wg_port); notice.z_class = class; @@ -81,51 +120,12 @@ Z_SendLocation(class, opcode, auth, format) notice.z_num_other_fields = 0; notice.z_default_format = format; - /* - keep track of what we said before so that we can be consistent - when changing location information. - This is done mainly for the sake of the WindowGram client. - */ - - if (!reenter) { - if (gethostname(host, MAXHOSTNAMELEN) < 0) - return (errno); - - hent = gethostbyname(host); - if (hent) - (void) strcpy(host, hent->h_name); - bptr[0] = host; -#ifdef X11 - if ((display = getenv("DISPLAY")) && *display) { - (void) strcpy(mytty, display); - bptr[2] = mytty; - } else { -#endif /* X11 */ - ttyp = ttyname(0); - if (ttyp) { - bptr[2] = strrchr(ttyp, '/'); - if (bptr[2]) - bptr[2]++; - else - bptr[2] = ttyp; - } - else - bptr[2] = "unknown"; - (void) strcpy(mytty, bptr[2]); -#ifdef X11 - } -#endif /* X11 */ - reenter = 1; - } else { - bptr[0] = host; - bptr[2] = mytty; - } - - ourtime = time((long *)0); + bptr[0] = host; + ourtime = time((time_t *)0); bptr[1] = ctime(&ourtime); bptr[1][strlen(bptr[1])-1] = '\0'; + bptr[2] = mytty; - if ((retval = ZSendList(¬ice, bptr, 3, auth)) != ZERR_NONE) return (retval); diff --git a/lib/ZMakeAscii.c b/lib/ZMakeAscii.c index da88fdd..413c515 100644 --- a/lib/ZMakeAscii.c +++ b/lib/ZMakeAscii.c @@ -12,11 +12,14 @@ */ /* $Header$ */ +#include <internal.h> +#include <assert.h> + #ifndef lint -static char rcsid_ZMakeAscii_c[] = "$Id$"; +static const char rcsid_ZMakeAscii_c[] = "$Id$"; #endif -#include <zephyr/zephyr_internal.h> +static char *itox_chars = "0123456789ABCDEF"; Code_t ZMakeAscii(ptr, len, field, num) register char *ptr; @@ -25,7 +28,6 @@ Code_t ZMakeAscii(ptr, len, field, num) int num; { int i; - register char *itox_chars = "0123456789ABCDEF"; for (i=0;i<num;i++) { /* we need to add "0x" if we are between 4 byte pieces */ @@ -51,3 +53,42 @@ Code_t ZMakeAscii(ptr, len, field, num) *ptr = '\0'; return ZERR_NONE; } + +Code_t ZMakeAscii32(ptr, len, value) + register char *ptr; + int len; + unsigned long value; +{ + if (len < 11) + return ZERR_FIELDLEN; + *ptr++ = '0'; + *ptr++ = 'x'; + *ptr++ = itox_chars[(value >> 28) & 0xf]; + *ptr++ = itox_chars[(value >> 24) & 0xf]; + *ptr++ = itox_chars[(value >> 20) & 0xf]; + *ptr++ = itox_chars[(value >> 16) & 0xf]; + *ptr++ = itox_chars[(value >> 12) & 0xf]; + *ptr++ = itox_chars[(value >> 8) & 0xf]; + *ptr++ = itox_chars[(value >> 4) & 0xf]; + *ptr++ = itox_chars[(value >> 0) & 0xf]; + *ptr = 0; + return ZERR_NONE; +} + +Code_t ZMakeAscii16(ptr, len, value) + register char *ptr; + int len; + unsigned int value; +{ + if (len < 7) + return ZERR_FIELDLEN; + *ptr++ = '0'; + *ptr++ = 'x'; + *ptr++ = itox_chars[(value >> 12) & 0xf]; + *ptr++ = itox_chars[(value >> 8) & 0xf]; + *ptr++ = itox_chars[(value >> 4) & 0xf]; + *ptr++ = itox_chars[(value >> 0) & 0xf]; + *ptr = 0; + return ZERR_NONE; +} + diff --git a/lib/ZMkAuth.c b/lib/ZMkAuth.c index d027476..18d5014 100644 --- a/lib/ZMkAuth.c +++ b/lib/ZMkAuth.c @@ -12,19 +12,20 @@ */ /* $Id$ */ +#include <internal.h> + #ifndef lint -static char rcsid_ZMakeAuthentication_c[] = "$Id$"; +static const char rcsid_ZMakeAuthentication_c[] = "$Id$"; #endif -#include <zephyr/zephyr_internal.h> -#ifdef Z_HaveKerberos -#include "krb_err.h" +#ifdef ZEPHYR_USES_KERBEROS +#include <krb_err.h> static long last_authent_time = 0L; static KTEXT_ST last_authent; #endif Code_t ZResetAuthentication () { -#ifdef Z_HaveKerberos +#ifdef ZEPHYR_USES_KERBEROS last_authent_time = 0L; #endif return ZERR_NONE; @@ -36,13 +37,14 @@ Code_t ZMakeAuthentication(notice, buffer, buffer_len, len) int buffer_len; int *len; { -#ifdef Z_HaveKerberos +#ifdef ZEPHYR_USES_KERBEROS int result; - long now,time(); + time_t now; KTEXT_ST authent; char *cstart, *cend; - long checksum; + ZChecksum_t checksum; CREDENTIALS cred; + extern unsigned long des_quad_cksum(); now = time(0); if (last_authent_time == 0 || (now - last_authent_time > 120)) { @@ -79,18 +81,16 @@ Code_t ZMakeAuthentication(notice, buffer, buffer_len, len) return(result); /* Compute a checksum over the header and message. */ - if (result = krb_get_cred(SERVER_SERVICE, SERVER_INSTANCE, - __Zephyr_realm, &cred)) + if ((result = krb_get_cred(SERVER_SERVICE, SERVER_INSTANCE, + __Zephyr_realm, &cred)) != 0) return result; checksum = des_quad_cksum(buffer, NULL, cstart - buffer, 0, cred.session); checksum ^= des_quad_cksum(cend, NULL, buffer + *len - cend, 0, cred.session); checksum ^= des_quad_cksum(notice->z_message, NULL, notice->z_message_len, 0, cred.session); - notice->z_checksum = (ZChecksum_t) checksum; - checksum = htonl(checksum); - ZMakeAscii(cstart, buffer + buffer_len - cstart, - (unsigned char *) &checksum, sizeof(checksum)); + notice->z_checksum = checksum; + ZMakeAscii32(cstart, buffer + buffer_len - cstart, checksum); return (ZERR_NONE); #else diff --git a/lib/ZNewLocU.c b/lib/ZNewLocU.c index 3231126..87c6dc4 100644 --- a/lib/ZNewLocU.c +++ b/lib/ZNewLocU.c @@ -12,19 +12,19 @@ */ /* $Header$ */ +#include <internal.h> + #ifndef lint -static char rcsid_ZNewLocateUser_c[] = +static const char rcsid_ZNewLocateUser_c[] = "$Id$"; #endif -#include <zephyr/zephyr_internal.h> - Code_t ZLocateUser(user, nlocs, auth) char *user; int *nlocs; Z_AuthProc auth; { - register int retval; + Code_t retval; ZNotice_t notice; ZAsyncLocateData_t zald; @@ -34,8 +34,7 @@ Code_t ZLocateUser(user, nlocs, auth) if ((retval = ZRequestLocations(user, &zald, UNACKED, auth)) != ZERR_NONE) return(retval); - retval = Z_WaitForNotice (¬ice, ZCompareALDPred, - (char *) &zald, SRV_TIMEOUT); + retval = Z_WaitForNotice (¬ice, ZCompareALDPred, &zald, SRV_TIMEOUT); if (retval == ZERR_NONOTICE) return ETIMEDOUT; if (retval != ZERR_NONE) diff --git a/lib/ZOpenPort.c b/lib/ZOpenPort.c index 88d2d9f..cae00b8 100644 --- a/lib/ZOpenPort.c +++ b/lib/ZOpenPort.c @@ -16,9 +16,7 @@ static char rcsid_ZOpenPort_c[] = "$Header$"; #endif -#include <zephyr/mit-copyright.h> - -#include <zephyr/zephyr_internal.h> +#include <internal.h> #include <sys/socket.h> Code_t ZOpenPort(port) diff --git a/lib/ZParseNot.c b/lib/ZParseNot.c index 5717d11..daf1b3d 100644 --- a/lib/ZParseNot.c +++ b/lib/ZParseNot.c @@ -17,9 +17,7 @@ static char rcsid_ZParseNotice_c[] = "$Zephyr: /mit/zephyr/src/lib/RCS/ZParseNotice.c,v 1.22 91/03/29 03:34:46 raeburn Exp $"; #endif -#include <zephyr/mit-copyright.h> - -#include <zephyr/zephyr_internal.h> +#include <internal.h> /* Assume that strlen is efficient on this machine... */ #define next_field(ptr) ptr += strlen (ptr) + 1 @@ -77,13 +75,8 @@ Code_t ZParseNotice(buffer, len, notice) ZNotice_t *notice; { char *ptr, *end; + unsigned long temp; int maj, numfields, i; - union { - int i; - ZUnique_Id_t uid; - u_short us; - ZChecksum_t sum; - } temp; #ifdef __LINE__ int lineno; @@ -92,11 +85,11 @@ Code_t ZParseNotice(buffer, len, notice) * be used as the "then" part of an "if" statement that also has * an "else" clause. */ -#define BAD {lineno=__LINE__;goto badpkt;} +#define BAD_PACKET {lineno=__LINE__;goto badpkt;} /* This one gets lint/compiler complaints. */ /*#define BAD do{lineno=__LINE__;goto badpkt;}while(0)*/ #else -#define BAD goto badpkt +#define BAD_PACKET goto badpkt #endif (void) memset((char *)notice, 0, sizeof(ZNotice_t)); @@ -121,10 +114,9 @@ Code_t ZParseNotice(buffer, len, notice) return (ZERR_VERS); next_field (ptr); - if (ZReadAscii(ptr, end-ptr, (unsigned char *)&temp.i, - sizeof(temp.i)) == ZERR_BADFIELD) - BAD; - numfields = ntohl((u_long) temp.i); + if (ZReadAscii32(ptr, end-ptr, &temp) == ZERR_BADFIELD) + BAD_PACKET; + numfields = temp; next_field (ptr); /*XXX 3 */ @@ -150,63 +142,57 @@ Code_t ZParseNotice(buffer, len, notice) } if (numfields) { - if (ZReadAscii(ptr, end-ptr, (unsigned char *)&temp.i, - sizeof(temp.i)) == ZERR_BADFIELD) - BAD; - notice->z_kind = (ZNotice_Kind_t)ntohl((u_long) temp.i); + if (ZReadAscii32(ptr, end-ptr, &temp) == ZERR_BADFIELD) + BAD_PACKET; + notice->z_kind = temp; numfields--; next_field (ptr); } else - BAD; + BAD_PACKET; if (numfields) { - if (ZReadAscii(ptr, end-ptr, (unsigned char *)&temp.uid, + if (ZReadAscii(ptr, end-ptr, (unsigned char *)¬ice->z_uid, sizeof(ZUnique_Id_t)) == ZERR_BADFIELD) - BAD; - notice->z_uid = temp.uid; + BAD_PACKET; notice->z_time.tv_sec = ntohl((u_long) notice->z_uid.tv.tv_sec); notice->z_time.tv_usec = ntohl((u_long) notice->z_uid.tv.tv_usec); numfields--; next_field (ptr); } else - BAD; + BAD_PACKET; if (numfields) { - if (ZReadAscii(ptr, end-ptr, (unsigned char *)&temp.us, - sizeof(u_short)) == - ZERR_BADFIELD) - BAD; - notice->z_port = temp.us; + if (ZReadAscii16(ptr, end-ptr, ¬ice->z_port) == ZERR_BADFIELD) + BAD_PACKET; + notice->z_port = htons(notice->z_port); numfields--; next_field (ptr); } else - BAD; + BAD_PACKET; if (numfields) { - if (ZReadAscii(ptr, end-ptr, (unsigned char *)&temp.i, - sizeof(int)) == ZERR_BADFIELD) - BAD; - notice->z_auth = temp.i; + if (ZReadAscii32(ptr, end-ptr, &temp) == ZERR_BADFIELD) + BAD_PACKET; + notice->z_auth = temp; numfields--; next_field (ptr); } else - BAD; + BAD_PACKET; notice->z_checked_auth = ZAUTH_UNSET; if (numfields) { - if (ZReadAscii(ptr, end-ptr, (unsigned char *)&temp.i, - sizeof(int)) == ZERR_BADFIELD) - BAD; - notice->z_authent_len = ntohl((u_long) temp.i); + if (ZReadAscii32(ptr, end-ptr, &temp) == ZERR_BADFIELD) + BAD_PACKET; + notice->z_authent_len = temp; numfields--; next_field (ptr); } else - BAD; + BAD_PACKET; if (numfields) { notice->z_ascii_authent = ptr; @@ -214,7 +200,7 @@ Code_t ZParseNotice(buffer, len, notice) next_field (ptr); } else - BAD; + BAD_PACKET; if (numfields) { notice->z_class = ptr; @@ -265,11 +251,9 @@ Code_t ZParseNotice(buffer, len, notice) notice->z_default_format = ""; /*XXX*/ - if (ZReadAscii(ptr, end-ptr, (unsigned char *)&temp.sum, - sizeof(ZChecksum_t)) - == ZERR_BADFIELD) - BAD; - notice->z_checksum = ntohl((u_long) temp.sum); + if (ZReadAscii32(ptr, end-ptr, &temp) == ZERR_BADFIELD) + BAD_PACKET; + notice->z_checksum = temp; numfields--; next_field (ptr); @@ -282,10 +266,9 @@ Code_t ZParseNotice(buffer, len, notice) notice->z_multinotice = ""; if (numfields) { - if (ZReadAscii(ptr, end-ptr, (unsigned char *)&temp.uid, + if (ZReadAscii(ptr, end-ptr, (unsigned char *)¬ice->z_multiuid, sizeof(ZUnique_Id_t)) == ZERR_BADFIELD) - BAD; - notice->z_multiuid = temp.uid; + BAD_PACKET; notice->z_time.tv_sec = ntohl((u_long) notice->z_multiuid.tv.tv_sec); notice->z_time.tv_usec = ntohl((u_long) notice->z_multiuid.tv.tv_usec); numfields--; @@ -296,7 +279,6 @@ Code_t ZParseNotice(buffer, len, notice) for (i=0;i<Z_MAXOTHERFIELDS && numfields;i++,numfields--) { notice->z_other_fields[i] = ptr; - numfields--; next_field (ptr); } notice->z_num_other_fields = i; @@ -304,16 +286,6 @@ Code_t ZParseNotice(buffer, len, notice) for (i=0;i<numfields;i++) next_field (ptr); -#ifdef notdef - if (ZReadAscii(ptr, end-ptr, (unsigned char *)temp, - sizeof(ZChecksum_t)) - == ZERR_BADFIELD) - BAD; - notice->z_checksum = ntohl(*temp); - numfields--; - next_field (ptr); -#endif - notice->z_message = (caddr_t) ptr; notice->z_message_len = len-(ptr-buffer); diff --git a/lib/ZPeekIfNot.c b/lib/ZPeekIfNot.c index a010fa6..11a5ae6 100644 --- a/lib/ZPeekIfNot.c +++ b/lib/ZPeekIfNot.c @@ -16,9 +16,7 @@ static char rcsid_ZPeekIfNotice_c[] = "$Header$"; #endif -#include <zephyr/mit-copyright.h> - -#include <zephyr/zephyr_internal.h> +#include <internal.h> Code_t ZPeekIfNotice(notice, from, predicate, args) ZNotice_t *notice; diff --git a/lib/ZPeekNot.c b/lib/ZPeekNot.c index f789ee1..e1ebb2d 100644 --- a/lib/ZPeekNot.c +++ b/lib/ZPeekNot.c @@ -16,9 +16,7 @@ static char rcsid_ZPeekNotice_c[] = "$Header$"; #endif -#include <zephyr/mit-copyright.h> - -#include <zephyr/zephyr_internal.h> +#include <internal.h> Code_t ZPeekNotice(notice, from) ZNotice_t *notice; diff --git a/lib/ZPeekPkt.c b/lib/ZPeekPkt.c index 439194b..aa21dda 100644 --- a/lib/ZPeekPkt.c +++ b/lib/ZPeekPkt.c @@ -16,9 +16,7 @@ static char rcsid_ZPeekPacket_c[] = "$Header$"; #endif -#include <zephyr/mit-copyright.h> - -#include <zephyr/zephyr_internal.h> +#include <internal.h> Code_t ZPeekPacket(buffer, ret_len, from) char **buffer; diff --git a/lib/ZPending.c b/lib/ZPending.c index 03cc8c7..982f83c 100644 --- a/lib/ZPending.c +++ b/lib/ZPending.c @@ -16,9 +16,7 @@ static char rcsid_ZPending_c[] = "$Header$"; #endif -#include <zephyr/mit-copyright.h> - -#include <zephyr/zephyr_internal.h> +#include <internal.h> int ZPending() { diff --git a/lib/ZReadAscii.c b/lib/ZReadAscii.c index ada78c6..4b4faed 100644 --- a/lib/ZReadAscii.c +++ b/lib/ZReadAscii.c @@ -13,17 +13,11 @@ /* $Header$ */ #ifndef lint -static -#ifdef __STDC__ - const -#endif - char rcsid_ZReadAscii_c[] = - "$Header$"; +static char rcsid_ZReadAscii_c[] = "$Header$"; #endif /* lint */ -#include <zephyr/mit-copyright.h> - -#include <zephyr/zephyr_internal.h> +#include <internal.h> +#include <assert.h> #if 0 static __inline__ @@ -42,7 +36,7 @@ Z_cnvt_xtoi (char c) #define Z_cnvt_xtoi(c) ((temp=(c)-'0'),(temp<10)?temp:((temp-='A'-'9'-1),(temp<16)?temp:-1)) -int ZReadAscii(ptr, len, field, num) +Code_t ZReadAscii(ptr, len, field, num) char *ptr; int len; unsigned char *field; @@ -51,9 +45,7 @@ int ZReadAscii(ptr, len, field, num) int i; unsigned int hexbyte; register int c1, c2; -#ifdef Z_cnvt_xtoi register unsigned int temp; -#endif for (i=0;i<num;i++) { if (*ptr == ' ') { @@ -83,3 +75,34 @@ int ZReadAscii(ptr, len, field, num) return *ptr ? ZERR_BADFIELD : ZERR_NONE; } + +Code_t ZReadAscii32(ptr, len, value_ptr) + char *ptr; + int len; + unsigned long *value_ptr; +{ + unsigned char buf[4]; + Code_t retval; + + retval = ZReadAscii(ptr, len, buf, 4); + if (retval != ZERR_NONE) + return retval; + *value_ptr = (buf[0] << 24) | (buf[1] << 16) | (buf[2] << 8) | buf[3]; + return ZERR_NONE; +} + +Code_t ZReadAscii16(ptr, len, value_ptr) + char *ptr; + int len; + unsigned short *value_ptr; +{ + unsigned char buf[2]; + Code_t retval; + + retval = ZReadAscii(ptr, len, buf, 2); + if (retval != ZERR_NONE) + return retval; + *value_ptr = (buf[0] << 8) | buf[1]; + return ZERR_NONE; +} + diff --git a/lib/ZRecvNot.c b/lib/ZRecvNot.c index 34de47b..4cd29bc 100644 --- a/lib/ZRecvNot.c +++ b/lib/ZRecvNot.c @@ -16,9 +16,7 @@ static char rcsid_ZReceiveNotice_c[] = "$Header$"; #endif -#include <zephyr/mit-copyright.h> - -#include <zephyr/zephyr_internal.h> +#include <internal.h> Code_t ZReceiveNotice(notice, from) ZNotice_t *notice; diff --git a/lib/ZRecvPkt.c b/lib/ZRecvPkt.c index 645aeba..13a6959 100644 --- a/lib/ZRecvPkt.c +++ b/lib/ZRecvPkt.c @@ -16,9 +16,7 @@ static char rcsid_ZReceivePacket_c[] = "$Header$"; #endif -#include <zephyr/mit-copyright.h> - -#include <zephyr/zephyr_internal.h> +#include <internal.h> Code_t ZReceivePacket(buffer, ret_len, from) ZPacket_t buffer; diff --git a/lib/ZRetSubs.c b/lib/ZRetSubs.c index 1366b4c..ddbff41 100644 --- a/lib/ZRetSubs.c +++ b/lib/ZRetSubs.c @@ -13,18 +13,23 @@ */ /* $Header$ */ +#include <internal.h> + #ifndef lint -static char rcsid_ZRetrieveSubscriptions_c[] = +static const char rcsid_ZRetrieveSubscriptions_c[] = "$Id$"; #endif -#include <zephyr/zephyr_internal.h> - static Code_t Z_RetSubs (); +/* Need STDC definition when possible for unsigned short argument. */ +#ifdef __STDC__ +Code_t ZRetrieveSubscriptions(unsigned short port, int *nsubs) +#else Code_t ZRetrieveSubscriptions(port,nsubs) - u_short port; + unsigned short port; int *nsubs; +#endif { int retval; ZNotice_t notice; @@ -33,9 +38,8 @@ Code_t ZRetrieveSubscriptions(port,nsubs) if (!port) /* use default port */ port = __Zephyr_port; - if ((retval = ZMakeAscii(asciiport,sizeof(asciiport), - (unsigned char *)&port, - sizeof(u_short))) != ZERR_NONE) + retval = ZMakeAscii16(asciiport, sizeof(asciiport), ntohs(port)); + if (retval != ZERR_NONE) return (retval); (void) memset((char *)¬ice, 0, sizeof(notice)); @@ -63,12 +67,13 @@ Code_t ZRetrieveDefaultSubscriptions(nsubs) static Code_t Z_RetSubs(notice, nsubs, auth_routine) register ZNotice_t *notice; int *nsubs; - int (*auth_routine)(); + Z_AuthProc auth_routine; { register int i; int retval,nrecv,gimmeack; ZNotice_t retnotice; char *ptr,*end,*ptr2; + ZSubscription_t *list = __subscriptions_list; retval = ZFlushSubscriptions(); @@ -92,7 +97,7 @@ static Code_t Z_RetSubs(notice, nsubs, auth_routine) nrecv = 0; gimmeack = 0; - __subscriptions_list = (ZSubscription_t *) 0; + list = (ZSubscription_t *) 0; while (!nrecv || !gimmeack) { retval = Z_WaitForNotice (&retnotice, ZCompareMultiUIDPred, @@ -135,46 +140,50 @@ static Code_t Z_RetSubs(notice, nsubs, auth_routine) __subscriptions_num = __subscriptions_num / 3; - __subscriptions_list = (ZSubscription_t *) - malloc((unsigned)(__subscriptions_num* - sizeof(ZSubscription_t))); - if (__subscriptions_num && !__subscriptions_list) { + list = (ZSubscription_t *) + malloc(__subscriptions_num * sizeof(ZSubscription_t)); + if (__subscriptions_num && !list) { ZFreeNotice(&retnotice); return (ENOMEM); } - for (ptr=retnotice.z_message,i = 0; i< __subscriptions_num; i++) { - __subscriptions_list[i].zsub_class = (char *) - malloc((unsigned)strlen(ptr)+1); - if (!__subscriptions_list[i].zsub_class) { + ptr = retnotice.z_message; + for (i = 0; i < __subscriptions_num; i++) { + list[i].zsub_class = (char *) + malloc(strlen(ptr) + 1); + if (!list[i].zsub_class) { ZFreeNotice(&retnotice); return (ENOMEM); } - (void) strcpy(__subscriptions_list[i].zsub_class,ptr); + strcpy(list[i].zsub_class, ptr); ptr += strlen(ptr)+1; - __subscriptions_list[i].zsub_classinst = (char *) - malloc((unsigned)strlen(ptr)+1); - if (!__subscriptions_list[i].zsub_classinst) { + list[i].zsub_classinst = (char *) + malloc(strlen(ptr) + 1); + if (!list[i].zsub_classinst) { ZFreeNotice(&retnotice); return (ENOMEM); } - (void) strcpy(__subscriptions_list[i].zsub_classinst,ptr); + strcpy(list[i].zsub_classinst, ptr); ptr += strlen(ptr)+1; ptr2 = ptr; - if (!*ptr2) - ptr2 = "*"; - __subscriptions_list[i].zsub_recipient = (char *) - malloc((unsigned)strlen(ptr2)+1); - if (!__subscriptions_list[i].zsub_recipient) { + list[i].zsub_recipient = (char *) + malloc(strlen(ptr2) + 2); + if (!list[i].zsub_recipient) { ZFreeNotice(&retnotice); return (ENOMEM); } - (void) strcpy(__subscriptions_list[i].zsub_recipient,ptr2); + if (*ptr2 == '@' || *ptr2 == 0) { + *list[i].zsub_recipient = '*'; + strcpy(list[i].zsub_recipient + 1, ptr2); + } else { + strcpy(list[i].zsub_recipient, ptr2); + } ptr += strlen(ptr)+1; } ZFreeNotice(&retnotice); } + __subscriptions_list = list; __subscriptions_next = 0; *nsubs = __subscriptions_num; diff --git a/lib/ZSendList.c b/lib/ZSendList.c index a7accfb..961975b 100644 --- a/lib/ZSendList.c +++ b/lib/ZSendList.c @@ -16,9 +16,7 @@ static char rcsid_ZSendList_c[] = "$Header$"; #endif -#include <zephyr/mit-copyright.h> - -#include <zephyr/zephyr_internal.h> +#include <internal.h> Code_t ZSendList(notice, list, nitems, cert_routine) ZNotice_t *notice; @@ -33,8 +31,8 @@ Code_t ZSrvSendList(notice, list, nitems, cert_routine, send_routine) ZNotice_t *notice; char *list[]; int nitems; - int (*cert_routine)(); - int (*send_routine)(); + Z_AuthProc cert_routine; + Code_t (*send_routine)(); { Code_t retval; ZNotice_t newnotice; diff --git a/lib/ZSendNot.c b/lib/ZSendNot.c index 3bd6f8a..18d31c0 100644 --- a/lib/ZSendNot.c +++ b/lib/ZSendNot.c @@ -16,21 +16,19 @@ static char rcsid_ZSendNotice_c[] = "$Header$"; #endif -#include <zephyr/mit-copyright.h> - -#include <zephyr/zephyr_internal.h> +#include <internal.h> Code_t ZSendNotice(notice, cert_routine) ZNotice_t *notice; - int (*cert_routine)(); + Z_AuthProc cert_routine; { return(ZSrvSendNotice(notice, cert_routine, Z_XmitFragment)); } Code_t ZSrvSendNotice(notice, cert_routine, send_routine) ZNotice_t *notice; - int (*cert_routine)(); - int (*send_routine)(); + Z_AuthProc cert_routine; + Code_t (*send_routine)(); { Code_t retval; ZNotice_t newnotice; diff --git a/lib/ZSendPkt.c b/lib/ZSendPkt.c index 019b989..d9c92f4 100644 --- a/lib/ZSendPkt.c +++ b/lib/ZSendPkt.c @@ -17,9 +17,7 @@ static char rcsid_ZSendPacket_c[] = "$Zephyr: /mit/zephyr/src/lib/RCS/ZSendPacket.c,v 1.29 91/03/21 11:57:08 raeburn Exp $"; #endif -#include <zephyr/mit-copyright.h> - -#include <zephyr/zephyr_internal.h> +#include <internal.h> #include <sys/socket.h> static int wait_for_hmack(); diff --git a/lib/ZSendRLst.c b/lib/ZSendRLst.c index b148a11..ef44d4a 100644 --- a/lib/ZSendRLst.c +++ b/lib/ZSendRLst.c @@ -16,9 +16,7 @@ static char rcsid_ZSendRawList_c[] = "$Header$"; #endif -#include <zephyr/mit-copyright.h> - -#include <zephyr/zephyr_internal.h> +#include <internal.h> Code_t ZSendRawList(notice, list, nitems) ZNotice_t *notice; @@ -32,7 +30,7 @@ Code_t ZSrvSendRawList(notice, list, nitems, send_routine) ZNotice_t *notice; char *list[]; int nitems; - int (*send_routine)(); + Code_t (*send_routine)(); { Code_t retval; ZNotice_t newnotice; diff --git a/lib/ZSendRaw.c b/lib/ZSendRaw.c index b9a633d..72e51e5 100644 --- a/lib/ZSendRaw.c +++ b/lib/ZSendRaw.c @@ -16,9 +16,7 @@ static char rcsid_ZSendRawNotice_c[] = "$Header$"; #endif -#include <zephyr/mit-copyright.h> - -#include <zephyr/zephyr_internal.h> +#include <internal.h> Code_t ZSendRawNotice(notice) ZNotice_t *notice; diff --git a/lib/ZSetDest.c b/lib/ZSetDest.c index dd16436..85e374d 100644 --- a/lib/ZSetDest.c +++ b/lib/ZSetDest.c @@ -16,9 +16,7 @@ static char rcsid_ZSetDestAddr_c[] = "$Header$"; #endif -#include <zephyr/mit-copyright.h> - -#include <zephyr/zephyr_internal.h> +#include <internal.h> Code_t ZSetDestAddr(addr) struct sockaddr_in *addr; diff --git a/lib/ZSetFD.c b/lib/ZSetFD.c index 40388f5..1d048ea 100644 --- a/lib/ZSetFD.c +++ b/lib/ZSetFD.c @@ -16,9 +16,7 @@ static char rcsid_ZSetFD_c[] = "$Header$"; #endif -#include <zephyr/mit-copyright.h> - -#include <zephyr/zephyr_internal.h> +#include <internal.h> Code_t ZSetFD(fd) int fd; diff --git a/lib/ZSetSrv.c b/lib/ZSetSrv.c index bc15016..7e62310 100644 --- a/lib/ZSetSrv.c +++ b/lib/ZSetSrv.c @@ -16,9 +16,7 @@ static char rcsid_ZSetServerState_c[] = "$Header$"; #endif -#include <zephyr/mit-copyright.h> - -#include <zephyr/zephyr_internal.h> +#include <internal.h> Code_t ZSetServerState(state) int state; diff --git a/lib/ZSubs.c b/lib/ZSubs.c index 99939fd..784483d 100644 --- a/lib/ZSubs.c +++ b/lib/ZSubs.c @@ -13,16 +13,22 @@ */ /* $Header$ */ +#include <internal.h> + #ifndef lint -static char rcsid_ZSubscriptions_c[] = "$Id$"; +static const char rcsid_ZSubscriptions_c[] = "$Id$"; #endif -#include <zephyr/zephyr_internal.h> +static Code_t Z_Subscriptions __P((register ZSubscription_t *sublist, + int nitems, unsigned int port, + char *opcode, int authit)); +static Code_t subscr_sendoff __P((ZNotice_t *notice, char **lyst, int num, + int authit)); Code_t ZSubscribeTo(sublist, nitems, port) ZSubscription_t *sublist; int nitems; - u_short port; + unsigned int port; { return (Z_Subscriptions(sublist, nitems, port, CLIENT_SUBSCRIBE, 1)); } @@ -30,7 +36,7 @@ Code_t ZSubscribeTo(sublist, nitems, port) Code_t ZSubscribeToSansDefaults(sublist, nitems, port) ZSubscription_t *sublist; int nitems; - u_short port; + unsigned int port; { return (Z_Subscriptions(sublist, nitems, port, CLIENT_SUBSCRIBE_NODEFS, 1)); @@ -39,30 +45,29 @@ Code_t ZSubscribeToSansDefaults(sublist, nitems, port) Code_t ZUnsubscribeTo(sublist, nitems, port) ZSubscription_t *sublist; int nitems; - u_short port; + unsigned int port; { return (Z_Subscriptions(sublist, nitems, port, CLIENT_UNSUBSCRIBE, 1)); } Code_t ZCancelSubscriptions(port) - u_short port; + unsigned int port; { return (Z_Subscriptions((ZSubscription_t *)0, 0, port, CLIENT_CANCELSUB, 0)); } -static Code_t subscr_sendoff(); - /* * This routine must do its own fragmentation. Subscriptions must * not be broken across packet boundaries, or else the server will * mis-interpret them. */ +static Code_t Z_Subscriptions(sublist, nitems, port, opcode, authit) register ZSubscription_t *sublist; int nitems; - u_short port; + unsigned int port; char *opcode; int authit; { @@ -71,6 +76,7 @@ Z_Subscriptions(sublist, nitems, port, opcode, authit) ZNotice_t notice; char header[Z_MAXHEADERLEN]; char **list; + char *recip; int hdrlen; int size_avail = Z_MAXPKTLEN-Z_FRAGFUDGE; /* space avail for data, adjusted below */ @@ -98,7 +104,7 @@ Z_Subscriptions(sublist, nitems, port, opcode, authit) retval = Z_FormatHeader(¬ice, header, sizeof(header), &hdrlen, ZAUTH); if (retval != ZERR_NONE && !authit) retval = Z_FormatHeader(¬ice, header, sizeof(header), - &hdrlen, ZAUTH); + &hdrlen, ZNOAUTH); if (retval != ZERR_NONE) { free((char *)list); return(retval); @@ -112,11 +118,12 @@ Z_Subscriptions(sublist, nitems, port, opcode, authit) for (i=0;i<nitems;i++) { list[i*3] = sublist[i].zsub_class; list[i*3+1] = sublist[i].zsub_classinst; - if (sublist[i].zsub_recipient && *sublist[i].zsub_recipient && - *sublist[i].zsub_recipient != '*') - list[i*3+2] = ZGetSender(); - else - list[i*3+2] = ""; + recip = sublist[i].zsub_recipient; + if (recip && *recip == '*') + recip++; + if (!recip || (*recip != 0 && *recip != '@')) + recip = ZGetSender(); + list[i*3+2] = recip; } start = -1; diff --git a/lib/ZVariables.c b/lib/ZVariables.c index 06de7bf..36635cd 100644 --- a/lib/ZVariables.c +++ b/lib/ZVariables.c @@ -17,15 +17,14 @@ static char rcsid_ZVariables_c[] = "$Header$"; #endif -#include <zephyr/mit-copyright.h> -#include <zephyr/zephyr_internal.h> +#include <internal.h> #include <ctype.h> #include <pwd.h> -static int get_localvarfile(); -static char *get_varval(); -static int varline(); +static int get_localvarfile __P((char *bfr)); +static char *get_varval __P((char *fn, char *val)); +static int varline __P((char *bfr, char *var)); char *ZGetVariable(var) char *var; @@ -36,10 +35,11 @@ char *ZGetVariable(var) if (get_localvarfile(varfile)) return ((char *)0); - if (ret = get_varval(varfile, var)) + if ((ret = get_varval(varfile, var)) != ZERR_NONE) return (ret); - return (get_varval(DEFAULT_VARS_FILE, var)); + sprintf(varfile, "%s/zephyr.vars", CONFDIR); + return (get_varval(varfile, var)); } Code_t ZSetVariable(var, value) @@ -60,7 +60,7 @@ Code_t ZSetVariable(var, value) if (!(fpout = fopen(varfilebackup, "w"))) return (errno); - if (fpin = fopen(varfile, "r")) { + if ((fpin = fopen(varfile, "r")) != NULL) { while (fgets(varbfr, sizeof varbfr, fpin) != (char *) 0) { if (varbfr[strlen(varbfr)-1] < ' ') varbfr[strlen(varbfr)-1] = '\0'; @@ -96,7 +96,7 @@ Code_t ZUnsetVariable(var) if (!(fpout = fopen(varfilebackup, "w"))) return (errno); - if (fpin = fopen(varfile, "r")) { + if ((fpin = fopen(varfile, "r")) != NULL) { while (fgets(varbfr, sizeof varbfr, fpin) != (char *) 0) { if (varbfr[strlen(varbfr)-1] < ' ') varbfr[strlen(varbfr)-1] = '\0'; @@ -112,7 +112,7 @@ Code_t ZUnsetVariable(var) return (ZERR_NONE); } -static get_localvarfile(bfr) +static int get_localvarfile(bfr) char *bfr; { char *envptr; @@ -123,7 +123,7 @@ static get_localvarfile(bfr) (void) strcpy(bfr, envptr); else { if (!(pwd = getpwuid((int) getuid()))) { - fprintf(stderr, "Zephyr internal failure: Can't find your entry in /etc/passwd\n"); + fprintf(stderr, "Zephyr internal failure: Can't determine your home directory.\n"); return (1); } (void) strcpy(bfr, pwd->pw_dir); diff --git a/lib/ZWait4Not.c b/lib/ZWait4Not.c index c550ae0..7cdb408 100644 --- a/lib/ZWait4Not.c +++ b/lib/ZWait4Not.c @@ -12,23 +12,19 @@ * "mit-copyright.h". */ -#include <zephyr/mit-copyright.h> +#include "mit-copyright.h" #ifndef lint -static char rcsid_ZWaitForNotice_c[] = - "$Zephyr$"; +static char rcsid_ZWaitForNotice_c[] = "$Zephyr$"; #endif -#include <zephyr/zephyr.h> -#ifdef _AIX -#include <sys/select.h> -#endif +#include <internal.h> +#include <sys/socket.h> -Code_t -Z_WaitForNotice (notice, pred, uid, timeout) +Code_t Z_WaitForNotice (notice, pred, arg, timeout) ZNotice_t *notice; - int (*pred) (); - ZUnique_Id_t *uid; + int (*pred) __P((ZNotice_t *, void *)); + void *arg; int timeout; { Code_t retval; @@ -37,7 +33,7 @@ Z_WaitForNotice (notice, pred, uid, timeout) int i, fd; retval = ZCheckIfNotice (notice, (struct sockaddr_in *) 0, pred, - (char *) uid); + (char *) arg); if (retval == ZERR_NONE) return ZERR_NONE; if (retval != ZERR_NONOTICE) @@ -58,7 +54,7 @@ Z_WaitForNotice (notice, pred, uid, timeout) return errno; if (i > 0) { retval = ZCheckIfNotice (notice, (struct sockaddr_in *) 0, pred, - (char *) uid); + (char *) arg); if (retval != ZERR_NONOTICE) /* includes ZERR_NONE */ return retval; } diff --git a/lib/ZhmStat.c b/lib/ZhmStat.c new file mode 100644 index 0000000..80f8ed4 --- /dev/null +++ b/lib/ZhmStat.c @@ -0,0 +1,88 @@ +/* This file is part of the Project Athena Zephyr Notification System. + * It contains the ZhmStat() function. + * + * Created by: Marc Horowitz + * + * $Source$ + * $Author$ + * + * Copyright (c) 1996 by the Massachusetts Institute of Technology. + * For copying and distribution information, see the file + * "mit-copyright.h". + */ + +#include <internal.h> +#include <sys/socket.h> + +static int outoftime = 0; + +static RETSIGTYPE timeout() +{ + outoftime = 1; +} + +Code_t ZhmStat(hostaddr, notice) + struct in_addr *hostaddr; + ZNotice_t *notice; +{ + struct servent *sp; + struct sockaddr_in sin; + ZNotice_t req; + Code_t code; +#ifdef _POSIX_VERSION + struct sigaction sa; +#endif + + (void) memset((char *)&sin, 0, sizeof(struct sockaddr_in)); + + sp = getservbyname(HM_SVCNAME, "udp"); + + sin.sin_port = (sp) ? sp->s_port : HM_SVC_FALLBACK; + sin.sin_family = AF_INET; + + if (hostaddr) + sin.sin_addr = *hostaddr; + else + sin.sin_addr.s_addr = htonl(INADDR_LOOPBACK); + + (void) memset((char *)&req, 0, sizeof(req)); + req.z_kind = STAT; + req.z_port = 0; + req.z_class = HM_STAT_CLASS; + req.z_class_inst = HM_STAT_CLIENT; + req.z_opcode = HM_GIMMESTATS; + req.z_sender = ""; + req.z_recipient = ""; + req.z_default_format = ""; + req.z_message_len = 0; + + if ((code = ZSetDestAddr(&sin)) != ZERR_NONE) + return(code); + + if ((code = ZSendNotice(&req, ZNOAUTH)) != ZERR_NONE) + return(code); + +#ifdef _POSIX_VERSION + sigemptyset(&sa.sa_mask); + sa.sa_flags = 0; + sa.sa_handler = timeout; + (void) sigaction(SIGALRM, &sa, (struct sigaction *)0); +#else + (void) signal(SIGALRM,timeout); +#endif + + outoftime = 0; + (void) alarm(10); + + if (((code = ZReceiveNotice(notice, (struct sockaddr_in *) 0)) + != ZERR_NONE) && + code != EINTR) + return(code); + + (void) alarm(0); + + if (outoftime) + return(ZERR_HMDEAD); + + return(ZERR_NONE); +} diff --git a/lib/Zinternal.c b/lib/Zinternal.c index 7cd24cc..019bafd 100644 --- a/lib/Zinternal.c +++ b/lib/Zinternal.c @@ -13,30 +13,16 @@ */ /* $Header$ */ -#ifndef lint -static char rcsid_Zinternal_c[] = - "$Id$"; -static char copyright[] = - "Copyright (c) 1987,1988,1991 by the Massachusetts Institute of Technology."; -#endif - -#include <zephyr/zephyr_internal.h> -#include <netdb.h> +#include <internal.h> #include <arpa/inet.h> -#include <sys/param.h> #include <sys/socket.h> -#include <sys/ioctl.h> #include <utmp.h> -#include <krb.h> -#ifdef SOLARIS -#include <sys/filio.h> -#endif - -#ifdef __STDC__ -typedef void *pointer; -#else -typedef char *pointer; +#ifndef lint +static const char rcsid_Zinternal_c[] = + "$Id$"; +static const char copyright[] = + "Copyright (c) 1987,1988,1991 by the Massachusetts Institute of Technology."; #endif extern char *inet_ntoa (); @@ -60,17 +46,21 @@ ZSubscription_t *__subscriptions_list; int __subscriptions_num; int __subscriptions_next; -#ifdef Z_HaveKerberos +#ifdef ZEPHYR_USES_KERBEROS C_Block __Zephyr_session; char __Zephyr_realm[REALM_SZ]; #endif #ifdef Z_DEBUG -void (*__Z_debug_print) Zproto((const char *fmt, va_list args, void *closure)); +void (*__Z_debug_print) __P((const char *fmt, va_list args, void *closure)); +void *__Z_debug_print_closure; #endif #define min(a,b) ((a)<(b)?(a):(b)) +static int Z_AddField __P((char **ptr, char *field, char *end)); +static int find_or_insert_uid __P((ZUnique_Id_t *uid, ZNotice_Kind_t kind)); + /* Find or insert uid in the old uids buffer. The buffer is a sorted * circular queue. We make the assumption that most packets arrive in * order, so we can usually search for a uid or insert it into the buffer @@ -177,12 +167,13 @@ Code_t Z_GetMyAddr() int Z_PacketWaiting() { - int bytes; - - if (ioctl(ZGetFD(), FIONREAD, (char *)&bytes) < 0) - return (0); + struct timeval tv; + fd_set read; - return (bytes > 0); + tv.tv_sec = tv.tv_usec = 0; + FD_ZERO(&read); + FD_SET(ZGetFD(), &read); + return (select(ZGetFD() + 1, &read, NULL, NULL, &tv)); } @@ -266,7 +257,6 @@ Code_t Z_ReadWait() int from_len, packet_len, part, partof; char *slash; Code_t retval; - static int filter_idx = -1; register int i; if (ZGetFD() < 0) @@ -288,7 +278,7 @@ Code_t Z_ReadWait() if (packet[i]) goto not_all_null; #ifdef Z_DEBUG - Z_debug ("got null packet from %s", inet_ntoa (from.sin_addr.s_addr)); + Z_debug ("got null packet from %s", inet_ntoa (from.sin_addr)); #endif return ZERR_NONE; not_all_null: @@ -613,7 +603,7 @@ Code_t Z_FormatHeader(notice, buffer, buffer_len, len, cert_routine) char *buffer; int buffer_len; int *len; - int (*cert_routine)(); + Z_AuthProc cert_routine; { Code_t retval; static char version[BUFSIZ]; /* default init should be all \0 */ @@ -661,7 +651,7 @@ Code_t Z_FormatAuthHeader(notice, buffer, buffer_len, len, cert_routine) char *buffer; int buffer_len; int *len; - int (*cert_routine)(); + Z_AuthProc cert_routine; { if (!cert_routine) { notice->z_auth = 0; @@ -682,10 +672,6 @@ Code_t Z_FormatRawHeader(notice, buffer, buffer_len, len, cstart, cend) int *len; char **cstart, **cend; { - union { - int i; - ZChecksum_t sum; - } temp; char newrecip[BUFSIZ]; char *ptr, *end; int i; @@ -714,36 +700,29 @@ Code_t Z_FormatRawHeader(notice, buffer, buffer_len, len, cstart, cend) (void) strcpy(ptr, notice->z_version); ptr += strlen(ptr)+1; - temp.i = htonl((u_long) (ZNUMFIELDS+notice->z_num_other_fields)); - if (ZMakeAscii(ptr, end-ptr, (unsigned char *)&temp.i, - sizeof(temp.i)) == ZERR_FIELDLEN) + if (ZMakeAscii32(ptr, end-ptr, Z_NUMFIELDS + notice->z_num_other_fields) + == ZERR_FIELDLEN) return (ZERR_HEADERLEN); ptr += strlen(ptr)+1; - - temp.i = htonl((u_long) notice->z_kind); - if (ZMakeAscii(ptr, end-ptr, (unsigned char *)&temp.i, - sizeof(temp.i)) == ZERR_FIELDLEN) + + if (ZMakeAscii32(ptr, end-ptr, notice->z_kind) == ZERR_FIELDLEN) return (ZERR_HEADERLEN); ptr += strlen(ptr)+1; - + if (ZMakeAscii(ptr, end-ptr, (unsigned char *)¬ice->z_uid, sizeof(ZUnique_Id_t)) == ZERR_FIELDLEN) return (ZERR_HEADERLEN); ptr += strlen(ptr)+1; - - if (ZMakeAscii(ptr, end-ptr, (unsigned char *)¬ice->z_port, - sizeof(u_short)) == ZERR_FIELDLEN) + + if (ZMakeAscii16(ptr, end-ptr, ntohs(notice->z_port)) == ZERR_FIELDLEN) return (ZERR_HEADERLEN); ptr += strlen(ptr)+1; - if (ZMakeAscii(ptr, end-ptr, (unsigned char *)¬ice->z_auth, - sizeof(int)) == ZERR_FIELDLEN) + if (ZMakeAscii32(ptr, end-ptr, notice->z_auth) == ZERR_FIELDLEN) return (ZERR_HEADERLEN); ptr += strlen(ptr)+1; - temp.i = htonl((u_long) notice->z_authent_len); - if (ZMakeAscii(ptr, end-ptr, (unsigned char *)&temp.i, - sizeof(temp.i)) == ZERR_FIELDLEN) + if (ZMakeAscii32(ptr, end-ptr, notice->z_authent_len) == ZERR_FIELDLEN) return (ZERR_HEADERLEN); ptr += strlen(ptr)+1; @@ -762,8 +741,7 @@ Code_t Z_FormatRawHeader(notice, buffer, buffer_len, len, cstart, cend) return (ZERR_HEADERLEN); } else { - (void) sprintf(newrecip, "%s@%s", notice->z_recipient, - __Zephyr_realm); + (void) sprintf(newrecip, "%s@%s", notice->z_recipient, __Zephyr_realm); if (Z_AddField(&ptr, newrecip, end)) return (ZERR_HEADERLEN); } @@ -773,9 +751,7 @@ Code_t Z_FormatRawHeader(notice, buffer, buffer_len, len, cstart, cend) /* copy back the end pointer location for crypto checksum */ if (cstart) *cstart = ptr; - temp.sum = htonl(notice->z_checksum); - if (ZMakeAscii(ptr, end-ptr, (unsigned char *)&temp.sum, - sizeof(temp.sum)) == ZERR_FIELDLEN) + if (ZMakeAscii32(ptr, end-ptr, notice->z_checksum) == ZERR_FIELDLEN) return (ZERR_HEADERLEN); ptr += strlen(ptr)+1; if (cend) @@ -793,19 +769,12 @@ Code_t Z_FormatRawHeader(notice, buffer, buffer_len, len, cstart, cend) if (Z_AddField(&ptr, notice->z_other_fields[i], end)) return (ZERR_HEADERLEN); -#ifdef notdef - temp = htonl(notice->z_checksum); - if (ZMakeAscii(ptr, end-ptr, (unsigned char *)&temp, - sizeof(ZChecksum_t)) == ZERR_FIELDLEN) - return (ZERR_HEADERLEN); - ptr += strlen(ptr)+1; -#endif - *len = ptr-buffer; return (ZERR_NONE); } +static int Z_AddField(ptr, field, end) char **ptr, *field, *end; { @@ -904,8 +873,8 @@ void Z_RemQueue(qptr) Code_t Z_SendFragmentedNotice(notice, len, cert_func, send_func) ZNotice_t *notice; int len; - Code_t (*cert_func)(); - Code_t (*send_func)(); + Z_AuthProc cert_func; + Z_SendProc send_func; { ZNotice_t partnotice; ZPacket_t buffer; @@ -970,56 +939,50 @@ int wait; #ifdef Z_DEBUG /* For debugging printing */ -Zconst char *Zconst ZNoticeKinds[] = { "UNSAFE", "UNACKED", "ACKED", "HMACK", - "HMCTL", "SERVACK", "SERVNAK", - "CLIENTACK", "STAT"}; +const char *const ZNoticeKinds[] = { + "UNSAFE", "UNACKED", "ACKED", "HMACK", "HMCTL", "SERVACK", "SERVNAK", + "CLIENTACK", "STAT" +}; #endif #ifdef Z_DEBUG #undef Z_debug -#ifdef Z_varargs -void Z_debug (va_alist) va_dcl +#ifdef HAVE_STDARG_H +void Z_debug (const char *format, ...) { va_list pvar; - char *format; if (!__Z_debug_print) return; - va_start (pvar); - format = va_arg (pvar, char *); + va_start (pvar, format); (*__Z_debug_print) (format, pvar, __Z_debug_print_closure); va_end (pvar); } #else /* stdarg */ -void Z_debug (const char *format, ...) +void Z_debug (va_alist) va_dcl { va_list pvar; + char *format; if (!__Z_debug_print) return; - va_start (pvar, format); + va_start (pvar); + format = va_arg (pvar, char *); (*__Z_debug_print) (format, pvar, __Z_debug_print_closure); va_end (pvar); } #endif void Z_debug_stderr (format, args, closure) -#ifdef __STDC__ - const -#endif - char *format; + const char *format; va_list args; -#ifdef __STDC__ void *closure; -#else - char *closure; -#endif { -#ifndef NO_VPRINTF - vfprintf (stderr, format, args); +#ifdef HAVE_VPRINTF + vfprintf (stderr, format, args); #else - _doprnt (format, args, stderr); + _doprnt (format, args, stderr); #endif - putc ('\n', stderr); + putc ('\n', stderr); } #undef ZGetFD @@ -1034,14 +997,13 @@ struct sockaddr_in ZGetDestAddr () { return __HM_addr; } #undef ZGetRealm Zconst char * ZGetRealm () { return __Zephyr_realm; } -#ifdef __STDC__ -#define ARGS (void (*proc)(const char *,va_list,void *), void *arg) -#else -#define ARGS (proc, arg) void (*proc)(); char *arg; -#endif #undef ZSetDebug -void ZSetDebug ARGS { +void ZSetDebug(proc, arg) + void (*proc) __P((const char *, va_list, void *)); + char *arg; +{ __Z_debug_print = proc; __Z_debug_print_closure = arg; } #endif /* Z_DEBUG */ + diff --git a/lib/acl_files.c b/lib/acl_files.c deleted file mode 100644 index 7025b1b..0000000 --- a/lib/acl_files.c +++ /dev/null @@ -1,556 +0,0 @@ -/* This file is part of the Project Athena Zephyr Notification System. - * It contains functions for maintaining Access Control Lists. - * - * Created by: John T. Kohl - * - * $Source$ - * $Author$ - * - * Copyright (c) 1987,1988 by the Massachusetts Institute of Technology. - * For copying and distribution information, see the file - * "mit-copyright.h". - */ - -/* Define this if you really want the ACL-writing code included. */ -/* #define WRITE_ACL */ - -/* - * Stolen from lib/acl_files.c because acl_load needs to be externally - * declared and not statically declared. - */ - -#ifndef lint -static char rcsid_acl_files_c[] = "$Id$"; -#endif - -/*** Routines for manipulating access control list files ***/ - -#include <zephyr/zephyr.h> -#include <string.h> -#include <sys/file.h> -#include <fcntl.h> -#include <sys/stat.h> -#include <ctype.h> -#include <sys/param.h> /* for MAXHOSTNAMELEN */ -#include <errno.h> - -/* "aname.inst@realm" */ -#define MAX_PRINCIPAL_SIZE (ANAME_SZ + INST_SZ + REALM_SZ + 3) -#define INST_SEP '.' -#define REALM_SEP '@' - -#define LINESIZE 2048 /* Maximum line length in an acl file */ - -#define NEW_FILE "%s.~NEWACL~" /* Format for name of altered acl file */ -#define WAIT_TIME 300 /* Maximum time allowed write acl file */ - -#define CACHED_ACLS 64 /* How many acls to cache */ -#define ACL_LEN 256 /* Twice a reasonable acl length */ - -#ifndef MAX -#define MAX(a,b) (((a)>(b))?(a):(b)) -#define MIN(a,b) (((a)<(b))?(a):(b)) -#endif - -#define COR(a,b) ((a!=NULL)?(a):(b)) - -/* Canonicalize a principal name */ -/* If instance is missing, it becomes "" */ -/* If realm is missing, it becomes the local realm */ -/* Canonicalized form is put in canon, which must be big enough to hold - MAX_PRINCIPAL_SIZE characters */ -acl_canonicalize_principal(principal, canon) - char *principal; - char *canon; -{ - char *dot, *atsign, *end; - int len; - - dot = (char *)strchr(principal, INST_SEP); - atsign = (char *)strchr(principal, REALM_SEP); - - /* Maybe we're done already */ - if(dot != NULL && atsign != NULL) { - if(dot < atsign) { - /* It's for real */ - /* Copy into canon */ - strncpy(canon, principal, MAX_PRINCIPAL_SIZE); - canon[MAX_PRINCIPAL_SIZE-1] = '\0'; - return; - } else { - /* Nope, it's part of the realm */ - dot = NULL; - } - } - - /* No such luck */ - end = principal + strlen(principal); - - /* Get the principal name */ - len = MIN(ANAME_SZ, COR(dot, COR(atsign, end)) - principal); - strncpy(canon, principal, len); - canon += len; - - /* Add INST_SEP */ - *canon++ = INST_SEP; - - /* Get the instance, if it exists */ - if(dot != NULL) { - ++dot; - len = MIN(INST_SZ, COR(atsign, end) - dot); - strncpy(canon, dot, len); - canon += len; - } - - /* Add REALM_SEP */ - *canon++ = REALM_SEP; - - /* Get the realm, if it exists */ - /* Otherwise, default to local realm */ - if(atsign != NULL) { - ++atsign; - len = MIN(REALM_SZ, end - atsign); - strncpy(canon, atsign, len); - canon += len; - *canon++ = '\0'; - } -#ifdef Z_HaveKerberos - else if(krb_get_lrealm(canon, 1) != KSUCCESS) { - strcpy(canon, KRB_REALM); - } -#endif -} - -/* Get a lock to modify acl_file */ -/* Return new FILE pointer */ -/* or NULL if file cannot be modified */ -/* REQUIRES WRITE PERMISSION TO CONTAINING DIRECTORY */ -static FILE *acl_lock_file(acl_file) - char *acl_file; -{ - struct stat s; - char new[LINESIZE]; - int nfd; - FILE *nf; - int mode; - - if(stat(acl_file, &s) < 0) return(NULL); - mode = s.st_mode; - sprintf(new, NEW_FILE, acl_file); - for(;;) { - /* Open the new file */ - if((nfd = open(new, O_WRONLY|O_CREAT|O_EXCL, mode)) < 0) { - if(errno == EEXIST) { - /* Maybe somebody got here already, maybe it's just old */ - if(stat(new, &s) < 0) return(NULL); - if(time(0) - s.st_ctime > WAIT_TIME) { - /* File is stale, kill it */ - unlink(new); - continue; - } else { - /* Wait and try again */ - sleep(1); - continue; - } - } else { - /* Some other error, we lose */ - return(NULL); - } - } - - /* If we got to here, the lock file is ours and ok */ - /* Reopen it under stdio */ - if((nf = fdopen(nfd, "w")) == NULL) { - /* Oops, clean up */ - unlink(new); - } - return(nf); - } -} - -/* Commit changes to acl_file written onto FILE *f */ -/* Returns zero if successful */ -/* Returns > 0 if lock was broken */ -/* Returns < 0 if some other error occurs */ -/* Closes f */ -static int acl_commit(acl_file, f) - char *acl_file; - FILE *f; -{ -#ifdef WRITE_ACL - char new[LINESIZE]; - int ret; - struct stat s; - - sprintf(new, NEW_FILE, acl_file); - if(fflush(f) < 0 - || fstat(fileno(f), &s) < 0 - || s.st_nlink == 0) { - acl_abort(acl_file, f); - return(-1); - } - - ret = rename(new, acl_file); - fclose(f); - return(ret); -#else - abort (); -#endif -} - -/* Abort changes to acl_file written onto FILE *f */ -/* Returns 0 if successful, < 0 otherwise */ -/* Closes f */ -static int acl_abort(acl_file, f) - char *acl_file; - FILE *f; -{ -#ifdef WRITE_ACL - char new[LINESIZE]; - int ret; - struct stat s; - - /* make sure we aren't nuking someone else's file */ - if(fstat(fileno(f), &s) < 0 - || s.st_nlink == 0) { - fclose(f); - return(-1); - } else { - sprintf(new, NEW_FILE, acl_file); - ret = unlink(new); - fclose(f); - return(ret); - } -#else - abort (); -#endif -} - -/* Initialize an acl_file */ -/* Creates the file with permissions perm if it does not exist */ -/* Erases it if it does */ -/* Returns return value of acl_commit */ -int -acl_initialize(acl_file, perm) - char *acl_file; - int perm; -{ - FILE *new; - int fd; - - /* Check if the file exists already */ - if((new = acl_lock_file(acl_file)) != NULL) { - return(acl_commit(acl_file, new)); - } else { - /* File must be readable and writable by owner */ - if((fd = open(acl_file, O_CREAT|O_EXCL, perm|0600)) < 0) { - return(-1); - } else { - close(fd); - return(0); - } - } -} - -/* Eliminate all whitespace character in buf */ -/* Modifies its argument */ -static nuke_whitespace(buf) - char *buf; -{ - register char *pin, *pout; - - for(pin = pout = buf; *pin != '\0'; pin++) - if(!isspace(*pin)) *pout++ = *pin; - *pout = '\0'; /* Terminate the string */ -} - -/* Hash table stuff */ - -struct hashtbl { - int size; /* Max number of entries */ - int entries; /* Actual number of entries */ - char **tbl; /* Pointer to start of table */ -}; - -/* Make an empty hash table of size s */ -static struct hashtbl *make_hash(size) - int size; -{ - struct hashtbl *h; - - if(size < 1) size = 1; - h = (struct hashtbl *) malloc(sizeof(struct hashtbl)); - h->size = size; - h->entries = 0; - h->tbl = (char **) calloc(size, sizeof(char *)); - return(h); -} - -/* Destroy a hash table */ -static void -destroy_hash(h) - struct hashtbl *h; -{ - int i; - - for(i = 0; i < h->size; i++) { - if(h->tbl[i] != NULL) free(h->tbl[i]); - } - free(h->tbl); - free(h); -} - -/* Compute hash value for a string */ -static unsigned int -hashval(s) - register char *s; -{ - register unsigned hv; - - for(hv = 0; *s != '\0'; s++) { - hv ^= ((hv << 3) ^ *s); - } - return(hv); -} - -/* Add an element to a hash table */ -static add_hash(h, el) - struct hashtbl *h; - char *el; -{ - unsigned hv; - char *s; - char **old; - int i; - - /* Make space if it isn't there already */ - if(h->entries + 1 > (h->size >> 1)) { - old = h->tbl; - h->tbl = (char **) calloc(h->size << 1, sizeof(char *)); - for(i = 0; i < h->size; i++) { - if(old[i] != NULL) { - hv = hashval(old[i]) % (h->size << 1); - while(h->tbl[hv] != NULL) hv = (hv+1) % (h->size << 1); - h->tbl[hv] = old[i]; - } - } - h->size = h->size << 1; - free(old); - } - - hv = hashval(el) % h->size; - while(h->tbl[hv] != NULL && strcmp(h->tbl[hv], el)) hv = (hv+1) % h->size; - s = (char *) malloc(strlen(el)+1); - strcpy(s, el); - h->tbl[hv] = s; - h->entries++; -} - -/* Returns nonzero if el is in h */ -static int -check_hash(h, el) - struct hashtbl *h; - char *el; -{ - unsigned hv; - - for(hv = hashval(el) % h->size; h->tbl[hv]; hv = (hv + 1) % h->size) { - if (!strcmp(h->tbl[hv], el)) { - return 1; - } - } - return 0; -} - -struct acl { - char filename[LINESIZE]; /* Name of acl file */ - struct hashtbl *acl; /* Acl entries */ -}; - -static struct acl acl_cache[CACHED_ACLS]; - -static int acl_cache_count = 0; -static int acl_cache_next = 0; - -/* Returns < 0 if unsuccessful in loading acl */ -/* Returns index into acl_cache otherwise */ -/* Note that if acl is already loaded, this is just a lookup */ -int acl_load(name) - char *name; -{ - int i; - FILE *f; - char buf[MAX_PRINCIPAL_SIZE]; - char canon[MAX_PRINCIPAL_SIZE]; - - /* See if it's there already */ - for(i = 0; i < acl_cache_count; i++) { - if (!strcmp(acl_cache[i].filename, name)) - goto got_it; - } - - /* It isn't, load it in */ - /* maybe there's still room */ - if(acl_cache_count < CACHED_ACLS) { - i = acl_cache_count++; - } else { - /* No room, clean one out */ - i = acl_cache_next; - acl_cache_next = (acl_cache_next + 1) % CACHED_ACLS; - if(acl_cache[i].acl) { - destroy_hash(acl_cache[i].acl); - acl_cache[i].acl = (struct hashtbl *) 0; - } - } - - /* Set up the acl */ - strcpy(acl_cache[i].filename, name); - /* Force reload */ - acl_cache[i].acl = (struct hashtbl *) 0; - -got_it: - /* - * See if we need to reload the ACL - */ - if (acl_cache[i].acl == (struct hashtbl *) 0) { - /* Gotta reload */ - if ((f = fopen(name, "r")) == NULL) { - return -1; - } - if (acl_cache[i].acl) destroy_hash(acl_cache[i].acl); - acl_cache[i].acl = make_hash(ACL_LEN); - while(fgets(buf, sizeof(buf), f) != NULL) { - nuke_whitespace(buf); - acl_canonicalize_principal(buf, canon); - add_hash(acl_cache[i].acl, canon); - } - fclose(f); - } - return(i); -} - -/* - * This destroys all cached ACL's so that new ones will be loaded in - * the next time they are requested. - */ -acl_cache_reset() -{ - int i; - - /* See if it's there already */ - for(i = 0; i < acl_cache_count; i++) - if (acl_cache[i].acl) { - destroy_hash(acl_cache[i].acl); - acl_cache[i].acl = (struct hashtbl *) 0; - } - acl_cache_count = 0; - acl_cache_next = 0; -} - - -/* Returns nonzero if it can be determined that acl contains principal */ -/* Principal is not canonicalized, and no wildcarding is done */ -acl_exact_match(acl, principal) - char *acl; - char *principal; -{ - int idx; - - return((idx = acl_load(acl)) >= 0 - && check_hash(acl_cache[idx].acl, principal)); -} - -/* Returns nonzero if it can be determined that acl contains principal */ -/* Recognizes wildcards in acl of the form - name.*@realm, *.*@realm, and *.*@* */ -acl_check(acl, principal) - char *acl; - char *principal; -{ - char buf[MAX_PRINCIPAL_SIZE]; - char canon[MAX_PRINCIPAL_SIZE]; - char *realm; - - acl_canonicalize_principal(principal, canon); - - /* Is it there? */ - if (acl_exact_match(acl, canon)) - return 1; - - /* Try the wildcards */ - realm = (char *)strchr(canon, REALM_SEP); - *((char *)strchr(canon, INST_SEP)) = '\0'; /* Chuck the instance */ - - sprintf(buf, "%s.*%s", canon, realm); - if(acl_exact_match(acl, buf)) return 1; - - sprintf(buf, "*.*%s", realm); - if(acl_exact_match(acl, buf) || acl_exact_match(acl, "*.*@*")) return(1); - - return(0); -} - -/* Adds principal to acl */ -/* Wildcards are interpreted literally */ -acl_add(acl, principal) - char *acl; - char *principal; -{ - int idx; - int i; - FILE *new; - char canon[MAX_PRINCIPAL_SIZE]; - - acl_canonicalize_principal(principal, canon); - - if((new = acl_lock_file(acl)) == NULL) return(-1); - if((acl_exact_match(acl, canon)) - || (idx = acl_load(acl)) < 0) { - acl_abort(acl, new); - return(-1); - } - /* It isn't there yet, copy the file and put it in */ - for(i = 0; i < acl_cache[idx].acl->size; i++) { - if(acl_cache[idx].acl->tbl[i] != NULL) { - if(fputs(acl_cache[idx].acl->tbl[i], new) == 0 - || putc('\n', new) != '\n') { - acl_abort(acl, new); - return(-1); - } - } - } - fputs(canon, new); - putc('\n', new); - return(acl_commit(acl, new)); -} - -/* Removes principal from acl */ -/* Wildcards are interpreted literally */ -int -acl_delete(acl, principal) - char *acl; - char *principal; -{ - int idx; - int i; - FILE *new; - char canon[MAX_PRINCIPAL_SIZE]; - - acl_canonicalize_principal(principal, canon); - - if((new = acl_lock_file(acl)) == NULL) return(-1); - if((!acl_exact_match(acl, canon)) - || (idx = acl_load(acl)) < 0) { - acl_abort(acl, new); - return(-1); - } - /* It isn't there yet, copy the file and put it in */ - for(i = 0; i < acl_cache[idx].acl->size; i++) { - if(acl_cache[idx].acl->tbl[i] != NULL - && strcmp(acl_cache[idx].acl->tbl[i], canon)) { - fputs(acl_cache[idx].acl->tbl[i], new); - putc('\n', new); - } - } - return(acl_commit(acl, new)); -} diff --git a/lib/acl_files.c.old b/lib/acl_files.c.old deleted file mode 100644 index c9c2f7a..0000000 --- a/lib/acl_files.c.old +++ /dev/null @@ -1,556 +0,0 @@ -/* This file is part of the Project Athena Zephyr Notification System. - * It contains functions for maintaining Access Control Lists. - * - * Created by: John T. Kohl - * - * $Source$ - * $Author$ - * - * Copyright (c) 1987,1988 by the Massachusetts Institute of Technology. - * For copying and distribution information, see the file - * "mit-copyright.h". - */ - -/* Define this if you really want the ACL-writing code included. */ -/* #define WRITE_ACL */ - -/* - * Stolen from lib/acl_files.c because acl_load needs to be externally - * declared and not statically declared. - */ - -#ifndef lint -static char rcsid_acl_files_c[] = "$Id$"; -#endif - -/*** Routines for manipulating access control list files ***/ - -#include <zephyr/zephyr.h> -#include <strings.h> -#include <sys/file.h> -#include <fcntl.h> -#include <sys/stat.h> -#include <ctype.h> -#include <sys/param.h> /* for MAXHOSTNAMELEN */ -#include <errno.h> - -/* "aname.inst@realm" */ -#define MAX_PRINCIPAL_SIZE (ANAME_SZ + INST_SZ + REALM_SZ + 3) -#define INST_SEP '.' -#define REALM_SEP '@' - -#define LINESIZE 2048 /* Maximum line length in an acl file */ - -#define NEW_FILE "%s.~NEWACL~" /* Format for name of altered acl file */ -#define WAIT_TIME 300 /* Maximum time allowed write acl file */ - -#define CACHED_ACLS 64 /* How many acls to cache */ -#define ACL_LEN 256 /* Twice a reasonable acl length */ - -#ifndef MAX -#define MAX(a,b) (((a)>(b))?(a):(b)) -#define MIN(a,b) (((a)<(b))?(a):(b)) -#endif - -#define COR(a,b) ((a!=NULL)?(a):(b)) - -/* Canonicalize a principal name */ -/* If instance is missing, it becomes "" */ -/* If realm is missing, it becomes the local realm */ -/* Canonicalized form is put in canon, which must be big enough to hold - MAX_PRINCIPAL_SIZE characters */ -acl_canonicalize_principal(principal, canon) - char *principal; - char *canon; -{ - char *dot, *atsign, *end; - int len; - - dot = (char *)strchr(principal, INST_SEP); - atsign = (char *)strchr(principal, REALM_SEP); - - /* Maybe we're done already */ - if(dot != NULL && atsign != NULL) { - if(dot < atsign) { - /* It's for real */ - /* Copy into canon */ - strncpy(canon, principal, MAX_PRINCIPAL_SIZE); - canon[MAX_PRINCIPAL_SIZE-1] = '\0'; - return; - } else { - /* Nope, it's part of the realm */ - dot = NULL; - } - } - - /* No such luck */ - end = principal + strlen(principal); - - /* Get the principal name */ - len = MIN(ANAME_SZ, COR(dot, COR(atsign, end)) - principal); - strncpy(canon, principal, len); - canon += len; - - /* Add INST_SEP */ - *canon++ = INST_SEP; - - /* Get the instance, if it exists */ - if(dot != NULL) { - ++dot; - len = MIN(INST_SZ, COR(atsign, end) - dot); - strncpy(canon, dot, len); - canon += len; - } - - /* Add REALM_SEP */ - *canon++ = REALM_SEP; - - /* Get the realm, if it exists */ - /* Otherwise, default to local realm */ - if(atsign != NULL) { - ++atsign; - len = MIN(REALM_SZ, end - atsign); - strncpy(canon, atsign, len); - canon += len; - *canon++ = '\0'; - } -#ifdef Z_HaveKerberos - else if(krb_get_lrealm(canon, 1) != KSUCCESS) { - strcpy(canon, KRB_REALM); - } -#endif -} - -/* Get a lock to modify acl_file */ -/* Return new FILE pointer */ -/* or NULL if file cannot be modified */ -/* REQUIRES WRITE PERMISSION TO CONTAINING DIRECTORY */ -static FILE *acl_lock_file(acl_file) - char *acl_file; -{ - struct stat s; - char new[LINESIZE]; - int nfd; - FILE *nf; - int mode; - - if(stat(acl_file, &s) < 0) return(NULL); - mode = s.st_mode; - sprintf(new, NEW_FILE, acl_file); - for(;;) { - /* Open the new file */ - if((nfd = open(new, O_WRONLY|O_CREAT|O_EXCL, mode)) < 0) { - if(errno == EEXIST) { - /* Maybe somebody got here already, maybe it's just old */ - if(stat(new, &s) < 0) return(NULL); - if(time(0) - s.st_ctime > WAIT_TIME) { - /* File is stale, kill it */ - unlink(new); - continue; - } else { - /* Wait and try again */ - sleep(1); - continue; - } - } else { - /* Some other error, we lose */ - return(NULL); - } - } - - /* If we got to here, the lock file is ours and ok */ - /* Reopen it under stdio */ - if((nf = fdopen(nfd, "w")) == NULL) { - /* Oops, clean up */ - unlink(new); - } - return(nf); - } -} - -/* Commit changes to acl_file written onto FILE *f */ -/* Returns zero if successful */ -/* Returns > 0 if lock was broken */ -/* Returns < 0 if some other error occurs */ -/* Closes f */ -static int acl_commit(acl_file, f) - char *acl_file; - FILE *f; -{ -#ifdef WRITE_ACL - char new[LINESIZE]; - int ret; - struct stat s; - - sprintf(new, NEW_FILE, acl_file); - if(fflush(f) < 0 - || fstat(fileno(f), &s) < 0 - || s.st_nlink == 0) { - acl_abort(acl_file, f); - return(-1); - } - - ret = rename(new, acl_file); - fclose(f); - return(ret); -#else - abort (); -#endif -} - -/* Abort changes to acl_file written onto FILE *f */ -/* Returns 0 if successful, < 0 otherwise */ -/* Closes f */ -static int acl_abort(acl_file, f) - char *acl_file; - FILE *f; -{ -#ifdef WRITE_ACL - char new[LINESIZE]; - int ret; - struct stat s; - - /* make sure we aren't nuking someone else's file */ - if(fstat(fileno(f), &s) < 0 - || s.st_nlink == 0) { - fclose(f); - return(-1); - } else { - sprintf(new, NEW_FILE, acl_file); - ret = unlink(new); - fclose(f); - return(ret); - } -#else - abort (); -#endif -} - -/* Initialize an acl_file */ -/* Creates the file with permissions perm if it does not exist */ -/* Erases it if it does */ -/* Returns return value of acl_commit */ -int -acl_initialize(acl_file, perm) - char *acl_file; - int perm; -{ - FILE *new; - int fd; - - /* Check if the file exists already */ - if((new = acl_lock_file(acl_file)) != NULL) { - return(acl_commit(acl_file, new)); - } else { - /* File must be readable and writable by owner */ - if((fd = open(acl_file, O_CREAT|O_EXCL, perm|0600)) < 0) { - return(-1); - } else { - close(fd); - return(0); - } - } -} - -/* Eliminate all whitespace character in buf */ -/* Modifies its argument */ -static nuke_whitespace(buf) - char *buf; -{ - register char *pin, *pout; - - for(pin = pout = buf; *pin != '\0'; pin++) - if(!isspace(*pin)) *pout++ = *pin; - *pout = '\0'; /* Terminate the string */ -} - -/* Hash table stuff */ - -struct hashtbl { - int size; /* Max number of entries */ - int entries; /* Actual number of entries */ - char **tbl; /* Pointer to start of table */ -}; - -/* Make an empty hash table of size s */ -static struct hashtbl *make_hash(size) - int size; -{ - struct hashtbl *h; - - if(size < 1) size = 1; - h = (struct hashtbl *) malloc(sizeof(struct hashtbl)); - h->size = size; - h->entries = 0; - h->tbl = (char **) calloc(size, sizeof(char *)); - return(h); -} - -/* Destroy a hash table */ -static void -destroy_hash(h) - struct hashtbl *h; -{ - int i; - - for(i = 0; i < h->size; i++) { - if(h->tbl[i] != NULL) free(h->tbl[i]); - } - free(h->tbl); - free(h); -} - -/* Compute hash value for a string */ -static unsigned int -hashval(s) - register char *s; -{ - register unsigned hv; - - for(hv = 0; *s != '\0'; s++) { - hv ^= ((hv << 3) ^ *s); - } - return(hv); -} - -/* Add an element to a hash table */ -static add_hash(h, el) - struct hashtbl *h; - char *el; -{ - unsigned hv; - char *s; - char **old; - int i; - - /* Make space if it isn't there already */ - if(h->entries + 1 > (h->size >> 1)) { - old = h->tbl; - h->tbl = (char **) calloc(h->size << 1, sizeof(char *)); - for(i = 0; i < h->size; i++) { - if(old[i] != NULL) { - hv = hashval(old[i]) % (h->size << 1); - while(h->tbl[hv] != NULL) hv = (hv+1) % (h->size << 1); - h->tbl[hv] = old[i]; - } - } - h->size = h->size << 1; - free(old); - } - - hv = hashval(el) % h->size; - while(h->tbl[hv] != NULL && strcmp(h->tbl[hv], el)) hv = (hv+1) % h->size; - s = (char *) malloc(strlen(el)+1); - strcpy(s, el); - h->tbl[hv] = s; - h->entries++; -} - -/* Returns nonzero if el is in h */ -static int -check_hash(h, el) - struct hashtbl *h; - char *el; -{ - unsigned hv; - - for(hv = hashval(el) % h->size; h->tbl[hv]; hv = (hv + 1) % h->size) { - if (!strcmp(h->tbl[hv], el)) { - return 1; - } - } - return 0; -} - -struct acl { - char filename[LINESIZE]; /* Name of acl file */ - struct hashtbl *acl; /* Acl entries */ -}; - -static struct acl acl_cache[CACHED_ACLS]; - -static int acl_cache_count = 0; -static int acl_cache_next = 0; - -/* Returns < 0 if unsuccessful in loading acl */ -/* Returns index into acl_cache otherwise */ -/* Note that if acl is already loaded, this is just a lookup */ -int acl_load(name) - char *name; -{ - int i; - FILE *f; - char buf[MAX_PRINCIPAL_SIZE]; - char canon[MAX_PRINCIPAL_SIZE]; - - /* See if it's there already */ - for(i = 0; i < acl_cache_count; i++) { - if (!strcmp(acl_cache[i].filename, name)) - goto got_it; - } - - /* It isn't, load it in */ - /* maybe there's still room */ - if(acl_cache_count < CACHED_ACLS) { - i = acl_cache_count++; - } else { - /* No room, clean one out */ - i = acl_cache_next; - acl_cache_next = (acl_cache_next + 1) % CACHED_ACLS; - if(acl_cache[i].acl) { - destroy_hash(acl_cache[i].acl); - acl_cache[i].acl = (struct hashtbl *) 0; - } - } - - /* Set up the acl */ - strcpy(acl_cache[i].filename, name); - /* Force reload */ - acl_cache[i].acl = (struct hashtbl *) 0; - -got_it: - /* - * See if we need to reload the ACL - */ - if (acl_cache[i].acl == (struct hashtbl *) 0) { - /* Gotta reload */ - if ((f = fopen(name, "r")) == NULL) { - return -1; - } - if (acl_cache[i].acl) destroy_hash(acl_cache[i].acl); - acl_cache[i].acl = make_hash(ACL_LEN); - while(fgets(buf, sizeof(buf), f) != NULL) { - nuke_whitespace(buf); - acl_canonicalize_principal(buf, canon); - add_hash(acl_cache[i].acl, canon); - } - fclose(f); - } - return(i); -} - -/* - * This destroys all cached ACL's so that new ones will be loaded in - * the next time they are requested. - */ -acl_cache_reset() -{ - int i; - - /* See if it's there already */ - for(i = 0; i < acl_cache_count; i++) - if (acl_cache[i].acl) { - destroy_hash(acl_cache[i].acl); - acl_cache[i].acl = (struct hashtbl *) 0; - } - acl_cache_count = 0; - acl_cache_next = 0; -} - - -/* Returns nonzero if it can be determined that acl contains principal */ -/* Principal is not canonicalized, and no wildcarding is done */ -acl_exact_match(acl, principal) - char *acl; - char *principal; -{ - int idx; - - return((idx = acl_load(acl)) >= 0 - && check_hash(acl_cache[idx].acl, principal)); -} - -/* Returns nonzero if it can be determined that acl contains principal */ -/* Recognizes wildcards in acl of the form - name.*@realm, *.*@realm, and *.*@* */ -acl_check(acl, principal) - char *acl; - char *principal; -{ - char buf[MAX_PRINCIPAL_SIZE]; - char canon[MAX_PRINCIPAL_SIZE]; - char *realm; - - acl_canonicalize_principal(principal, canon); - - /* Is it there? */ - if (acl_exact_match(acl, canon)) - return 1; - - /* Try the wildcards */ - realm = (char *)strchr(canon, REALM_SEP); - *((char *)strchr(canon, INST_SEP)) = '\0'; /* Chuck the instance */ - - sprintf(buf, "%s.*%s", canon, realm); - if(acl_exact_match(acl, buf)) return 1; - - sprintf(buf, "*.*%s", realm); - if(acl_exact_match(acl, buf) || acl_exact_match(acl, "*.*@*")) return(1); - - return(0); -} - -/* Adds principal to acl */ -/* Wildcards are interpreted literally */ -acl_add(acl, principal) - char *acl; - char *principal; -{ - int idx; - int i; - FILE *new; - char canon[MAX_PRINCIPAL_SIZE]; - - acl_canonicalize_principal(principal, canon); - - if((new = acl_lock_file(acl)) == NULL) return(-1); - if((acl_exact_match(acl, canon)) - || (idx = acl_load(acl)) < 0) { - acl_abort(acl, new); - return(-1); - } - /* It isn't there yet, copy the file and put it in */ - for(i = 0; i < acl_cache[idx].acl->size; i++) { - if(acl_cache[idx].acl->tbl[i] != NULL) { - if(fputs(acl_cache[idx].acl->tbl[i], new) == 0 - || putc('\n', new) != '\n') { - acl_abort(acl, new); - return(-1); - } - } - } - fputs(canon, new); - putc('\n', new); - return(acl_commit(acl, new)); -} - -/* Removes principal from acl */ -/* Wildcards are interpreted literally */ -int -acl_delete(acl, principal) - char *acl; - char *principal; -{ - int idx; - int i; - FILE *new; - char canon[MAX_PRINCIPAL_SIZE]; - - acl_canonicalize_principal(principal, canon); - - if((new = acl_lock_file(acl)) == NULL) return(-1); - if((!acl_exact_match(acl, canon)) - || (idx = acl_load(acl)) < 0) { - acl_abort(acl, new); - return(-1); - } - /* It isn't there yet, copy the file and put it in */ - for(i = 0; i < acl_cache[idx].acl->size; i++) { - if(acl_cache[idx].acl->tbl[i] != NULL - && strcmp(acl_cache[idx].acl->tbl[i], canon)) { - fputs(acl_cache[idx].acl->tbl[i], new); - putc('\n', new); - } - } - return(acl_commit(acl, new)); -} diff --git a/lib/decl b/lib/decl deleted file mode 100755 index c5a410d..0000000 --- a/lib/decl +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/csh -f -rm -f lib_headers -foreach i (Z*.c) - echo $i - awk -f decl.awk $i >> lib_headers - echo "" >> lib_headers -end diff --git a/lib/decl.awk b/lib/decl.awk deleted file mode 100644 index 5040249..0000000 --- a/lib/decl.awk +++ /dev/null @@ -1,9 +0,0 @@ -BEGIN { - foo = 0; -} -/Z.*\(/ { if (foo != 2) foo = 1; } -/{/ { foo = 2; } -{ - if (foo == 1) - print; -} diff --git a/lib/inet_ntoa.c b/lib/inet_ntoa.c deleted file mode 100644 index df91da9..0000000 --- a/lib/inet_ntoa.c +++ /dev/null @@ -1,36 +0,0 @@ -/* This file is part of the Project Athena Zephyr Notification System. - * It contains a version of the standard inet_ntoa function, for use - * on a Sun 4 with gcc version 1. - * - * Created by: Ken Raeburn - * - * $Source$ - * $Author$ - * - * Copyright (c) 1991 by the Massachusetts Institute of Technology. - * For copying and distribution information, see the file - * "mit-copyright.h". - */ - -#include <zephyr/mit-copyright.h> - -#ifndef lint -static char rcsid_inet_ntoa_c[] = "$Zephyr$"; -#endif - -#if defined (sparc) && __GNUC__ == 1 -/* GCC version 1 passes structures incorrectly on the Sparc. - This addition will cause things to work correctly if everything - using inet_ntoa is compiled with gcc. If not, you lose anyways. */ -char *inet_ntoa (addr) - struct in_addr addr; -{ - static char buf[16]; - sprintf (buf, "%d.%d.%d.%d", - addr.S_un.S_un_b.s_b1, - addr.S_un.S_un_b.s_b2, - addr.S_un.S_un_b.s_b3, - addr.S_un.S_un_b.s_b4); - return buf; -} -#endif diff --git a/lib/krb_err.et b/lib/krb_err.et deleted file mode 100644 index d03288a..0000000 --- a/lib/krb_err.et +++ /dev/null @@ -1,259 +0,0 @@ -# Copyright 1987,1988 Massachusetts Institute of Technology -# -# For copying and distribution information, see the file -# "mit-copyright.h". -# -# $Source$ -# $Author$ -# $Header$ -# - error_table krb - - ec KRBET_KSUCCESS, - "Kerberos successful" - - ec KRBET_KDC_NAME_EXP, - "Kerberos principal expired" - - ec KRBET_KDC_SERVICE_EXP, - "Kerberos service expired" - - ec KRBET_KDC_AUTH_EXP, - "Kerberos auth expired" - - ec KRBET_KDC_PKT_VER, - "Incorrect kerberos master key version" - - ec KRBET_KDC_P_MKEY_VER, - "Incorrect kerberos master key version" - - ec KRBET_KDC_S_MKEY_VER, - "Incorrect kerberos master key version" - - ec KRBET_KDC_BYTE_ORDER, - "Kerberos error: byte order unknown" - - ec KRBET_KDC_PR_UNKNOWN, - "Kerberos principal unknown" - - ec KRBET_KDC_PR_N_UNIQUE, - "Kerberos principal not unique" - - ec KRBET_KDC_NULL_KEY, - "Kerberos principal has null key" - - ec KRBET_KRB_RES11, - "Reserved 11" - - ec KRBET_KRB_RES12, - "Reserved 12" - - ec KRBET_KRB_RES13, - "Reserved 13" - - ec KRBET_KRB_RES14, - "Reserved 14" - - ec KRBET_KRB_RES15, - "Reserved 15" - - ec KRBET_KRB_RES16, - "Reserved 16" - - ec KRBET_KRB_RES17, - "Reserved 17" - - ec KRBET_KRB_RES18, - "Reserved 18" - - ec KRBET_KRB_RES19, - "Reserved 19" - - ec KRBET_KDC_GEN_ERR, - "Generic error from Kerberos KDC" - - ec KRBET_GC_TKFIL, - "Can't read Kerberos ticket file" - - ec KRBET_GC_NOTKT, - "Can't find Kerberos ticket or TGT" - - ec KRBET_KRB_RES23, - "Reserved 23" - - ec KRBET_KRB_RES24, - "Reserved 24" - - ec KRBET_KRB_RES25, - "Reserved 25" - - ec KRBET_MK_AP_TGTEXP, - "Kerberos TGT Expired" - - ec KRBET_KRB_RES27, - "Reserved 27" - - ec KRBET_KRB_RES28, - "Reserved 28" - - ec KRBET_KRB_RES29, - "Reserved 29" - - ec KRBET_KRB_RES30, - "Reserved 30" - - ec KRBET_RD_AP_UNDEC, - "Kerberos error: Can't decode authenticator" - - ec KRBET_RD_AP_EXP, - "Kerberos ticket expired" - - ec KRBET_RD_AP_NYV, - "Kerberos ticket not yet valid" - - ec KRBET_RD_AP_REPEAT, - "Kerberos error: Repeated request" - - ec KRBET_RD_AP_NOT_US, - "The kerberos ticket isn't for us" - - ec KRBET_RD_AP_INCON, - "Kerberos request inconsistent" - - ec KRBET_RD_AP_TIME, - "Kerberos error: delta_t too big" - - ec KRBET_RD_AP_BADD, - "Kerberos error: incorrect net address" - - ec KRBET_RD_AP_VERSION, - "Kerberos protocol version mismatch" - - ec KRBET_RD_AP_MSG_TYPE, - "Kerberos error: invalid msg type" - - ec KRBET_RD_AP_MODIFIED, - "Kerberos error: message stream modified" - - ec KRBET_RD_AP_ORDER, - "Kerberos error: message out of order" - - ec KRBET_RD_AP_UNAUTHOR, - "Kerberos error: unauthorized request" - - ec KRBET_KRB_RES44, - "Reserved 44" - - ec KRBET_KRB_RES45, - "Reserved 45" - - ec KRBET_KRB_RES46, - "Reserved 46" - - ec KRBET_KRB_RES47, - "Reserved 47" - - ec KRBET_KRB_RES48, - "Reserved 48" - - ec KRBET_KRB_RES49, - "Reserved 49" - - ec KRBET_KRB_RES50, - "Reserved 50" - - ec KRBET_GT_PW_NULL, - "Kerberos error: current PW is null" - - ec KRBET_GT_PW_BADPW, - "Kerberos error: Incorrect current password" - - ec KRBET_GT_PW_PROT, - "Kerberos protocol error" - - ec KRBET_GT_PW_KDCERR, - "Error returned by Kerberos KDC" - - ec KRBET_GT_PW_NULLTKT, - "Null Kerberos ticket returned by KDC" - - ec KRBET_SKDC_RETRY, - "Kerberos error: Retry count exceeded" - - ec KRBET_SKDC_CANT, - "Kerberos error: Can't send request" - - ec KRBET_KRB_RES58, - "Reserved 58" - - ec KRBET_KRB_RES59, - "Reserved 59" - - ec KRBET_KRB_RES60, - "Reserved 60" - - ec KRBET_INTK_W_NOTALL, - "Kerberos error: not all tickets returned" - - ec KRBET_INTK_BADPW, - "Kerberos error: incorrect password" - - ec KRBET_INTK_PROT, - "Kerberos error: Protocol Error" - - ec KRBET_KRB_RES64, - "Reserved 64" - - ec KRBET_KRB_RES65, - "Reserved 65" - - ec KRBET_KRB_RES66, - "Reserved 66" - - ec KRBET_KRB_RES67, - "Reserved 67" - - ec KRBET_KRB_RES68, - "Reserved 68" - - ec KRBET_KRB_RES69, - "Reserved 69" - - ec KRBET_INTK_ERR, - "Other error" - - ec KRBET_AD_NOTGT, - "Don't have Kerberos ticket-granting ticket" - - ec KRBET_KRB_RES72, - "Reserved 72" - - ec KRBET_KRB_RES73, - "Reserved 73" - - ec KRBET_KRB_RES74, - "Reserved 74" - - ec KRBET_KRB_RES75, - "Reserved 75" - - ec KRBET_NO_TKT_FIL, - "No ticket file found" - - ec KRBET_TKT_FIL_ACC, - "Couldn't access ticket file" - - ec KRBET_TKT_FIL_LCK, - "Couldn't lock ticket file" - - ec KRBET_TKT_FIL_FMT, - "Bad ticket file format" - - ec KRBET_TKT_FIL_INI, - "tf_init not called first" - - ec KRBET_KNAME_FMT, - "Bad Kerberos name format" - - end - diff --git a/lib/lib_headers b/lib/lib_headers deleted file mode 100644 index 8edc1e7..0000000 --- a/lib/lib_headers +++ /dev/null @@ -1,197 +0,0 @@ -int ZCheckAuthentication(notice, from) - ZNotice_t *notice; - struct sockaddr_in *from; - -Code_t ZCheckIfNotice(notice, from, predicate, args) - ZNotice_t *notice; - struct sockaddr_in *from; - int (*predicate)(); - char *args; - -Code_t ZClosePort() - -int ZCompareUID(uid1, uid2) - ZUnique_Id_t *uid1, *uid2; - -int ZCompareUIDPred(notice, uid) - ZNotice_t *notice; - ZUnique_Id_t *uid; - -Code_t ZFlushLocations() - -Code_t ZFlushSubscriptions() - -Code_t ZFormatAuthenticNotice(notice, buffer, buffer_len, len, session) - ZNotice_t *notice; - char *buffer; - int buffer_len; - int *len; - C_Block session; - -Code_t ZFormatNotice(notice, buffer, ret_len, cert_routine) - ZNotice_t *notice; - char **buffer; - int *ret_len; - int (*cert_routine)(); - -Code_t ZFormatNoticeList(notice, list, nitems, buffer, ret_len, - cert_routine) - ZNotice_t *notice; - char *list[]; - int nitems; - char **buffer; - int *ret_len; - int (*cert_routine)(); - -Code_t ZFormatRawNotice(notice, buffer, ret_len) - ZNotice_t *notice; - char **buffer; - int *ret_len; - -Code_t ZFormatRawNoticeList(notice, list, nitems, buffer, ret_len) - ZNotice_t *notice; - char *list[]; - int nitems; - char **buffer; - int *ret_len; - -Code_t ZFormatSmallRawNotice(notice, buffer, ret_len) - ZNotice_t *notice; - ZPacket_t buffer; - int *ret_len; - -Code_t ZFormatSmallRawNoticeList(notice, list, nitems, buffer, ret_len) - ZNotice_t *notice; - char *list[]; - int nitems; - ZPacket_t buffer; - int *ret_len; - -Code_t ZFreeNotice(notice) - ZNotice_t *notice; - -Code_t ZGetLocations(location, numlocs) - ZLocations_t *location; - int *numlocs; - -char *ZGetSender() - -Code_t ZGetSubscriptions(subscription, numsubs) - ZSubscription_t *subscription; - int *numsubs; - -short ZGetWGPort() - -Code_t ZIfNotice(notice, from, predicate, args) - ZNotice_t *notice; - struct sockaddr_in *from; - int (*predicate)(); - char *args; - -Code_t ZInitialize() - -Code_t ZLocateUser(user, nlocs) - char *user; - int *nlocs; - -Code_t ZSetLocation(exposure) - char *exposure; - -Code_t ZMakeAscii(ptr, len, field, num) - char *ptr; - int len; - unsigned char *field; - int num; - -Code_t ZMakeAuthentication(notice, buffer, buffer_len, len) - ZNotice_t *notice; - char *buffer; - int buffer_len; - int *len; - -Code_t ZOpenPort(port) - u_short *port; - -Code_t ZParseNotice(buffer, len, notice) - char *buffer; - int len; - ZNotice_t *notice; - -Code_t ZPeekIfNotice(notice, from, predicate, args) - ZNotice_t *notice; - struct sockaddr_in *from; - int (*predicate)(); - char *args; - -Code_t ZPeekNotice(notice, from) - ZNotice_t *notice; - struct sockaddr_in *from; - -Code_t ZPeekPacket(buffer, ret_len, from) - char **buffer; - int *ret_len; - struct sockaddr_in *from; - -int ZPending() - -int ZReadAscii(ptr, len, field, num) - char *ptr; - int len; - unsigned char *field; - int num; - -Code_t ZReceiveNotice(notice, from) - ZNotice_t *notice; - struct sockaddr_in *from; - -Code_t ZReceivePacket(buffer, ret_len, from) - ZPacket_t buffer; - int *ret_len; - struct sockaddr_in *from; - -Code_t ZRetrieveSubscriptions(port,nsubs) - u_short port; - int *nsubs; - -Code_t ZSendList(notice, list, nitems, cert_routine) - ZNotice_t *notice; - char *list[]; - int nitems; - int (*cert_routine)(); - -Code_t ZSendNotice(notice, cert_routine) - ZNotice_t *notice; - int (*cert_routine)(); - -Code_t ZSendPacket(packet, len, waitforack) - char *packet; - int len; - int waitforack; - -Code_t ZSendRawList(notice, list, nitems) - ZNotice_t *notice; - char *list[]; - int nitems; - -Code_t ZSendRawNotice(notice) - ZNotice_t *notice; - -Code_t ZSetDestAddr(addr) - struct sockaddr_in *addr; - -Code_t ZSetFD(fd) - int fd; - -Code_t ZSetServerState(state) - int state; - -Code_t ZSubscribeTo(sublist, nitems, port) - ZSubscription_t *sublist; - int nitems; - u_short port; - -char *ZGetVariable(var) - char *var; - -Code_t Z_GetMyAddr() - diff --git a/lib/mit-copyright.h b/lib/mit-copyright.h new file mode 100644 index 0000000..73059b3 --- /dev/null +++ b/lib/mit-copyright.h @@ -0,0 +1,24 @@ +/* + +Copyright 1987,1988 by the Massachusetts Institute of Technology + +All rights reserved. + +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 the Massachusetts +Institute of Technology (M.I.T.) not be used in advertising or publicity +pertaining to distribution of the software without specific, written +prior permission. + +M.I.T. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING +ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL +M.I.T. BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR +ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, +WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, +ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS +SOFTWARE. + +*/ diff --git a/lib/strcasecmp.c b/lib/strcasecmp.c deleted file mode 100644 index 7cefd1c..0000000 --- a/lib/strcasecmp.c +++ /dev/null @@ -1,95 +0,0 @@ -/* - * Copyright (c) 1987 Regents of the University of California. - * All rights reserved. - * - * Redistribution and use in source and binary forms are permitted - * provided that this notice is preserved and that due credit is given - * to the University of California at Berkeley. The name of the University - * may not be used to endorse or promote products derived from this - * software without specific written prior permission. This software - * is provided ``as is'' without express or implied warranty. - */ - -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)strcasecmp.c 5.5 (Berkeley) 11/24/87"; -#endif /* LIBC_SCCS and not lint */ - -#ifdef lint -#include <sys/types.h> -#endif - -#ifndef __STDC__ -#define const -#endif - -#ifndef lint -static const char rcsid_strcasecmp_c[] = - "$Zephyr$"; -#endif - -/* - * This array is designed for mapping upper and lower case letter - * together for a case independent comparison. The mappings are - * based upon ascii character sequences. - */ -static const u_char charmap[] = { - '\000', '\001', '\002', '\003', '\004', '\005', '\006', '\007', - '\010', '\011', '\012', '\013', '\014', '\015', '\016', '\017', - '\020', '\021', '\022', '\023', '\024', '\025', '\026', '\027', - '\030', '\031', '\032', '\033', '\034', '\035', '\036', '\037', - '\040', '\041', '\042', '\043', '\044', '\045', '\046', '\047', - '\050', '\051', '\052', '\053', '\054', '\055', '\056', '\057', - '\060', '\061', '\062', '\063', '\064', '\065', '\066', '\067', - '\070', '\071', '\072', '\073', '\074', '\075', '\076', '\077', - '\100', '\141', '\142', '\143', '\144', '\145', '\146', '\147', - '\150', '\151', '\152', '\153', '\154', '\155', '\156', '\157', - '\160', '\161', '\162', '\163', '\164', '\165', '\166', '\167', - '\170', '\171', '\172', '\133', '\134', '\135', '\136', '\137', - '\140', '\141', '\142', '\143', '\144', '\145', '\146', '\147', - '\150', '\151', '\152', '\153', '\154', '\155', '\156', '\157', - '\160', '\161', '\162', '\163', '\164', '\165', '\166', '\167', - '\170', '\171', '\172', '\173', '\174', '\175', '\176', '\177', - '\200', '\201', '\202', '\203', '\204', '\205', '\206', '\207', - '\210', '\211', '\212', '\213', '\214', '\215', '\216', '\217', - '\220', '\221', '\222', '\223', '\224', '\225', '\226', '\227', - '\230', '\231', '\232', '\233', '\234', '\235', '\236', '\237', - '\240', '\241', '\242', '\243', '\244', '\245', '\246', '\247', - '\250', '\251', '\252', '\253', '\254', '\255', '\256', '\257', - '\260', '\261', '\262', '\263', '\264', '\265', '\266', '\267', - '\270', '\271', '\272', '\273', '\274', '\275', '\276', '\277', - '\300', '\341', '\342', '\343', '\344', '\345', '\346', '\347', - '\350', '\351', '\352', '\353', '\354', '\355', '\356', '\357', - '\360', '\361', '\362', '\363', '\364', '\365', '\366', '\367', - '\370', '\371', '\372', '\333', '\334', '\335', '\336', '\337', - '\340', '\341', '\342', '\343', '\344', '\345', '\346', '\347', - '\350', '\351', '\352', '\353', '\354', '\355', '\356', '\357', - '\360', '\361', '\362', '\363', '\364', '\365', '\366', '\367', - '\370', '\371', '\372', '\373', '\374', '\375', '\376', '\377', -}; - -strcasecmp(s1, s2) - const char *s1, *s2; -{ - register u_char const *cm = charmap, - *us1 = (u_char const *)s1, - *us2 = (u_char const *)s2; - - while (cm[*us1] == cm[*us2++]) - if (*us1++ == '\0') - return(0); - return(cm[*us1] - cm[*--us2]); -} - -strncasecmp(s1, s2, n) - const char *s1, *s2; - register int n; -{ - register u_char const *cm = charmap, - *us1 = (u_char const *)s1, - *us2 = (u_char const *)s2; - - while (--n >= 0 && cm[*us1] == cm[*us2++]) - if (*us1++ == '\0') - return(0); - return(n < 0 ? 0 : cm[*us1] - cm[*--us2]); -} |