diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/ChangeLog | 18 | ||||
-rw-r--r-- | lib/Makefile.in | 61 | ||||
-rw-r--r-- | lib/ZAsyncLocate.c | 4 | ||||
-rw-r--r-- | lib/ZCkAuth.c | 7 | ||||
-rw-r--r-- | lib/ZFmtAuth.c | 8 | ||||
-rw-r--r-- | lib/ZFmtRaw.c | 4 | ||||
-rw-r--r-- | lib/ZFmtRawLst.c | 6 | ||||
-rw-r--r-- | lib/ZFmtSmRLst.c | 4 | ||||
-rw-r--r-- | lib/ZFmtSmRaw.c | 4 | ||||
-rw-r--r-- | lib/ZGetDefRlm.c | 25 | ||||
-rw-r--r-- | lib/ZGetRhs.c | 57 | ||||
-rw-r--r-- | lib/ZGetSender.c | 4 | ||||
-rw-r--r-- | lib/ZInit.c | 167 | ||||
-rw-r--r-- | lib/ZLocateU.c | 24 | ||||
-rw-r--r-- | lib/ZLocations.c | 19 | ||||
-rw-r--r-- | lib/ZMkAuth.c | 89 | ||||
-rw-r--r-- | lib/ZNewLocU.c | 6 | ||||
-rw-r--r-- | lib/ZOpenPort.c | 16 | ||||
-rw-r--r-- | lib/ZParseNot.c | 98 | ||||
-rw-r--r-- | lib/ZReadAscii.c | 32 | ||||
-rw-r--r-- | lib/ZRealmCnt.c | 49 | ||||
-rw-r--r-- | lib/ZRecvNot.c | 29 | ||||
-rw-r--r-- | lib/ZRetSubs.c | 11 | ||||
-rw-r--r-- | lib/ZSetDest.c | 2 | ||||
-rw-r--r-- | lib/ZSubs.c | 31 | ||||
-rw-r--r-- | lib/ZVariables.c | 2 | ||||
-rw-r--r-- | lib/Zinternal.c | 500 | ||||
-rw-r--r-- | lib/zephyr_err.et | 8 |
28 files changed, 310 insertions, 975 deletions
diff --git a/lib/ChangeLog b/lib/ChangeLog deleted file mode 100644 index 21b8aa2..0000000 --- a/lib/ChangeLog +++ /dev/null @@ -1,18 +0,0 @@ -2002-01-05 Ken Raeburn <raeburn@mit.edu> - - * ZInit.c: Include sys/sockio.h and net/if.h if available. - - * ZReadAscii.c (Z_cnvt_xtoi): Delete disabled function version. - -2001-08-25 Ken Raeburn <raeburn@mit.edu> - - * ZParseNot.c (next_field): Delete machine-specific versions, just - rely on the compiler. - - * ZInit.c: Include netinet/in.h, sys/ioctl.h, and ifaddrs.h if - it's available. - (max, ifreq_size) [HAVE_SA_LEN]: New macros. - (ZInitialize): Use structure assignments rather than memcpy. Add - a new branch for determining local addresses using getifaddrs or - SIOCGIFCONF, adapted from current krb5 code. - diff --git a/lib/Makefile.in b/lib/Makefile.in index 092b41e..cdaecc8 100644 --- a/lib/Makefile.in +++ b/lib/Makefile.in @@ -6,69 +6,68 @@ datadir=@datadir@ sysconfdir=@sysconfdir@ sbindir=@sbindir@ lsbindir=@lsbindir@ +top_builddir=.. includedir=${prefix}/include -mandir=@mandir@ +mandir=${prefix}/man libdir=${exec_prefix}/lib -LIBS=@LIBS@ srcdir=@srcdir@ top_srcdir=@top_srcdir@ -top_builddir=.. BUILDTOP=.. VPATH=@srcdir@ +LIBTOOL=@LIBTOOL@ CC=@CC@ INSTALL=@INSTALL@ -LIBTOOL=@LIBTOOL@ -FPIC= -DEBUG=-O +RANLIB=@RANLIB@ CPPFLAGS=@CPPFLAGS@ -CFLAGS=@CFLAGS@ ${DEBUG} ${FPIC} +CFLAGS=@CFLAGS@ ALL_CFLAGS=${CFLAGS} -DSYSCONFDIR=\"${sysconfdir}\" -I${top_srcdir}/h \ -I${BUILDTOP}/h ${CPPFLAGS} -LIBS=@LIBS@ - -OBJS = zephyr_err.lo ZAsyncLocate.lo ZCkAuth.lo ZCkIfNot.lo \ - ZClosePort.lo ZCmpUID.lo ZCmpUIDP.lo ZFlsLocs.lo ZFlsSubs.lo \ - ZFmtAuth.lo ZFmtList.lo ZFmtNotice.lo ZFmtRaw.lo ZFmtRawLst.lo \ - ZFmtSmRLst.lo ZFmtSmRaw.lo ZFreeNot.lo ZGetDefRlm.lo \ - ZGetLocs.lo ZGetRhs.lo ZGetSender.lo ZGetSubs.lo ZGetWGPort.lo \ - ZhmStat.lo ZIfNotice.lo ZInit.lo ZLocations.lo ZMakeAscii.lo \ - ZMkAuth.lo ZNewLocU.lo ZOpenPort.lo ZParseNot.lo ZPeekIfNot.lo \ - ZPeekNot.lo ZPeekPkt.lo ZPending.lo ZReadAscii.lo ZRealmCnt.lo \ - ZRecvNot.lo ZRecvPkt.lo ZRetSubs.lo ZSendList.lo ZSendNot.lo \ - ZSendPkt.lo ZSendRaw.lo ZSendRLst.lo ZSetDest.lo ZSetFD.lo \ - ZSetSrv.lo ZSubs.lo ZVariables.lo ZWait4Not.lo Zinternal.lo +LDFLAGS=@LDFLAGS@ +LIBS=@LIBS@ -lcom_err + +OBJS = zephyr_err.lo ZAsyncLocate.lo ZCkAuth.lo ZCkIfNot.lo ZClosePort.lo \ + ZCmpUID.lo ZCmpUIDP.lo ZFlsLocs.lo ZFlsSubs.lo ZFmtAuth.lo \ + ZFmtList.lo ZFmtNotice.lo ZFmtRaw.lo ZFmtRawLst.lo ZFmtSmRLst.lo \ + ZFmtSmRaw.lo ZFreeNot.lo ZGetLocs.lo ZGetSender.lo ZGetSubs.lo \ + ZGetWGPort.lo ZhmStat.lo ZIfNotice.lo ZInit.lo ZLocations.lo \ + ZMakeAscii.lo ZMkAuth.lo ZNewLocU.lo ZOpenPort.lo ZParseNot.lo \ + ZPeekIfNot.lo ZPeekNot.lo ZPeekPkt.lo ZPending.lo ZReadAscii.lo \ + ZRecvNot.lo ZRecvPkt.lo ZRetSubs.lo ZSendList.lo ZSendNot.lo \ + ZSendPkt.lo ZSendRaw.lo ZSendRLst.lo ZSetDest.lo ZSetFD.lo ZSetSrv.lo \ + ZSubs.lo ZVariables.lo ZWait4Not.lo Zinternal.lo + +.SUFFIXES: .lo all: libzephyr.la libzephyr.la: ${OBJS} - ${LIBTOOL} $(CC) -version-info 4:0:0 -o libzephyr.la $(OBJS) -rpath $(libdir) $(LIBS) - - + ${LIBTOOL} --mode=link ${CC} -rpath ${libdir} -version-info 3:0:0 \ + ${LDFLAGS} -o $@ ${OBJS} ${LIBS} 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 +.c.lo: + ${LIBTOOL} --mode=compile ${CC} -c -o $@ ${ALL_CFLAGS} $< + check: install: libzephyr.la - ${LIBTOOL} ${INSTALL} -m 644 libzephyr.la ${DESTDIR}${libdir} - ${LIBTOOL} ${INSTALL} -m 644 ${srcdir}/zephyr.1 ${DESTDIR}${mandir}/man1 - + ${LIBTOOL} --mode=install ${INSTALL} -m 644 libzephyr.la \ + ${DESTDIR}${libdir} + ${INSTALL} -m 644 ${srcdir}/zephyr.1 ${DESTDIR}${mandir}/man1 clean: - ${LIBTOOL} rm -f ${OBJS} libzephyr.la zephyr_err.c zephyr_err.h + rm -f zephyr_err.c zephyr_err.h + ${LIBTOOL} --mode=clean rm -f ${OBJS} libzephyr.la ${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 -.SUFFIXES: .lo - -.c.lo: - ${LIBTOOL} ${CC} -c ${ALL_CFLAGS} $< diff --git a/lib/ZAsyncLocate.c b/lib/ZAsyncLocate.c index 055cc52..d248064 100644 --- a/lib/ZAsyncLocate.c +++ b/lib/ZAsyncLocate.c @@ -16,8 +16,7 @@ static const char rcsid_ZAsyncLocate_c[] = "$Id$"; #endif -Code_t ZRequestLocations(galaxy, user, zald, kind, auth) - char *galaxy; +Code_t ZRequestLocations(user, zald, kind, auth) char *user; register ZAsyncLocateData_t *zald; ZNotice_Kind_t kind; /* UNSAFE, UNACKED, or ACKED */ @@ -40,7 +39,6 @@ Code_t ZRequestLocations(galaxy, user, zald, kind, auth) notice.z_recipient = ""; notice.z_default_format = ""; notice.z_message_len = 0; - notice.z_dest_galaxy = galaxy; if ((retval = ZSendNotice(¬ice, auth)) != ZERR_NONE) return(retval); diff --git a/lib/ZCkAuth.c b/lib/ZCkAuth.c index 8db1f94..17fdc2b 100644 --- a/lib/ZCkAuth.c +++ b/lib/ZCkAuth.c @@ -33,7 +33,6 @@ Code_t ZCheckAuthentication(notice, from) int result; ZChecksum_t our_checksum; CREDENTIALS cred; - char *realm; /* If the value is already known, return it. */ if (notice->z_checked_auth != ZAUTH_UNSET) @@ -42,12 +41,8 @@ Code_t ZCheckAuthentication(notice, from) if (!notice->z_auth) return (ZAUTH_NO); - /* yes, this really is a realm, not a rhs */ - if ((realm = ZGetRhs(notice->z_dest_galaxy)) == NULL) - return (ZAUTH_NO); - if ((result = krb_get_cred(SERVER_SERVICE, SERVER_INSTANCE, - realm, &cred)) != 0) + __Zephyr_realm, &cred)) != 0) return (ZAUTH_NO); #ifdef NOENCRYPTION diff --git a/lib/ZFmtAuth.c b/lib/ZFmtAuth.c index 29ed7f7..c2d8a00 100644 --- a/lib/ZFmtAuth.c +++ b/lib/ZFmtAuth.c @@ -33,8 +33,8 @@ Code_t ZFormatAuthenticNotice(notice, buffer, buffer_len, len, session) newnotice.z_authent_len = 0; newnotice.z_ascii_authent = ""; - if ((retval = Z_FormatRawHeader(&newnotice, buffer, buffer_len, &hdrlen, - NULL, NULL, &ptr, NULL)) != ZERR_NONE) + if ((retval = Z_FormatRawHeader(&newnotice, buffer, buffer_len, + &hdrlen, &ptr, NULL)) != ZERR_NONE) return (retval); #ifdef NOENCRYPTION @@ -43,8 +43,8 @@ Code_t ZFormatAuthenticNotice(notice, buffer, buffer_len, len, session) newnotice.z_checksum = (ZChecksum_t)des_quad_cksum(buffer, NULL, ptr - buffer, 0, session); #endif - if ((retval = Z_FormatRawHeader(&newnotice, buffer, buffer_len, &hdrlen, - NULL, NULL, NULL, NULL)) != ZERR_NONE) + if ((retval = Z_FormatRawHeader(&newnotice, buffer, buffer_len, + &hdrlen, NULL, NULL)) != ZERR_NONE) return (retval); ptr = buffer+hdrlen; diff --git a/lib/ZFmtRaw.c b/lib/ZFmtRaw.c index 6e2f2cc..2940f98 100644 --- a/lib/ZFmtRaw.c +++ b/lib/ZFmtRaw.c @@ -25,8 +25,8 @@ Code_t ZFormatRawNotice(notice, buffer, ret_len) int hdrlen; Code_t retval; - if ((retval = Z_FormatRawHeader(notice, header, sizeof(header), &hdrlen, - NULL, NULL, NULL, NULL)) != ZERR_NONE) + if ((retval = Z_FormatRawHeader(notice, header, sizeof(header), + &hdrlen, NULL, NULL)) != ZERR_NONE) return (retval); *ret_len = hdrlen+notice->z_message_len; diff --git a/lib/ZFmtRawLst.c b/lib/ZFmtRawLst.c index 1d7acd6..7d83f71 100644 --- a/lib/ZFmtRawLst.c +++ b/lib/ZFmtRawLst.c @@ -3,7 +3,7 @@ * * Created by: Robert French * -n * $Id$ + * $Id$ * * Copyright (c) 1987 by the Massachusetts Institute of Technology. * For copying and distribution information, see the file @@ -28,8 +28,8 @@ Code_t ZFormatRawNoticeList(notice, list, nitems, buffer, ret_len) char *ptr; Code_t retval; - if ((retval = Z_FormatRawHeader(notice, header, sizeof(header), &hdrlen, - NULL, NULL, NULL, NULL)) != ZERR_NONE) + if ((retval = Z_FormatRawHeader(notice, header, sizeof(header), + &hdrlen, NULL, NULL)) != ZERR_NONE) return (retval); size = 0; diff --git a/lib/ZFmtSmRLst.c b/lib/ZFmtSmRLst.c index 31574a2..6e41285 100644 --- a/lib/ZFmtSmRLst.c +++ b/lib/ZFmtSmRLst.c @@ -27,8 +27,8 @@ Code_t ZFormatSmallRawNoticeList(notice, list, nitems, buffer, ret_len) int hdrlen, i, size; char *ptr; - if ((retval = Z_FormatRawHeader(notice, buffer, Z_MAXHEADERLEN, &hdrlen, - NULL, NULL, NULL, NULL)) != ZERR_NONE) + if ((retval = Z_FormatRawHeader(notice, buffer, Z_MAXHEADERLEN, + &hdrlen, NULL, NULL)) != ZERR_NONE) return (retval); size = 0; diff --git a/lib/ZFmtSmRaw.c b/lib/ZFmtSmRaw.c index cae6d4b..a9ce79d 100644 --- a/lib/ZFmtSmRaw.c +++ b/lib/ZFmtSmRaw.c @@ -24,8 +24,8 @@ Code_t ZFormatSmallRawNotice(notice, buffer, ret_len) Code_t retval; int hdrlen; - if ((retval = Z_FormatRawHeader(notice, buffer, Z_MAXHEADERLEN, &hdrlen, - NULL, NULL, NULL, NULL)) != ZERR_NONE) + if ((retval = Z_FormatRawHeader(notice, buffer, Z_MAXHEADERLEN, + &hdrlen, NULL, NULL)) != ZERR_NONE) return (retval); *ret_len = hdrlen+notice->z_message_len; diff --git a/lib/ZGetDefRlm.c b/lib/ZGetDefRlm.c deleted file mode 100644 index 90145d5..0000000 --- a/lib/ZGetDefRlm.c +++ /dev/null @@ -1,25 +0,0 @@ -/* This file is part of the Project Athena Zephyr Notification System. - * It contains source for the ZGetDefRlm function. - * - * Created by: Marc Horowitz - * - * $Source$ - * $Author$ - * - * Copyright (c) 1987, 1991 by the Massachusetts Institute of Technology. - * For copying and distribution information, see the file - * "mit-copyright.h". - */ -/* $Header$ */ - -#include <internal.h> - -#ifndef lint -static const char rcsid_ZGetDefGxy_c[] = - "$Id$"; -#endif - -char *ZGetDefaultGalaxy() -{ - return(__galaxy_list[__default_galaxy].galaxy_config.galaxy); -} diff --git a/lib/ZGetRhs.c b/lib/ZGetRhs.c deleted file mode 100644 index 0e53536..0000000 --- a/lib/ZGetRhs.c +++ /dev/null @@ -1,57 +0,0 @@ -/* This file is part of the Project Athena Zephyr Notification System. - * It contains source for the ZGetRhs function. - * - * Created by: Marc Horowitz - * - * $Source$ - * $Author$ - * - * Copyright (c) 1987, 1991 by the Massachusetts Institute of Technology. - * For copying and distribution information, see the file - * "mit-copyright.h". - */ -/* $Header$ */ - -#include <internal.h> - -#ifndef lint -static const char rcsid_ZGetRhs_c[] = - "$Id$"; -#endif - -/* Get the thing after the @ (kerberos realm if kerberos, otherwise - just the zephyr galaxy), given the zephyr destination realm */ - -char *ZGetRhs(zgalaxy) - char *zgalaxy; -{ - Z_GalaxyList *rl; - int i; - - /* this should only happen on a server */ - if (__ngalaxies == 0) - return("local-galaxy"); - - if (zgalaxy && zgalaxy[0]) { - rl = NULL; - - for (i=0; i<__ngalaxies; i++) - if (strcasecmp(__galaxy_list[i].galaxy_config.galaxy, zgalaxy) == 0) { - rl = &__galaxy_list[i]; - break; - } - - if (rl == NULL) - return(NULL); - } else { - rl = &__galaxy_list[__default_galaxy]; - } - - return( -#ifdef HAVE_KRB4 - rl->krealm -#else - rl->galaxy_config.galaxy -#endif - ); -} diff --git a/lib/ZGetSender.c b/lib/ZGetSender.c index aac5d7c..df5f3e2 100644 --- a/lib/ZGetSender.c +++ b/lib/ZGetSender.c @@ -1,5 +1,5 @@ /* This file is part of the Project Athena Zephyr Notification System. - * It contains source for the ZGetSender function. + * It contains source for the ZGetSender.c function. * * Created by: Robert French * @@ -47,6 +47,6 @@ char *ZGetSender() pw = getpwuid((int) getuid()); if (!pw) return ("unknown"); - (void) sprintf(sender, "%s@%s", pw->pw_name, ZGetRhs(NULL)); + (void) sprintf(sender, "%s@%s", pw->pw_name, __Zephyr_realm); return (sender); } diff --git a/lib/ZInit.c b/lib/ZInit.c index 9eb0fa5..401f6db 100644 --- a/lib/ZInit.c +++ b/lib/ZInit.c @@ -18,18 +18,6 @@ static char rcsid_ZInitialize_c[] = #include <internal.h> #include <sys/socket.h> -#include <netinet/in.h> -#include <sys/ioctl.h> -#include <config.h> -#ifdef HAVE_SYS_SOCKIO_H -#include <sys/sockio.h> -#endif -#ifdef HAVE_IFADDRS_H -#include <ifaddrs.h> -#endif -#ifdef HAVE_NET_IF_H -#include <net/if.h> -#endif #ifdef HAVE_KRB4 #include <krb_err.h> #endif @@ -42,15 +30,17 @@ Code_t ZInitialize() { struct servent *hmserv; struct hostent *hostent; - char hostname[MAXHOSTNAMELEN], *def; + char addr[4], hostname[MAXHOSTNAMELEN]; + struct in_addr servaddr; struct sockaddr_in sin; int s, sinsize = sizeof(sin); Code_t code; ZNotice_t notice; - char *mp; - int i; #ifdef HAVE_KRB4 - char *krealm; + char *krealm = NULL; + int krbval; + char d1[ANAME_SZ], d2[INST_SZ]; + initialize_krb_error_table(); #endif @@ -59,14 +49,20 @@ Code_t ZInitialize() (void) memset((char *)&__HM_addr, 0, sizeof(__HM_addr)); __HM_addr.sin_family = AF_INET; -#ifdef HAVE_SA_LEN - __HM_addr.sin_len = sizeof (struct sockaddr_in); -#endif - __HM_addr.sin_addr.s_addr = htonl (0x7f000001L); + + /* Set up local loopback address for HostManager */ + addr[0] = 127; + addr[1] = 0; + addr[2] = 0; + addr[3] = 1; hmserv = (struct servent *)getservbyname(HM_SVCNAME, "udp"); __HM_addr.sin_port = (hmserv) ? hmserv->s_port : HM_SVC_FALLBACK; + (void) memcpy((char *)&__HM_addr.sin_addr, addr, 4); + + __HM_set = 0; + /* Initialize the input queue */ __Q_Tail = NULL; __Q_Head = NULL; @@ -75,6 +71,7 @@ Code_t ZInitialize() 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. */ + servaddr.s_addr = INADDR_NONE; if (! __Zephyr_server) { if ((code = ZOpenPort(NULL)) != ZERR_NONE) return(code); @@ -88,94 +85,62 @@ Code_t ZInitialize() If this code ever support a multiplexing zhm, this will have to be made smarter, and probably per-message */ - for (i=0, mp = notice.z_message; - mp<notice.z_message+notice.z_message_len; - i++, mp += strlen(mp)+1) - ; - - /* if this is an old zhm, i will be 10, and __ngalaxies will be 0 */ - - __ngalaxies = i/12; /* XXX should be a defined constant */ - - if (__ngalaxies == 0) { - char galaxy_config[1024]; - - __ngalaxies = 1; - __galaxy_list = (Z_GalaxyList *) malloc(sizeof(Z_GalaxyList)*1); - - /* we're talking to an old zhm. Use the one server name we get - to figure out the krealm. ZReceiveNotice() knows this case, - and will always assume the current/only galaxy. */ - - strcpy(galaxy_config, "local-galaxy hostlist "); - strcat(galaxy_config, notice.z_message); - - if ((code = - Z_ParseGalaxyConfig(galaxy_config, - &__galaxy_list[0].galaxy_config)) - != ZERR_NONE) { - __ngalaxies = 0; - free(__galaxy_list); - return(code); - } - #ifdef HAVE_KRB4 - krealm = krb_realmofhost(__galaxy_list[0].galaxy_config.server_list[0].name); - if (!krealm) - krealm = ""; - - strcpy(__galaxy_list[0].krealm, krealm); - - __galaxy_list[0].last_authent_time = 0; + krealm = krb_realmofhost(notice.z_message); #endif - } else { - __galaxy_list = (Z_GalaxyList *) malloc(sizeof(Z_GalaxyList)*__ngalaxies); - for (i=0, mp = notice.z_message; - mp<notice.z_message+notice.z_message_len; - i++, mp += strlen(mp)+1) { - if (i%12 == 11) { - if ((code = - Z_ParseGalaxyConfig(mp, - &__galaxy_list[i/12].galaxy_config)) - != ZERR_NONE) { - __ngalaxies = i/12; - for (i=0; i<__ngalaxies; i++) - Z_FreeGalaxyConfig(&__galaxy_list[i].galaxy_config); - free(__galaxy_list); - return(code); - } + hostent = gethostbyname(notice.z_message); + if (hostent && hostent->h_addrtype == AF_INET) + memcpy(&servaddr, hostent->h_addr, sizeof(servaddr)); -#ifdef HAVE_KRB4 - krealm = krb_realmofhost(__galaxy_list[i/12].galaxy_config.server_list[0].name); - if (!krealm) - krealm = ""; - - strcpy(__galaxy_list[i/12].krealm, krealm); + ZFreeNotice(¬ice); + } - __galaxy_list[i/12].last_authent_time = 0; +#ifdef HAVE_KRB4 + 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); + } +#else + strcpy(__Zephyr_realm, "local-realm"); #endif - } - } - } - ZFreeNotice(¬ice); - - __default_galaxy = 0; - - if (def = ZGetVariable("defaultgalaxy")) { - for (i=0; i<__ngalaxies; i++) { - if (strcasecmp(__galaxy_list[i].galaxy_config.galaxy, - def) == 0) { - __default_galaxy = i; - break; - } - } - } - } else { - __galaxy_list = 0; - __ngalaxies = 0; - __default_galaxy = 0; + __My_addr.s_addr = INADDR_NONE; + if (servaddr.s_addr != INADDR_NONE) { + /* Try to get the local interface address by connecting a UDP + * socket to the server address and getting the local address. + * Some broken operating systems (e.g. Solaris 2.0-2.5) yield + * INADDR_ANY (zero), so we have to check for that. */ + s = socket(AF_INET, SOCK_DGRAM, 0); + if (s != -1) { + memset(&sin, 0, sizeof(sin)); + sin.sin_family = AF_INET; + memcpy(&sin.sin_addr, &servaddr, sizeof(servaddr)); + sin.sin_port = HM_SRV_SVC_FALLBACK; + if (connect(s, (struct sockaddr *) &sin, sizeof(sin)) == 0 + && getsockname(s, (struct sockaddr *) &sin, &sinsize) == 0 + && sin.sin_addr.s_addr != 0) + memcpy(&__My_addr, &sin.sin_addr, sizeof(__My_addr)); + close(s); + } + } + if (__My_addr.s_addr == INADDR_NONE) { + /* We couldn't figure out the local interface address by the + * above method. Try by resolving the local hostname. (This + * is a pretty broken thing to do, and unfortunately what we + * always do on server machines.) */ + if (gethostname(hostname, sizeof(hostname)) == 0) { + hostent = gethostbyname(hostname); + if (hostent && hostent->h_addrtype == AF_INET) + memcpy(&__My_addr, hostent->h_addr, sizeof(__My_addr)); + } } + /* If the above methods failed, zero out __My_addr so things will + * sort of kind of work. */ + if (__My_addr.s_addr == INADDR_NONE) + __My_addr.s_addr = 0; /* Get the sender so we can cache it */ (void) ZGetSender(); diff --git a/lib/ZLocateU.c b/lib/ZLocateU.c new file mode 100644 index 0000000..9e53b9e --- /dev/null +++ b/lib/ZLocateU.c @@ -0,0 +1,24 @@ +/* This file is part of the Project Athena Zephyr Notification System. + * It contains source for the ZLocateUser function. + * + * Created by: Robert French + * + * $Id$ + * + * Copyright (c) 1987,1988 by the Massachusetts Institute of Technology. + * For copying and distribution information, see the file + * "mit-copyright.h". + */ + +#ifndef lint +static char rcsid_ZLocateUser_c[] = "$Id$"; +#endif + +#include <internal.h> + +Code_t ZLocateUser(user, nlocs) + char *user; + int *nlocs; +{ + return(ZNewLocateUser(user,nlocs,ZAUTH)); +} diff --git a/lib/ZLocations.c b/lib/ZLocations.c index a237604..e157342 100644 --- a/lib/ZLocations.c +++ b/lib/ZLocations.c @@ -56,25 +56,22 @@ Code_t ZInitLocationInfo(hostname, tty) return (ZERR_NONE); } -Code_t ZSetLocation(galaxy, exposure) - char *galaxy; +Code_t ZSetLocation(exposure) char *exposure; { - return (Z_SendLocation(galaxy, LOGIN_CLASS, exposure, ZAUTH, + return (Z_SendLocation(LOGIN_CLASS, exposure, ZAUTH, "$sender logged in to $1 on $3 at $2")); } -Code_t ZUnsetLocation(galaxy) - char *galaxy; +Code_t ZUnsetLocation() { - return (Z_SendLocation(galaxy, LOGIN_CLASS, LOGIN_USER_LOGOUT, ZNOAUTH, + return (Z_SendLocation(LOGIN_CLASS, LOGIN_USER_LOGOUT, ZNOAUTH, "$sender logged out of $1 on $3 at $2")); } -Code_t ZFlushMyLocations(galaxy) - char *galaxy; +Code_t ZFlushMyLocations() { - return (Z_SendLocation(galaxy, LOGIN_CLASS, LOGIN_USER_FLUSH, ZAUTH, "")); + return (Z_SendLocation(LOGIN_CLASS, LOGIN_USER_FLUSH, ZAUTH, "")); } char *ZParseExposureLevel(text) @@ -96,8 +93,7 @@ char *ZParseExposureLevel(text) return(NULL); } -Code_t Z_SendLocation(galaxy, class, opcode, auth, format) - char *galaxy; +Code_t Z_SendLocation(class, opcode, auth, format) char *class; char *opcode; Z_AuthProc auth; @@ -123,7 +119,6 @@ Code_t Z_SendLocation(galaxy, class, opcode, auth, format) notice.z_recipient = ""; notice.z_num_other_fields = 0; notice.z_default_format = format; - notice.z_dest_galaxy = galaxy; bptr[0] = host; ourtime = time((time_t *)0); diff --git a/lib/ZMkAuth.c b/lib/ZMkAuth.c index 312dbc7..5a6749c 100644 --- a/lib/ZMkAuth.c +++ b/lib/ZMkAuth.c @@ -16,76 +16,38 @@ static const char rcsid_ZMakeAuthentication_c[] = "$Id$"; #endif -Code_t ZResetAuthentication () { #ifdef HAVE_KRB4 - int i; - - for (i=0; i<__ngalaxies; i++) - __galaxy_list[i].last_authent_time = 0; - +#include <krb_err.h> #endif + +Code_t ZResetAuthentication () { return ZERR_NONE; } -Code_t ZMakeAuthentication(notice, buffer, buffer_len, phdr_len) +Code_t ZMakeAuthentication(notice, buffer, buffer_len, len) register ZNotice_t *notice; char *buffer; int buffer_len; - int *phdr_len; + int *len; { #ifdef HAVE_KRB4 - int i; - int cksum_len; int result; time_t now; KTEXT_ST authent; - char *krealm, *cksum_start, *cstart, *cend; + char *cstart, *cend; ZChecksum_t checksum; CREDENTIALS cred; + extern unsigned long des_quad_cksum(); - if (notice->z_dest_galaxy && *notice->z_dest_galaxy) { - for (i=0; i<__ngalaxies; i++) { - if (strcasecmp(notice->z_dest_galaxy, - __galaxy_list[i].galaxy_config.galaxy) == 0) - break; - } + result = krb_mk_req(&authent, SERVER_SERVICE, + SERVER_INSTANCE, __Zephyr_realm, 0); + if (result != MK_AP_OK) + return (result+krb_err_base); + result = krb_get_cred(SERVER_SERVICE, SERVER_INSTANCE, + __Zephyr_realm, &cred); + if (result != KSUCCESS) + return (result+krb_err_base); - if (i == __ngalaxies) - return(ZERR_GALAXYUNKNOWN); - } else { - i = __default_galaxy; - } - - krealm = __galaxy_list[i].krealm; - - if (krealm[0] == '\0') -#endif - { - notice->z_checksum = 0; - notice->z_auth = 1; - notice->z_authent_len = 0; - notice->z_ascii_authent = ""; - return (Z_FormatRawHeader(notice, buffer, buffer_len, phdr_len, - NULL, NULL, NULL, NULL)); - } - -#ifdef HAVE_KRB4 - now = time(0); - - if ((__galaxy_list[i].last_authent_time == 0) || - (now - __galaxy_list[i].last_authent_time > 120)) { - result = krb_mk_req(&authent, SERVER_SERVICE, SERVER_INSTANCE, - krealm, 0); - if (result != MK_AP_OK) { - __galaxy_list[i].last_authent_time = 0; - return (result+krb_err_base); - } - __galaxy_list[i].last_authent_time = now; - __galaxy_list[i].last_authent = authent; - } - else { - authent = __galaxy_list[i].last_authent; - } notice->z_auth = 1; notice->z_authent_len = authent.length; notice->z_ascii_authent = (char *)malloc((unsigned)authent.length*3); @@ -99,27 +61,28 @@ Code_t ZMakeAuthentication(notice, buffer, buffer_len, phdr_len) free(notice->z_ascii_authent); return (result); } - result = Z_FormatRawHeader(notice, buffer, buffer_len, phdr_len, - &cksum_start, &cksum_len, &cstart, &cend); + result = Z_FormatRawHeader(notice, buffer, buffer_len, len, &cstart, + &cend); free(notice->z_ascii_authent); notice->z_authent_len = 0; if (result) return(result); /* Compute a checksum over the header and message. */ - - if ((result = krb_get_cred(SERVER_SERVICE, SERVER_INSTANCE, - krealm, &cred)) != 0) - return result; - checksum = des_quad_cksum(cksum_start, NULL, cstart - cksum_start, 0, - cred.session); - checksum ^= des_quad_cksum(cend, NULL, (cksum_start + cksum_len) - cend, 0, + 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 = checksum; - ZMakeAscii32(cstart, (buffer + buffer_len) - cstart, checksum); + ZMakeAscii32(cstart, buffer + buffer_len - cstart, checksum); return (ZERR_NONE); +#else + notice->z_checksum = 0; + notice->z_auth = 1; + notice->z_authent_len = 0; + notice->z_ascii_authent = ""; + return (Z_FormatRawHeader(notice, buffer, buffer_len, len, NULL, NULL)); #endif } diff --git a/lib/ZNewLocU.c b/lib/ZNewLocU.c index 94a1278..9ad620d 100644 --- a/lib/ZNewLocU.c +++ b/lib/ZNewLocU.c @@ -17,8 +17,7 @@ static const char rcsid_ZNewLocateUser_c[] = "$Id$"; #endif -Code_t ZLocateUser(galaxy, user, nlocs, auth) - char *galaxy; +Code_t ZLocateUser(user, nlocs, auth) char *user; int *nlocs; Z_AuthProc auth; @@ -30,8 +29,7 @@ Code_t ZLocateUser(galaxy, user, nlocs, auth) (void) ZFlushLocations(); /* ZFlushLocations never fails (the library is allowed to know this). */ - if ((retval = ZRequestLocations(galaxy, user, &zald, UNACKED, - auth)) != ZERR_NONE) + if ((retval = ZRequestLocations(user, &zald, UNACKED, auth)) != ZERR_NONE) return(retval); retval = Z_WaitForNotice (¬ice, ZCompareALDPred, &zald, SRV_TIMEOUT); diff --git a/lib/ZOpenPort.c b/lib/ZOpenPort.c index ee043ae..75cec22 100644 --- a/lib/ZOpenPort.c +++ b/lib/ZOpenPort.c @@ -22,9 +22,6 @@ Code_t ZOpenPort(port) { struct sockaddr_in bindin; int len; -#ifdef SO_BSDCOMPAT - int on = 1; -#endif (void) ZClosePort(); @@ -33,11 +30,6 @@ Code_t ZOpenPort(port) return (errno); } -#ifdef SO_BSDCOMPAT - /* Prevent Linux from giving us socket errors we don't care about. */ - setsockopt(__Zephyr_fd, SOL_SOCKET, SO_BSDCOMPAT, &on, sizeof(on)); -#endif - bindin.sin_family = AF_INET; if (port && *port) @@ -68,11 +60,3 @@ Code_t ZOpenPort(port) return (ZERR_NONE); } - -int ZGetPort() -{ - if (__Zephyr_open) - return(__Zephyr_port); - else - return(-1); -} diff --git a/lib/ZParseNot.c b/lib/ZParseNot.c index 44dbaf6..7950e96 100644 --- a/lib/ZParseNot.c +++ b/lib/ZParseNot.c @@ -17,7 +17,16 @@ static char rcsid_ZParseNotice_c[] = #include <internal.h> -#define next_field(ptr) ptr += strlen (ptr) + 1 +/* Skip to the next NUL-terminated field in the packet. */ +static char *next_field(ptr, end) + char *ptr, *end; +{ + while (ptr < end && *ptr != '\0') + ptr++; + if (ptr < end) + ptr++; + return (ptr); +} Code_t ZParseNotice(buffer, len, notice) char *buffer; @@ -26,7 +35,7 @@ Code_t ZParseNotice(buffer, len, notice) { char *ptr, *end; unsigned long temp; - int maj, min, numfields, i; + int maj, numfields, i; #ifdef __LINE__ int lineno; @@ -62,21 +71,12 @@ Code_t ZParseNotice(buffer, len, notice) maj = atoi(ptr); if (maj != ZVERSIONMAJOR) return (ZERR_VERS); - while (*ptr != '.') ptr++; - min = atoi(ptr+1); - next_field (ptr); - - if (min == ZVERSIONMINOR_GALAXY) { - notice->z_dest_galaxy = ptr; - next_field (ptr); - /* skip the dummy version field */ - next_field (ptr); - } + ptr = next_field(ptr, end); if (ZReadAscii32(ptr, end-ptr, &temp) == ZERR_BADFIELD) BAD_PACKET; numfields = temp; - next_field (ptr); + ptr = next_field(ptr, end); /*XXX 3 */ numfields -= 2; /* numfields, version, and checksum */ @@ -100,151 +100,153 @@ Code_t ZParseNotice(buffer, len, notice) return ZERR_BADPKT; } - if (numfields) { + if (numfields && ptr < end) { if (ZReadAscii32(ptr, end-ptr, &temp) == ZERR_BADFIELD) BAD_PACKET; notice->z_kind = (ZNotice_Kind_t)temp; numfields--; - next_field (ptr); + ptr = next_field(ptr, end); } else BAD_PACKET; - if (numfields) { + if (numfields && ptr < end) { if (ZReadAscii(ptr, end-ptr, (unsigned char *)¬ice->z_uid, sizeof(ZUnique_Id_t)) == ZERR_BADFIELD) 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); + ptr = next_field(ptr, end); } else BAD_PACKET; - if (numfields) { + if (numfields && ptr < end) { if (ZReadAscii16(ptr, end-ptr, ¬ice->z_port) == ZERR_BADFIELD) BAD_PACKET; notice->z_port = htons(notice->z_port); numfields--; - next_field (ptr); + ptr = next_field(ptr, end); } else BAD_PACKET; - if (numfields) { + if (numfields && ptr < end) { if (ZReadAscii32(ptr, end-ptr, &temp) == ZERR_BADFIELD) BAD_PACKET; notice->z_auth = temp; numfields--; - next_field (ptr); + ptr = next_field(ptr, end); } else BAD_PACKET; notice->z_checked_auth = ZAUTH_UNSET; - if (numfields) { + if (numfields && ptr < end) { if (ZReadAscii32(ptr, end-ptr, &temp) == ZERR_BADFIELD) BAD_PACKET; notice->z_authent_len = temp; numfields--; - next_field (ptr); + ptr = next_field(ptr, end); } else BAD_PACKET; - if (numfields) { + if (numfields && ptr < end) { notice->z_ascii_authent = ptr; numfields--; - next_field (ptr); + ptr = next_field(ptr, end); } else BAD_PACKET; - if (numfields) { + if (numfields && ptr < end) { notice->z_class = ptr; numfields--; - next_field (ptr); + ptr = next_field(ptr, end); } else notice->z_class = ""; - if (numfields) { + if (numfields && ptr < end) { notice->z_class_inst = ptr; numfields--; - next_field (ptr); + ptr = next_field(ptr, end); } else notice->z_class_inst = ""; - if (numfields) { + if (numfields && ptr < end) { notice->z_opcode = ptr; numfields--; - next_field (ptr); + ptr = next_field(ptr, end); } else notice->z_opcode = ""; - if (numfields) { + if (numfields && ptr < end) { notice->z_sender = ptr; numfields--; - next_field (ptr); + ptr = next_field(ptr, end); } else notice->z_sender = ""; - if (numfields) { + if (numfields && ptr < end) { notice->z_recipient = ptr; numfields--; - next_field (ptr); + ptr = next_field(ptr, end); } else notice->z_recipient = ""; - if (numfields) { + if (numfields && ptr < end) { notice->z_default_format = ptr; numfields--; - next_field (ptr); + ptr = next_field(ptr, end); } else notice->z_default_format = ""; -/*XXX*/ if (ZReadAscii32(ptr, end-ptr, &temp) == ZERR_BADFIELD) BAD_PACKET; notice->z_checksum = temp; numfields--; - next_field (ptr); + ptr = next_field(ptr, end); - if (numfields) { + if (numfields && ptr < end) { notice->z_multinotice = ptr; numfields--; - next_field (ptr); + ptr = next_field(ptr, end); } else notice->z_multinotice = ""; - if (numfields) { + if (numfields && ptr < end) { if (ZReadAscii(ptr, end-ptr, (unsigned char *)¬ice->z_multiuid, sizeof(ZUnique_Id_t)) == ZERR_BADFIELD) 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--; - next_field (ptr); + ptr = next_field(ptr, end); } else notice->z_multiuid = notice->z_uid; - for (i=0;i<Z_MAXOTHERFIELDS && numfields;i++,numfields--) { + for (i=0;ptr < end && i<Z_MAXOTHERFIELDS && numfields;i++,numfields--) { notice->z_other_fields[i] = ptr; - next_field (ptr); + ptr = next_field(ptr, end); } notice->z_num_other_fields = i; - for (i=0;i<numfields;i++) - next_field (ptr); - + for (i=0;ptr < end && numfields;numfields--) + ptr = next_field(ptr, end); + + if (numfields || *(ptr - 1) != '\0') + BAD_PACKET; + notice->z_message = (caddr_t) ptr; notice->z_message_len = len-(ptr-buffer); diff --git a/lib/ZReadAscii.c b/lib/ZReadAscii.c index baf7469..53037cb 100644 --- a/lib/ZReadAscii.c +++ b/lib/ZReadAscii.c @@ -17,6 +17,21 @@ static char rcsid_ZReadAscii_c[] = "$Id$"; #include <internal.h> #include <assert.h> +#if 0 +static __inline__ +int +Z_cnvt_xtoi (char c) +{ + c -= '0'; + if (c < 10) + return c; + c -= 'A'-'9'-1; + if (c < 16) + return c; + return -1; +} +#endif + #define Z_cnvt_xtoi(c) ((temp=(c)-'0'),(temp<10)?temp:((temp-='A'-'9'-1),(temp<16)?temp:-1)) Code_t ZReadAscii(ptr, len, field, num) @@ -31,17 +46,16 @@ Code_t ZReadAscii(ptr, len, field, num) register unsigned int temp; for (i=0;i<num;i++) { - if (*ptr == ' ') { + if (len >= 1 && *ptr == ' ') { ptr++; - if (--len < 0) - return ZERR_BADFIELD; - } - if (ptr[0] == '0' && ptr[1] == 'x') { + len--; + } + if (len >= 2 && ptr[0] == '0' && ptr[1] == 'x') { ptr += 2; len -= 2; - if (len < 0) - return ZERR_BADFIELD; - } + } + if (len < 2) + return ZERR_BADFIELD; c1 = Z_cnvt_xtoi(ptr[0]); if (c1 < 0) return ZERR_BADFIELD; @@ -52,8 +66,6 @@ Code_t ZReadAscii(ptr, len, field, num) field[i] = hexbyte; ptr += 2; len -= 2; - if (len < 0) - return ZERR_BADFIELD; } return *ptr ? ZERR_BADFIELD : ZERR_NONE; diff --git a/lib/ZRealmCnt.c b/lib/ZRealmCnt.c deleted file mode 100644 index 0fb76e5..0000000 --- a/lib/ZRealmCnt.c +++ /dev/null @@ -1,49 +0,0 @@ -/* This file is part of the Project Athena Zephyr Notification System. - * It contains source for the ZGetGalaxyCount and ZGetGalaxyName functions. - * - * Created by: Marc Horowitz - * - * $Source$ - * $Author$ - * - * Copyright (c) 1987, 1991 by the Massachusetts Institute of Technology. - * For copying and distribution information, see the file - * "mit-copyright.h". - */ -/* $Header$ */ - -#include <internal.h> - -#ifndef lint -static const char rcsid_ZGxyCnt_c[] = - "$Id$"; -#endif - -Code_t ZGetGalaxyCount(pcnt) - int *pcnt; -{ - *pcnt = __ngalaxies; - - return(ZERR_NONE); -} - -Code_t ZGetGalaxyName(idx, name) - int idx; - char **name; -{ - if ((idx < 0) || (idx >= __ngalaxies)) - return(EINVAL); - - /* return the default galaxy first. when the default galaxy would have - been returned in the order, return the first galaxy. */ - - if (idx == 0) - *name = __galaxy_list[__default_galaxy].galaxy_config.galaxy; - else if (idx == __default_galaxy) - *name = __galaxy_list[0].galaxy_config.galaxy; - else - *name = __galaxy_list[idx].galaxy_config.galaxy; - - - return(ZERR_NONE); -} diff --git a/lib/ZRecvNot.c b/lib/ZRecvNot.c index bfed17a..27cba29 100644 --- a/lib/ZRecvNot.c +++ b/lib/ZRecvNot.c @@ -22,9 +22,8 @@ Code_t ZReceiveNotice(notice, from) { char *buffer; struct _Z_InputQ *nextq; - int len, auth, i, j; + int len, auth; Code_t retval; - struct sockaddr_in sin; if ((retval = Z_WaitForComplete()) != ZERR_NONE) return (retval); @@ -36,11 +35,9 @@ Code_t ZReceiveNotice(notice, from) if (!(buffer = (char *) malloc((unsigned) len))) return (ENOMEM); - if (!from) - from = &sin; - - *from = nextq->from; - + if (from) + *from = nextq->from; + (void) memcpy(buffer, nextq->packet, len); auth = nextq->auth; @@ -49,23 +46,5 @@ Code_t ZReceiveNotice(notice, from) if ((retval = ZParseNotice(buffer, len, notice)) != ZERR_NONE) return (retval); notice->z_checked_auth = auth; - - notice->z_dest_galaxy = "unknown-galaxy"; - - if (__ngalaxies == 1) { - /* assume everything is in the same galaxy */ - - notice->z_dest_galaxy = __galaxy_list[0].galaxy_config.galaxy; - } else { - for (i=0; i<__ngalaxies; i++) - for (j=0; j<__galaxy_list[i].galaxy_config.nservers; j++) - if (from->sin_addr.s_addr == - __galaxy_list[i].galaxy_config.server_list[j].addr.s_addr) { - notice->z_dest_galaxy = - __galaxy_list[i].galaxy_config.galaxy; - break; - } - } - return ZERR_NONE; } diff --git a/lib/ZRetSubs.c b/lib/ZRetSubs.c index e79941f..bd2cf5d 100644 --- a/lib/ZRetSubs.c +++ b/lib/ZRetSubs.c @@ -22,11 +22,9 @@ static Code_t Z_RetSubs (); /* Need STDC definition when possible for unsigned short argument. */ #ifdef __STDC__ -Code_t ZRetrieveSubscriptions(char *galaxy, - unsigned short port, int *nsubs) +Code_t ZRetrieveSubscriptions(unsigned short port, int *nsubs) #else -Code_t ZRetrieveSubscriptions(galaxy,port,nsubs) - ZCONST char *galaxy; +Code_t ZRetrieveSubscriptions(port,nsubs) unsigned short port; int *nsubs; #endif @@ -46,13 +44,11 @@ Code_t ZRetrieveSubscriptions(galaxy,port,nsubs) notice.z_message = asciiport; notice.z_message_len = strlen(asciiport)+1; notice.z_opcode = CLIENT_GIMMESUBS; - notice.z_dest_galaxy = galaxy; return(Z_RetSubs(¬ice, nsubs, ZAUTH)); } -Code_t ZRetrieveDefaultSubscriptions(galaxy, nsubs) - char *galaxy; +Code_t ZRetrieveDefaultSubscriptions(nsubs) int *nsubs; { ZNotice_t notice; @@ -61,7 +57,6 @@ Code_t ZRetrieveDefaultSubscriptions(galaxy, nsubs) notice.z_message = (char *) 0; notice.z_message_len = 0; notice.z_opcode = CLIENT_GIMMEDEFS; - notice.z_dest_galaxy = galaxy; return(Z_RetSubs(¬ice, nsubs, ZNOAUTH)); diff --git a/lib/ZSetDest.c b/lib/ZSetDest.c index f6b8b4b..7190dcd 100644 --- a/lib/ZSetDest.c +++ b/lib/ZSetDest.c @@ -21,5 +21,7 @@ Code_t ZSetDestAddr(addr) { __HM_addr = *addr; + __HM_set = 1; + return (ZERR_NONE); } diff --git a/lib/ZSubs.c b/lib/ZSubs.c index c8e5a03..15a5a91 100644 --- a/lib/ZSubs.c +++ b/lib/ZSubs.c @@ -17,48 +17,41 @@ static const char rcsid_ZSubscriptions_c[] = "$Id$"; #endif -static Code_t Z_Subscriptions __P((char *galaxy, - register ZSubscription_t *sublist, +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(galaxy, sublist, nitems, port) - char *galaxy; +Code_t ZSubscribeTo(sublist, nitems, port) ZSubscription_t *sublist; int nitems; unsigned int port; { - return (Z_Subscriptions(galaxy, sublist, nitems, port, - CLIENT_SUBSCRIBE, 1)); + return (Z_Subscriptions(sublist, nitems, port, CLIENT_SUBSCRIBE, 1)); } -Code_t ZSubscribeToSansDefaults(galaxy, sublist, nitems, port) - char *galaxy; +Code_t ZSubscribeToSansDefaults(sublist, nitems, port) ZSubscription_t *sublist; int nitems; unsigned int port; { - return (Z_Subscriptions(galaxy, sublist, nitems, port, - CLIENT_SUBSCRIBE_NODEFS, 1)); + return (Z_Subscriptions(sublist, nitems, port, CLIENT_SUBSCRIBE_NODEFS, + 1)); } -Code_t ZUnsubscribeTo(galaxy, sublist, nitems, port) - char *galaxy; +Code_t ZUnsubscribeTo(sublist, nitems, port) ZSubscription_t *sublist; int nitems; unsigned int port; { - return (Z_Subscriptions(galaxy, sublist, nitems, port, - CLIENT_UNSUBSCRIBE, 1)); + return (Z_Subscriptions(sublist, nitems, port, CLIENT_UNSUBSCRIBE, 1)); } -Code_t ZCancelSubscriptions(galaxy, port) - char *galaxy; +Code_t ZCancelSubscriptions(port) unsigned int port; { - return (Z_Subscriptions(galaxy, (ZSubscription_t *)0, 0, port, + return (Z_Subscriptions((ZSubscription_t *)0, 0, port, CLIENT_CANCELSUB, 0)); } @@ -69,8 +62,7 @@ Code_t ZCancelSubscriptions(galaxy, port) */ static Code_t -Z_Subscriptions(galaxy, sublist, nitems, port, opcode, authit) - char *galaxy; +Z_Subscriptions(sublist, nitems, port, opcode, authit) register ZSubscription_t *sublist; int nitems; unsigned int port; @@ -105,7 +97,6 @@ Z_Subscriptions(galaxy, sublist, nitems, port, opcode, authit) notice.z_recipient = ""; notice.z_default_format = ""; notice.z_message_len = 0; - notice.z_dest_galaxy = galaxy; /* format the header to figure out how long it is */ retval = Z_FormatHeader(¬ice, header, sizeof(header), &hdrlen, ZAUTH); diff --git a/lib/ZVariables.c b/lib/ZVariables.c index 7352860..1d9cd06 100644 --- a/lib/ZVariables.c +++ b/lib/ZVariables.c @@ -36,7 +36,7 @@ char *ZGetVariable(var) if ((ret = get_varval(varfile, var)) != ZERR_NONE) return (ret); - sprintf(varfile, "%s/zephyr/zephyr.vars", SYSCONFDIR); + sprintf(varfile, "%s/zephyr.vars", SYSCONFDIR); return (get_varval(varfile, var)); } diff --git a/lib/Zinternal.c b/lib/Zinternal.c index 5860b10..1a3fcec 100644 --- a/lib/Zinternal.c +++ b/lib/Zinternal.c @@ -15,8 +15,6 @@ #include <arpa/inet.h> #include <sys/socket.h> #include <utmp.h> -#include <unistd.h> -#include <netdb.h> #ifndef lint static const char rcsid_Zinternal_c[] = @@ -30,11 +28,13 @@ extern char *inet_ntoa (); int __Zephyr_fd = -1; int __Zephyr_open; int __Zephyr_port = -1; +struct in_addr __My_addr; int __Q_CompleteLength; int __Q_Size; struct _Z_InputQ *__Q_Head, *__Q_Tail; struct sockaddr_in __HM_addr; struct sockaddr_in __HM_addr_real; +int __HM_set; int __Zephyr_server; ZLocations_t *__locate_list; int __locate_num; @@ -44,9 +44,10 @@ int __subscriptions_num; int __subscriptions_next; int Z_discarded_packets = 0; -Z_GalaxyList *__galaxy_list; -int __ngalaxies; -int __default_galaxy; +#ifdef HAVE_KRB4 +C_Block __Zephyr_session; +#endif +char __Zephyr_realm[REALM_SZ]; #ifdef Z_DEBUG void (*__Z_debug_print) __P((const char *fmt, va_list args, void *closure)); @@ -222,7 +223,7 @@ Code_t Z_ReadWait() ZNotice_t notice; ZPacket_t packet; struct sockaddr_in olddest, from; - int i, j, from_len, packet_len, zvlen, part, partof; + int from_len, packet_len, zvlen, part, partof; char *slash; Code_t retval; fd_set fds; @@ -289,20 +290,8 @@ Code_t Z_ReadWait() if (find_or_insert_uid(¬ice.z_uid, notice.z_kind)) return(ZERR_NONE); - notice.z_dest_galaxy = "unknown-galaxy"; - - for (i=0; i<__ngalaxies; i++) - for (j=0; j<__galaxy_list[i].galaxy_config.nservers; j++) - if (from.sin_addr.s_addr == - __galaxy_list[i].galaxy_config.server_list[j].addr.s_addr) { - notice.z_dest_galaxy = __galaxy_list[i].galaxy_config.galaxy; - break; - } - - if ((notice.z_kind != HMACK) && (notice.z_kind != SERVACK)) { - /* Check authentication on the notice. */ - notice.z_checked_auth = ZCheckAuthentication(¬ice, &from); - } + /* Check authentication on the notice. */ + notice.z_checked_auth = ZCheckAuthentication(¬ice, &from); } @@ -482,6 +471,11 @@ Code_t Z_AddNoticeToEntry(qptr, notice, part) struct _Z_Hole *hole, *lasthole; struct timeval tv; + /* Bounds check. */ + if (part < 0 || notice->z_message_len < 0 || part > qptr->msg_len + || notice->z_message_len > qptr->msg_len - part) + return (ZERR_NONE); + /* Incorporate this notice's checked authentication. */ if (notice->z_checked_auth == ZAUTH_FAILED) qptr->auth = ZAUTH_FAILED; @@ -586,14 +580,6 @@ Code_t Z_AddNoticeToEntry(qptr, notice, part) return (ZERR_NONE); } -void Z_gettimeofday(struct _ZTimeval *ztv, struct timezone *tz) -{ - struct timeval tv; - (void) gettimeofday(&tv, tz); /* yeah, yeah, I know */ - ztv->tv_sec=tv.tv_sec; - ztv->tv_usec=tv.tv_usec; -} - Code_t Z_FormatHeader(notice, buffer, buffer_len, len, cert_routine) ZNotice_t *notice; char *buffer; @@ -605,7 +591,6 @@ Code_t Z_FormatHeader(notice, buffer, buffer_len, len, cert_routine) static char version[BUFSIZ]; /* default init should be all \0 */ struct sockaddr_in name; int namelen = sizeof(name); - int i, j; if (!notice->z_sender) notice->z_sender = ZGetSender(); @@ -624,22 +609,19 @@ Code_t Z_FormatHeader(notice, buffer, buffer_len, len, cert_routine) notice->z_multinotice = ""; - (void) Z_gettimeofday(¬ice->z_uid.tv, (struct timezone *)0); + (void) gettimeofday(¬ice->z_uid.tv, (struct timezone *)0); notice->z_uid.tv.tv_sec = htonl((u_long) notice->z_uid.tv.tv_sec); notice->z_uid.tv.tv_usec = htonl((u_long) notice->z_uid.tv.tv_usec); - - for (i=0; i<__ngalaxies; i++) - if (notice->z_dest_galaxy == 0 || - strcmp(__galaxy_list[i].galaxy_config.galaxy, - notice->z_dest_galaxy) == 0) { - memcpy(¬ice->z_uid.zuid_addr, - &__galaxy_list[i].galaxy_config.server_list[0].my_addr.s_addr, - sizeof(struct in_addr)); - break; - } + + (void) memcpy(¬ice->z_uid.zuid_addr, &__My_addr, sizeof(__My_addr)); notice->z_multiuid = notice->z_uid; + if (!version[0]) + (void) sprintf(version, "%s%d.%d", ZVERSIONHDR, ZVERSIONMAJOR, + ZVERSIONMINOR); + notice->z_version = version; + return Z_FormatAuthHeader(notice, buffer, buffer_len, len, cert_routine); } @@ -655,25 +637,20 @@ Code_t Z_FormatAuthHeader(notice, buffer, buffer_len, len, cert_routine) notice->z_authent_len = 0; notice->z_ascii_authent = ""; notice->z_checksum = 0; - return (Z_FormatRawHeader(notice, buffer, buffer_len, len, - NULL, NULL, NULL, NULL)); + return (Z_FormatRawHeader(notice, buffer, buffer_len, + len, NULL, NULL)); } return ((*cert_routine)(notice, buffer, buffer_len, len)); } -Code_t Z_FormatRawHeader(notice, buffer, buffer_len, hdr_len, - cksum_start, cksum_len, cstart, cend) +Code_t Z_FormatRawHeader(notice, buffer, buffer_len, len, cstart, cend) ZNotice_t *notice; char *buffer; int buffer_len; - int *hdr_len; - char **cksum_start; - int *cksum_len; + int *len; char **cstart, **cend; { - static char version_galaxy[BUFSIZ]; /* default init should be all \0 */ - static char version_nogalaxy[BUFSIZ]; /* default init should be all \0 */ char newrecip[BUFSIZ]; char *ptr, *end; int i; @@ -696,36 +673,13 @@ Code_t Z_FormatRawHeader(notice, buffer, buffer_len, hdr_len, ptr = buffer; end = buffer+buffer_len; - if (notice->z_dest_galaxy && - *notice->z_dest_galaxy) { - if (ZGetRhs(notice->z_dest_galaxy) == NULL) - return(ZERR_GALAXYUNKNOWN); - - if (!version_galaxy[0]) - (void) sprintf(version_galaxy, "%s%d.%d", ZVERSIONHDR, - ZVERSIONMAJOR, ZVERSIONMINOR_GALAXY); - - if (Z_AddField(&ptr, version_galaxy, end)) - return (ZERR_HEADERLEN); - - if (Z_AddField(&ptr, notice->z_dest_galaxy, end)) - return (ZERR_HEADERLEN); - } - - if (cksum_start) - *cksum_start = ptr; - - if (!version_nogalaxy[0]) - (void) sprintf(version_nogalaxy, "%s%d.%d", ZVERSIONHDR, - ZVERSIONMAJOR, ZVERSIONMINOR_NOGALAXY); - - notice->z_version = version_nogalaxy; - - if (Z_AddField(&ptr, version_nogalaxy, end)) + if (buffer_len < strlen(notice->z_version)+1) return (ZERR_HEADERLEN); - if (ZMakeAscii32(ptr, end-ptr, - Z_NUMFIELDS + notice->z_num_other_fields) + (void) strcpy(ptr, notice->z_version); + ptr += strlen(ptr)+1; + + if (ZMakeAscii32(ptr, end-ptr, Z_NUMFIELDS + notice->z_num_other_fields) == ZERR_FIELDLEN) return (ZERR_HEADERLEN); ptr += strlen(ptr)+1; @@ -766,8 +720,10 @@ Code_t Z_FormatRawHeader(notice, buffer, buffer_len, hdr_len, return (ZERR_HEADERLEN); } else { - (void) sprintf(newrecip, "%s@%s", notice->z_recipient, - ZGetRhs(notice->z_dest_galaxy)); + if (strlen(notice->z_recipient) + strlen(__Zephyr_realm) + 2 > + sizeof(newrecip)) + return (ZERR_HEADERLEN); + (void) sprintf(newrecip, "%s@%s", notice->z_recipient, __Zephyr_realm); if (Z_AddField(&ptr, newrecip, end)) return (ZERR_HEADERLEN); } @@ -795,11 +751,8 @@ Code_t Z_FormatRawHeader(notice, buffer, buffer_len, hdr_len, if (Z_AddField(&ptr, notice->z_other_fields[i], end)) return (ZERR_HEADERLEN); - if (cksum_len) - *cksum_len = ptr-*cksum_start; - - *hdr_len = ptr-buffer; - + *len = ptr-buffer; + return (ZERR_NONE); } @@ -908,7 +861,7 @@ Code_t Z_SendFragmentedNotice(notice, len, cert_func, send_func) ZNotice_t partnotice; ZPacket_t buffer; char multi[64]; - int i, offset, hdrsize, fragsize, ret_len, message_len, waitforack; + int offset, hdrsize, fragsize, ret_len, message_len, waitforack; Code_t retval; hdrsize = len-notice->z_message_len; @@ -925,22 +878,14 @@ Code_t Z_SendFragmentedNotice(notice, len, cert_func, send_func) (void) sprintf(multi, "%d/%d", offset, notice->z_message_len); partnotice.z_multinotice = multi; if (offset > 0) { - (void) Z_gettimeofday(&partnotice.z_uid.tv, - (struct timezone *)0); + (void) gettimeofday(&partnotice.z_uid.tv, + (struct timezone *)0); partnotice.z_uid.tv.tv_sec = htonl((u_long) partnotice.z_uid.tv.tv_sec); partnotice.z_uid.tv.tv_usec = htonl((u_long) partnotice.z_uid.tv.tv_usec); - - for (i=0; i<__ngalaxies; i++) - if (notice->z_dest_galaxy == 0 || - strcmp(__galaxy_list[i].galaxy_config.galaxy, - notice->z_dest_galaxy) == 0) { - memcpy((char *)&partnotice.z_uid.zuid_addr, - &__galaxy_list[i].galaxy_config.server_list[0].my_addr.s_addr, - sizeof(struct in_addr)); - break; - } + (void) memcpy((char *)&partnotice.z_uid.zuid_addr, &__My_addr, + sizeof(__My_addr)); } message_len = min(notice->z_message_len-offset, fragsize); partnotice.z_message = notice->z_message+offset; @@ -962,364 +907,6 @@ Code_t Z_SendFragmentedNotice(notice, len, cert_func, send_func) return (ZERR_NONE); } -void Z_SourceAddr(peer_addr, my_addr) - struct in_addr *peer_addr, *my_addr; -{ - int s; - struct sockaddr_in s_in; - socklen_t sinsize; - struct hostent *hent; - char hostname[1024]; - - my_addr->s_addr = INADDR_NONE; - - if (peer_addr->s_addr != INADDR_NONE) { - /* Try to get the local interface address by connecting a UDP - * socket to the server address and getting the local address. - * Some broken operating systems (e.g. Solaris 2.0-2.5) yield - * INADDR_ANY (zero), so we have to check for that. */ - s = socket(AF_INET, SOCK_DGRAM, 0); - if (s != -1) { - memset(&s_in, 0, sizeof(s_in)); - s_in.sin_family = AF_INET; - memcpy(&s_in.sin_addr, peer_addr, sizeof(*peer_addr)); - s_in.sin_port = HM_SRV_SVC_FALLBACK; - sinsize = sizeof(s_in); - if (connect(s, (struct sockaddr *) &s_in, sizeof(s_in)) == 0 - && getsockname(s, (struct sockaddr *) &s_in, &sinsize) == 0 - && s_in.sin_addr.s_addr != 0) - memcpy(my_addr, &s_in.sin_addr, sizeof(*my_addr)); - close(s); - } - } - - if (my_addr->s_addr == INADDR_NONE) { - /* We couldn't figure out the local interface address by the - * above method. Try by resolving the local hostname. (This - * is a pretty broken thing to do) */ - if (gethostname(hostname, sizeof(hostname)) == 0) { - hent = gethostbyname(hostname); - if (hent && hent->h_addrtype == AF_INET) - memcpy(my_addr, hent->h_addr, sizeof(*my_addr)); - } - } - - /* If the above methods failed, zero out my_addr so things will - * sort of kind of work. */ - if (my_addr->s_addr == INADDR_NONE) - my_addr->s_addr = 0; -} - -Code_t Z_ParseGalaxyConfig(str, gc) - char *str; - Z_GalaxyConfig *gc; -{ - char *ptra, *ptrb; - struct hostent *hp; - enum { CLUSTER, SLOC, HOSTLIST } listtype; - int hostcount; - struct in_addr *my_addr, *serv_addr; -#ifdef HAVE_HESIOD - char **hes_serv_list; -#endif - - gc->galaxy = NULL; - - /* skip whitespace, check for eol or comment */ - - ptra = str; - while (*ptra && isspace(*ptra)) ptra++; - - if (*ptra == '\0' || *ptra == '#') { - /* no galaxy is ok, it's a blank line */ - return(ZERR_NONE); - } - - /* scan the galaxy */ - - ptrb = ptra; - while(*ptrb && !isspace(*ptrb) && *ptrb != '#') ptrb++; - - if ((gc->galaxy = (char *) malloc(ptrb - ptra + 1)) == NULL) - return(ENOMEM); - - strncpy(gc->galaxy, ptra, ptrb - ptra); - gc->galaxy[ptrb - ptra] = '\0'; - - /* skip whitespace, check for eol or comment */ - - ptra = ptrb; - while (*ptra && isspace(*ptra)) ptra++; - - if (*ptra == '\0' || *ptra == '#') { - free(gc->galaxy); - return(ZERR_BADCONFGALAXY); - } - - /* scan the type */ - - ptrb = ptra; - while(*ptrb && !isspace(*ptrb) && *ptrb != '#') ptrb++; - -#ifdef HAVE_HESIOD - if (strncasecmp("hes-cluster", ptra, ptrb - ptra) == 0) { - listtype = CLUSTER; - } else if (strncasecmp("hes-sloc", ptra, ptrb - ptra) == 0) { - listtype = SLOC; - } else -#endif - if (strncasecmp("hostlist", ptra, ptrb - ptra) == 0) { - listtype = HOSTLIST; - } else { - free(gc->galaxy); - return(ZERR_BADCONF); - } - -#ifdef HAVE_HESIOD - if (listtype == CLUSTER || listtype == SLOC) { - char *zcluster; - - if (listtype == CLUSTER) { - char hostname[1024]; - - if (gethostname(hostname, sizeof(hostname)) != 0) { - zcluster = 0; - } else { - char **clust_info, **cpp; - - if ((clust_info = hes_resolve(hostname, "CLUSTER")) == NULL) { - zcluster = 0; - } else { - for (cpp = clust_info; *cpp; cpp++) { - if (strncasecmp("ZCLUSTER", *cpp, 9) == 0) { - register char *c; - - if ((c = strchr(*cpp, ' ')) == 0) { - for (cpp = clust_info; *cpp; cpp++) - free(*cpp); - return(ZERR_BADCONFGALAXY); - } else { - if ((zcluster = - malloc((unsigned)(strlen(c+1)+1))) - != NULL) { - strcpy(zcluster, c+1); - } else { - for (cpp = clust_info; *cpp; cpp++) - free(*cpp); - return(ENOMEM); - } - } - break; - } - } - for (cpp = clust_info; *cpp; cpp++) - free(*cpp); - if (zcluster == NULL) { - if ((zcluster = - malloc((unsigned)(strlen("zephyr")+1))) != NULL) - strcpy(zcluster, "zephyr"); - else - return(ENOMEM); - } - } - } - } else { - /* skip whitespace, check for eol or comment */ - - ptra = ptrb; - while (*ptra && isspace(*ptra)) ptra++; - - if (*ptra == '\0' || *ptra == '#') { - free(gc->galaxy); - return(ZERR_BADCONFGALAXY); - } - - /* scan for the service name for the sloc lookup */ - - ptrb = ptra; - while(*ptrb && !isspace(*ptrb) && *ptrb != '#') ptrb++; - - if ((zcluster = (char *) malloc(ptrb - ptra + 1)) == NULL) { - free(gc->galaxy); - return(ENOMEM); - } - - strncpy(zcluster, ptra, ptrb - ptra); - zcluster[ptrb - ptra] = '\0'; - - /* skip whitespace, check for eol or comment */ - - ptra = ptrb; - while (*ptra && isspace(*ptra)) ptra++; - - if (*ptra != '\0' && *ptra != '#') { - free(zcluster); - free(gc->galaxy); - return(ZERR_BADCONF); - } - } - - /* get the server list from hesiod */ - - if (((hes_serv_list = hes_resolve(zcluster, "sloc")) == NULL) || - (hes_serv_list[0] == NULL)) { - syslog(LOG_ERR, "No hesiod for galaxy %s (%s sloc)", - gc->galaxy, zcluster); - free(zcluster); - free(gc->galaxy); - /* treat this as an empty line, since other lines may succeed */ - gc->galaxy = NULL; - return(ZERR_NONE); - } - - free(zcluster); - } -#endif - - /* scan hosts */ - - gc->server_list = NULL; - gc->nservers = 0; - hostcount = 0; - - while (1) { - if (gc->server_list) { - gc->server_list = (Z_SrvNameAddr *) - realloc(gc->server_list, - sizeof(Z_SrvNameAddr)*(gc->nservers+1)); - } else { - gc->server_list = (Z_SrvNameAddr *) - malloc(sizeof(Z_SrvNameAddr)); - } - - if (gc->server_list == NULL) { - free(gc->galaxy); - return(ENOMEM); - } - -#ifdef HAVE_HESIOD - if (listtype == CLUSTER || listtype == SLOC) { - if (*hes_serv_list == NULL) - break; - - /* this is clean, but only because hesiod memory management - is gross */ - gc->server_list[gc->nservers].name = *hes_serv_list; - hes_serv_list++; - } else -#endif - if (listtype == HOSTLIST) { - /* skip whitespace, check for eol or comment */ - - ptra = ptrb; - while (*ptra && isspace(*ptra)) ptra++; - - if (*ptra == '\0' || *ptra == '#') { - /* end of server list */ - break; - } - - /* scan a hostname */ - - ptrb = ptra; - while(*ptrb && !isspace(*ptrb) && *ptrb != '#') ptrb++; - - if ((gc->server_list[gc->nservers].name = - (char *) malloc(ptrb - ptra + 1)) - == NULL) { - free(gc->server_list); - free(gc->galaxy); - return(ENOMEM); - } - - strncpy(gc->server_list[gc->nservers].name, ptra, ptrb - ptra); - gc->server_list[gc->nservers].name[ptrb - ptra] = '\0'; - } - - hostcount++; - - /* now, take the hesiod or hostlist hostname, and resolve it */ - - if ((hp = gethostbyname(gc->server_list[gc->nservers].name)) == NULL) { - /* if the address lookup fails authoritatively from a - hostlist, return an error. Otherwise, syslog. This - could cause a syslog from a client, but only if a - lookup which succeeded from zhm earlier fails now. - This isn't perfect, but will do. */ - - if (h_errno != TRY_AGAIN && listtype == HOSTLIST) { - free(gc->server_list); - free(gc->galaxy); - return(ZERR_BADCONFHOST); - } else { - syslog(LOG_ERR, "Lookup for server %s for galaxy %s failed, continuing", - gc->server_list[gc->nservers].name, gc->galaxy); - - /* in an ideal world, when we need to find a new - server, or when we receive a packet from a server - we don't know, we would redo the lookup, but this - takes a long time, and blocks. So for now, we'll - only do this when we reread the config info. */ - - continue; - } - } - - /* XXX this isn't quite right for multihomed servers. In that - case, we should add an entry to server_list for each unique - address */ - - serv_addr = &gc->server_list[gc->nservers].addr; - - if (hp->h_length < sizeof(*serv_addr)) { - syslog(LOG_ERR, "Lookup for server %s for galaxy %s failed (h_length < %d), continuing", - gc->server_list[gc->nservers].name, gc->galaxy, - sizeof(*serv_addr));; - continue; - } - - memcpy((char *) serv_addr, hp->h_addr, sizeof(*serv_addr)); - - my_addr = &gc->server_list[gc->nservers].my_addr; - - Z_SourceAddr(serv_addr, my_addr); - - gc->nservers++; - } - - if (gc->nservers == 0) { - if (hostcount) { - /* this means the net was losing. skip this galaxy, because - another one might be ok. */ - - free(gc->server_list); - free(gc->galaxy); - gc->galaxy = NULL; - return(ZERR_NONE); - } else { - /* this means that a hostlist was empty */ - - return(ZERR_BADCONFGALAXY); - } - } - - return(ZERR_NONE); -} - -Code_t Z_FreeGalaxyConfig(gc) - Z_GalaxyConfig *gc; -{ - int i; - - for (i=0; i<gc->nservers; i++) - free(gc->server_list[i].name); - - free(gc->server_list); - free(gc->galaxy); - - return(ZERR_NONE); -} - /*ARGSUSED*/ Code_t Z_XmitFragment(notice, buf, len, wait) ZNotice_t *notice; @@ -1387,6 +974,9 @@ int ZQLength () { return __Q_CompleteLength; } #undef ZGetDestAddr struct sockaddr_in ZGetDestAddr () { return __HM_addr; } +#undef ZGetRealm +Zconst char * ZGetRealm () { return __Zephyr_realm; } + #undef ZSetDebug void ZSetDebug(proc, arg) void (*proc) __P((const char *, va_list, void *)); diff --git a/lib/zephyr_err.et b/lib/zephyr_err.et index 3f24aec..8fae4b3 100644 --- a/lib/zephyr_err.et +++ b/lib/zephyr_err.et @@ -53,13 +53,5 @@ ec ZERR_TOOMANYSUBS, "Too many subscriptions to transmit" ec ZERR_EOF, "End of file detected during read" -ec ZERR_BADCONF, - "Error parsing configuration file" -ec ZERR_BADCONFHOST, - "Unknown host parsing configuration file" -ec ZERR_BADCONFGALAXY, - "Galaxy had no servers while parsing configuration file" -ec ZERR_GALAXYUNKNOWN, - "Unknown zephyr galaxy" end |