summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/ZAsyncLocate.c4
-rw-r--r--lib/ZCkAuth.c7
-rw-r--r--lib/ZFmtAuth.c8
-rw-r--r--lib/ZFmtRaw.c4
-rw-r--r--lib/ZFmtRawLst.c6
-rw-r--r--lib/ZFmtSmRLst.c4
-rw-r--r--lib/ZFmtSmRaw.c4
-rw-r--r--lib/ZGetSender.c4
-rw-r--r--lib/ZInit.c167
-rw-r--r--lib/ZLocations.c19
-rw-r--r--lib/ZMkAuth.c83
-rw-r--r--lib/ZNewLocU.c6
-rw-r--r--lib/ZOpenPort.c8
-rw-r--r--lib/ZParseNot.c59
-rw-r--r--lib/ZReadAscii.c15
-rw-r--r--lib/ZRecvNot.c29
-rw-r--r--lib/ZRetSubs.c11
-rw-r--r--lib/ZSetDest.c2
-rw-r--r--lib/ZSubs.c31
-rw-r--r--lib/zephyr_err.et8
20 files changed, 274 insertions, 205 deletions
diff --git a/lib/ZAsyncLocate.c b/lib/ZAsyncLocate.c
index d248064..055cc52 100644
--- a/lib/ZAsyncLocate.c
+++ b/lib/ZAsyncLocate.c
@@ -16,7 +16,8 @@
static const char rcsid_ZAsyncLocate_c[] = "$Id$";
#endif
-Code_t ZRequestLocations(user, zald, kind, auth)
+Code_t ZRequestLocations(galaxy, user, zald, kind, auth)
+ char *galaxy;
char *user;
register ZAsyncLocateData_t *zald;
ZNotice_Kind_t kind; /* UNSAFE, UNACKED, or ACKED */
@@ -39,6 +40,7 @@ Code_t ZRequestLocations(user, zald, kind, auth)
notice.z_recipient = "";
notice.z_default_format = "";
notice.z_message_len = 0;
+ notice.z_dest_galaxy = galaxy;
if ((retval = ZSendNotice(&notice, auth)) != ZERR_NONE)
return(retval);
diff --git a/lib/ZCkAuth.c b/lib/ZCkAuth.c
index 17fdc2b..8db1f94 100644
--- a/lib/ZCkAuth.c
+++ b/lib/ZCkAuth.c
@@ -33,6 +33,7 @@ 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)
@@ -41,8 +42,12 @@ 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,
- __Zephyr_realm, &cred)) != 0)
+ realm, &cred)) != 0)
return (ZAUTH_NO);
#ifdef NOENCRYPTION
diff --git a/lib/ZFmtAuth.c b/lib/ZFmtAuth.c
index c2d8a00..29ed7f7 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, &ptr, NULL)) != ZERR_NONE)
+ if ((retval = Z_FormatRawHeader(&newnotice, buffer, buffer_len, &hdrlen,
+ NULL, NULL, &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)) != ZERR_NONE)
+ if ((retval = Z_FormatRawHeader(&newnotice, buffer, buffer_len, &hdrlen,
+ NULL, NULL, NULL, NULL)) != ZERR_NONE)
return (retval);
ptr = buffer+hdrlen;
diff --git a/lib/ZFmtRaw.c b/lib/ZFmtRaw.c
index 2940f98..6e2f2cc 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)) != ZERR_NONE)
+ if ((retval = Z_FormatRawHeader(notice, header, sizeof(header), &hdrlen,
+ NULL, NULL, NULL, NULL)) != ZERR_NONE)
return (retval);
*ret_len = hdrlen+notice->z_message_len;
diff --git a/lib/ZFmtRawLst.c b/lib/ZFmtRawLst.c
index 7d83f71..1d7acd6 100644
--- a/lib/ZFmtRawLst.c
+++ b/lib/ZFmtRawLst.c
@@ -3,7 +3,7 @@
*
* Created by: Robert French
*
- * $Id$
+n * $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)) != ZERR_NONE)
+ if ((retval = Z_FormatRawHeader(notice, header, sizeof(header), &hdrlen,
+ NULL, NULL, NULL, NULL)) != ZERR_NONE)
return (retval);
size = 0;
diff --git a/lib/ZFmtSmRLst.c b/lib/ZFmtSmRLst.c
index 6e41285..31574a2 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)) != ZERR_NONE)
+ if ((retval = Z_FormatRawHeader(notice, buffer, Z_MAXHEADERLEN, &hdrlen,
+ NULL, NULL, NULL, NULL)) != ZERR_NONE)
return (retval);
size = 0;
diff --git a/lib/ZFmtSmRaw.c b/lib/ZFmtSmRaw.c
index a9ce79d..cae6d4b 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)) != ZERR_NONE)
+ if ((retval = Z_FormatRawHeader(notice, buffer, Z_MAXHEADERLEN, &hdrlen,
+ NULL, NULL, NULL, NULL)) != ZERR_NONE)
return (retval);
*ret_len = hdrlen+notice->z_message_len;
diff --git a/lib/ZGetSender.c b/lib/ZGetSender.c
index df5f3e2..aac5d7c 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.c function.
+ * It contains source for the ZGetSender 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, __Zephyr_realm);
+ (void) sprintf(sender, "%s@%s", pw->pw_name, ZGetRhs(NULL));
return (sender);
}
diff --git a/lib/ZInit.c b/lib/ZInit.c
index 401f6db..9eb0fa5 100644
--- a/lib/ZInit.c
+++ b/lib/ZInit.c
@@ -18,6 +18,18 @@ 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
@@ -30,17 +42,15 @@ Code_t ZInitialize()
{
struct servent *hmserv;
struct hostent *hostent;
- char addr[4], hostname[MAXHOSTNAMELEN];
- struct in_addr servaddr;
+ char hostname[MAXHOSTNAMELEN], *def;
struct sockaddr_in sin;
int s, sinsize = sizeof(sin);
Code_t code;
ZNotice_t notice;
+ char *mp;
+ int i;
#ifdef HAVE_KRB4
- char *krealm = NULL;
- int krbval;
- char d1[ANAME_SZ], d2[INST_SZ];
-
+ char *krealm;
initialize_krb_error_table();
#endif
@@ -49,20 +59,14 @@ Code_t ZInitialize()
(void) memset((char *)&__HM_addr, 0, sizeof(__HM_addr));
__HM_addr.sin_family = AF_INET;
-
- /* Set up local loopback address for HostManager */
- addr[0] = 127;
- addr[1] = 0;
- addr[2] = 0;
- addr[3] = 1;
+#ifdef HAVE_SA_LEN
+ __HM_addr.sin_len = sizeof (struct sockaddr_in);
+#endif
+ __HM_addr.sin_addr.s_addr = htonl (0x7f000001L);
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;
@@ -71,7 +75,6 @@ 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);
@@ -85,62 +88,94 @@ 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(notice.z_message);
-#endif
- hostent = gethostbyname(notice.z_message);
- if (hostent && hostent->h_addrtype == AF_INET)
- memcpy(&servaddr, hostent->h_addr, sizeof(servaddr));
+ krealm = krb_realmofhost(__galaxy_list[0].galaxy_config.server_list[0].name);
+ if (!krealm)
+ krealm = "";
- ZFreeNotice(&notice);
- }
+ strcpy(__galaxy_list[0].krealm, krealm);
+
+ __galaxy_list[0].last_authent_time = 0;
+#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);
+ }
#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");
+ krealm = krb_realmofhost(__galaxy_list[i/12].galaxy_config.server_list[0].name);
+ if (!krealm)
+ krealm = "";
+
+ strcpy(__galaxy_list[i/12].krealm, krealm);
+
+ __galaxy_list[i/12].last_authent_time = 0;
#endif
+ }
+ }
+ }
- __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));
- }
+ ZFreeNotice(&notice);
+
+ __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;
}
- /* 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/ZLocations.c b/lib/ZLocations.c
index e157342..a237604 100644
--- a/lib/ZLocations.c
+++ b/lib/ZLocations.c
@@ -56,22 +56,25 @@ Code_t ZInitLocationInfo(hostname, tty)
return (ZERR_NONE);
}
-Code_t ZSetLocation(exposure)
+Code_t ZSetLocation(galaxy, exposure)
+ char *galaxy;
char *exposure;
{
- return (Z_SendLocation(LOGIN_CLASS, exposure, ZAUTH,
+ return (Z_SendLocation(galaxy, LOGIN_CLASS, exposure, ZAUTH,
"$sender logged in to $1 on $3 at $2"));
}
-Code_t ZUnsetLocation()
+Code_t ZUnsetLocation(galaxy)
+ char *galaxy;
{
- return (Z_SendLocation(LOGIN_CLASS, LOGIN_USER_LOGOUT, ZNOAUTH,
+ return (Z_SendLocation(galaxy, LOGIN_CLASS, LOGIN_USER_LOGOUT, ZNOAUTH,
"$sender logged out of $1 on $3 at $2"));
}
-Code_t ZFlushMyLocations()
+Code_t ZFlushMyLocations(galaxy)
+ char *galaxy;
{
- return (Z_SendLocation(LOGIN_CLASS, LOGIN_USER_FLUSH, ZAUTH, ""));
+ return (Z_SendLocation(galaxy, LOGIN_CLASS, LOGIN_USER_FLUSH, ZAUTH, ""));
}
char *ZParseExposureLevel(text)
@@ -93,7 +96,8 @@ char *ZParseExposureLevel(text)
return(NULL);
}
-Code_t Z_SendLocation(class, opcode, auth, format)
+Code_t Z_SendLocation(galaxy, class, opcode, auth, format)
+ char *galaxy;
char *class;
char *opcode;
Z_AuthProc auth;
@@ -119,6 +123,7 @@ Code_t Z_SendLocation(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 cbd3136..1a35058 100644
--- a/lib/ZMkAuth.c
+++ b/lib/ZMkAuth.c
@@ -16,47 +16,76 @@
static const char rcsid_ZMakeAuthentication_c[] = "$Id$";
#endif
-#ifdef HAVE_KRB4
-#include <krb_err.h>
-static long last_authent_time = 0L;
-static KTEXT_ST last_authent;
-#endif
-
Code_t ZResetAuthentication () {
#ifdef HAVE_KRB4
- last_authent_time = 0L;
+ int i;
+
+ for (i=0; i<__ngalaxies; i++)
+ __galaxy_list[i].last_authent_time = 0;
+
#endif
return ZERR_NONE;
}
-Code_t ZMakeAuthentication(notice, buffer, buffer_len, len)
+Code_t ZMakeAuthentication(notice, buffer, buffer_len, phdr_len)
register ZNotice_t *notice;
char *buffer;
int buffer_len;
- int *len;
+ int *phdr_len;
{
#ifdef HAVE_KRB4
+ int i;
+ int cksum_len;
int result;
time_t now;
KTEXT_ST authent;
- char *cstart, *cend;
+ char *krealm, *cksum_start, *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;
+ }
+
+ 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 (last_authent_time == 0 || (now - last_authent_time > 120)) {
- result = krb_mk_req(&authent, SERVER_SERVICE,
- SERVER_INSTANCE, __Zephyr_realm, 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) {
- last_authent_time = 0;
+ __galaxy_list[i].last_authent_time = 0;
return (result+krb_err_base);
}
- last_authent_time = now;
- last_authent = authent;
+ __galaxy_list[i].last_authent_time = now;
+ __galaxy_list[i].last_authent = authent;
}
else {
- authent = last_authent;
+ authent = __galaxy_list[i].last_authent;
}
notice->z_auth = 1;
notice->z_authent_len = authent.length;
@@ -71,31 +100,27 @@ Code_t ZMakeAuthentication(notice, buffer, buffer_len, len)
free(notice->z_ascii_authent);
return (result);
}
- result = Z_FormatRawHeader(notice, buffer, buffer_len, len, &cstart,
- &cend);
+ result = Z_FormatRawHeader(notice, buffer, buffer_len, phdr_len,
+ &cksum_start, &cksum_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,
- __Zephyr_realm, &cred)) != 0)
+ krealm, &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,
+ 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,
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 9ad620d..94a1278 100644
--- a/lib/ZNewLocU.c
+++ b/lib/ZNewLocU.c
@@ -17,7 +17,8 @@ static const char rcsid_ZNewLocateUser_c[] =
"$Id$";
#endif
-Code_t ZLocateUser(user, nlocs, auth)
+Code_t ZLocateUser(galaxy, user, nlocs, auth)
+ char *galaxy;
char *user;
int *nlocs;
Z_AuthProc auth;
@@ -29,7 +30,8 @@ Code_t ZLocateUser(user, nlocs, auth)
(void) ZFlushLocations(); /* ZFlushLocations never fails (the library
is allowed to know this). */
- if ((retval = ZRequestLocations(user, &zald, UNACKED, auth)) != ZERR_NONE)
+ if ((retval = ZRequestLocations(galaxy, user, &zald, UNACKED,
+ auth)) != ZERR_NONE)
return(retval);
retval = Z_WaitForNotice (&notice, ZCompareALDPred, &zald, SRV_TIMEOUT);
diff --git a/lib/ZOpenPort.c b/lib/ZOpenPort.c
index b8241db..ee043ae 100644
--- a/lib/ZOpenPort.c
+++ b/lib/ZOpenPort.c
@@ -68,3 +68,11 @@ 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 6d393a0..44dbaf6 100644
--- a/lib/ZParseNot.c
+++ b/lib/ZParseNot.c
@@ -17,56 +17,8 @@ static char rcsid_ZParseNotice_c[] =
#include <internal.h>
-/* Assume that strlen is efficient on this machine... */
#define next_field(ptr) ptr += strlen (ptr) + 1
-#if defined (__GNUC__) && defined (__vax__)
-#undef next_field
-static __inline__ char * Istrend (char *str) {
- /*
- * This should be faster on VAX models outside the 2 series. Don't
- * use it if you are using MicroVAX 2 servers. If you are using a
- * VS2 server, use something like
- * #define next_field(ptr) while(*ptr++)
- * instead of this code.
- *
- * This requires use of GCC to get the optimized code, but
- * everybody uses GCC, don't they? :-)
- */
- register char *str2 asm ("r1");
- /* Assumes that no field is longer than 64K.... */
- asm ("locc $0,$65535,(%1)" : "=r" (str2) : "r" (str) : "r0");
- return str2;
-}
-#define next_field(ptr) ptr = Istrend (ptr) + 1
-#endif
-
-#ifdef mips
-#undef next_field
-/*
- * The compiler doesn't optimize this macro as well as it does the
- * following function.
- */
-#define next_fieldXXX(ptr) do{register unsigned c1,c2;c1= *ptr; \
- while((ptr++,c2= *ptr,c1)&&(ptr++,c1= *ptr,c2));}while(0)
-static char *next_field_1 (s) char *s; {
- /*
- * Calling overhead is still present, but this routine is faster
- * than strlen, and doesn't bother with some of the other math
- * that we'd just have to undo later anyways.
- */
- register unsigned c1 = *s, c2;
- while (1) {
- s++; c2 = *s; if (c1 == 0) break;
- s++; c1 = *s; if (c2 == 0) break;
- s++; c2 = *s; if (c1 == 0) break;
- s++; c1 = *s; if (c2 == 0) break;
- }
- return s;
-}
-#define next_field(ptr) ptr=next_field_1(ptr)
-#endif
-
Code_t ZParseNotice(buffer, len, notice)
char *buffer;
int len;
@@ -74,7 +26,7 @@ Code_t ZParseNotice(buffer, len, notice)
{
char *ptr, *end;
unsigned long temp;
- int maj, numfields, i;
+ int maj, min, numfields, i;
#ifdef __LINE__
int lineno;
@@ -110,8 +62,17 @@ 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);
+ }
+
if (ZReadAscii32(ptr, end-ptr, &temp) == ZERR_BADFIELD)
BAD_PACKET;
numfields = temp;
diff --git a/lib/ZReadAscii.c b/lib/ZReadAscii.c
index f826bc7..baf7469 100644
--- a/lib/ZReadAscii.c
+++ b/lib/ZReadAscii.c
@@ -17,21 +17,6 @@ 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)
diff --git a/lib/ZRecvNot.c b/lib/ZRecvNot.c
index 27cba29..bfed17a 100644
--- a/lib/ZRecvNot.c
+++ b/lib/ZRecvNot.c
@@ -22,8 +22,9 @@ Code_t ZReceiveNotice(notice, from)
{
char *buffer;
struct _Z_InputQ *nextq;
- int len, auth;
+ int len, auth, i, j;
Code_t retval;
+ struct sockaddr_in sin;
if ((retval = Z_WaitForComplete()) != ZERR_NONE)
return (retval);
@@ -35,9 +36,11 @@ Code_t ZReceiveNotice(notice, from)
if (!(buffer = (char *) malloc((unsigned) len)))
return (ENOMEM);
- if (from)
- *from = nextq->from;
-
+ if (!from)
+ from = &sin;
+
+ *from = nextq->from;
+
(void) memcpy(buffer, nextq->packet, len);
auth = nextq->auth;
@@ -46,5 +49,23 @@ 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 bd2cf5d..e79941f 100644
--- a/lib/ZRetSubs.c
+++ b/lib/ZRetSubs.c
@@ -22,9 +22,11 @@ static Code_t Z_RetSubs ();
/* Need STDC definition when possible for unsigned short argument. */
#ifdef __STDC__
-Code_t ZRetrieveSubscriptions(unsigned short port, int *nsubs)
+Code_t ZRetrieveSubscriptions(char *galaxy,
+ unsigned short port, int *nsubs)
#else
-Code_t ZRetrieveSubscriptions(port,nsubs)
+Code_t ZRetrieveSubscriptions(galaxy,port,nsubs)
+ ZCONST char *galaxy;
unsigned short port;
int *nsubs;
#endif
@@ -44,11 +46,13 @@ Code_t ZRetrieveSubscriptions(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(&notice, nsubs, ZAUTH));
}
-Code_t ZRetrieveDefaultSubscriptions(nsubs)
+Code_t ZRetrieveDefaultSubscriptions(galaxy, nsubs)
+ char *galaxy;
int *nsubs;
{
ZNotice_t notice;
@@ -57,6 +61,7 @@ Code_t ZRetrieveDefaultSubscriptions(nsubs)
notice.z_message = (char *) 0;
notice.z_message_len = 0;
notice.z_opcode = CLIENT_GIMMEDEFS;
+ notice.z_dest_galaxy = galaxy;
return(Z_RetSubs(&notice, nsubs, ZNOAUTH));
diff --git a/lib/ZSetDest.c b/lib/ZSetDest.c
index 7190dcd..f6b8b4b 100644
--- a/lib/ZSetDest.c
+++ b/lib/ZSetDest.c
@@ -21,7 +21,5 @@ Code_t ZSetDestAddr(addr)
{
__HM_addr = *addr;
- __HM_set = 1;
-
return (ZERR_NONE);
}
diff --git a/lib/ZSubs.c b/lib/ZSubs.c
index 15a5a91..c8e5a03 100644
--- a/lib/ZSubs.c
+++ b/lib/ZSubs.c
@@ -17,41 +17,48 @@
static const char rcsid_ZSubscriptions_c[] = "$Id$";
#endif
-static Code_t Z_Subscriptions __P((register ZSubscription_t *sublist,
+static Code_t Z_Subscriptions __P((char *galaxy,
+ 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)
+Code_t ZSubscribeTo(galaxy, sublist, nitems, port)
+ char *galaxy;
ZSubscription_t *sublist;
int nitems;
unsigned int port;
{
- return (Z_Subscriptions(sublist, nitems, port, CLIENT_SUBSCRIBE, 1));
+ return (Z_Subscriptions(galaxy, sublist, nitems, port,
+ CLIENT_SUBSCRIBE, 1));
}
-Code_t ZSubscribeToSansDefaults(sublist, nitems, port)
+Code_t ZSubscribeToSansDefaults(galaxy, sublist, nitems, port)
+ char *galaxy;
ZSubscription_t *sublist;
int nitems;
unsigned int port;
{
- return (Z_Subscriptions(sublist, nitems, port, CLIENT_SUBSCRIBE_NODEFS,
- 1));
+ return (Z_Subscriptions(galaxy, sublist, nitems, port,
+ CLIENT_SUBSCRIBE_NODEFS, 1));
}
-Code_t ZUnsubscribeTo(sublist, nitems, port)
+Code_t ZUnsubscribeTo(galaxy, sublist, nitems, port)
+ char *galaxy;
ZSubscription_t *sublist;
int nitems;
unsigned int port;
{
- return (Z_Subscriptions(sublist, nitems, port, CLIENT_UNSUBSCRIBE, 1));
+ return (Z_Subscriptions(galaxy, sublist, nitems, port,
+ CLIENT_UNSUBSCRIBE, 1));
}
-Code_t ZCancelSubscriptions(port)
+Code_t ZCancelSubscriptions(galaxy, port)
+ char *galaxy;
unsigned int port;
{
- return (Z_Subscriptions((ZSubscription_t *)0, 0, port,
+ return (Z_Subscriptions(galaxy, (ZSubscription_t *)0, 0, port,
CLIENT_CANCELSUB, 0));
}
@@ -62,7 +69,8 @@ Code_t ZCancelSubscriptions(port)
*/
static Code_t
-Z_Subscriptions(sublist, nitems, port, opcode, authit)
+Z_Subscriptions(galaxy, sublist, nitems, port, opcode, authit)
+ char *galaxy;
register ZSubscription_t *sublist;
int nitems;
unsigned int port;
@@ -97,6 +105,7 @@ Z_Subscriptions(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(&notice, header, sizeof(header), &hdrlen, ZAUTH);
diff --git a/lib/zephyr_err.et b/lib/zephyr_err.et
index 8fae4b3..3f24aec 100644
--- a/lib/zephyr_err.et
+++ b/lib/zephyr_err.et
@@ -53,5 +53,13 @@ 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