From 5c362db8305068a22e5e00915c7e2139d3a3f904 Mon Sep 17 00:00:00 2001 From: Derrick Brashear Date: Fri, 29 Jun 2001 14:23:01 -0400 Subject: znol: watch foreign users in their own realm If we want to receive login/logout notices for a user in another realm, we need to subscribe to them in that realm. Extracted from Andrew zephyr/058, which reverts a change to client-side interrealm support that was inadvertently introduced when importing new code from Athena. --- clients/znol/znol.c | 37 +++++++++++++++++++++++++++++++++---- 1 file changed, 33 insertions(+), 4 deletions(-) (limited to 'clients') diff --git a/clients/znol/znol.c b/clients/znol/znol.c index 009e5f7..4d03914 100644 --- a/clients/znol/znol.c +++ b/clients/znol/znol.c @@ -27,6 +27,7 @@ int main(int argc, char *argv[]) { register char *cp; + char *realm; ZSubscription_t subs[SUBSATONCE]; ZLocations_t locations; FILE *fp = NULL; @@ -156,12 +157,36 @@ main(int argc, char *argv[]) *cp++ = '@'; (void) strcpy(cp,ZGetRealm()); } - if ((subs[ind].zsub_classinst = malloc((unsigned)(strlen(name)+1))) == NULL) { + cp = strchr(name,'@'); + if (cp[0] && strcmp(cp+1,ZGetRealm())) { + realm = cp + 1; + *cp = '\0'; + if ((subs[ind].zsub_classinst = + malloc((unsigned)(strlen(name) + strlen(realm) + 2))) + == NULL) + { + fprintf (stderr, "znol: out of memory"); + exit (1); + } + (void) sprintf(subs[ind].zsub_classinst, "%s@%s", name, + realm); + (void) strcpy(name, subs[ind].zsub_classinst); + if ((subs[ind].zsub_recipient = + malloc((unsigned)(strlen(realm)+2))) == NULL) { + fprintf (stderr, "znol: out of memory"); + exit (1); + } + (void) sprintf(subs[ind++].zsub_recipient, "@%s", realm); + } else { + if ((subs[ind].zsub_classinst = + malloc((unsigned)(strlen(name)+1))) == NULL) + { fprintf (stderr, "znol: out of memory"); exit (1); + } + (void) strcpy(subs[ind].zsub_classinst, name); + subs[ind++].zsub_recipient = ""; } - (void) strcpy(subs[ind].zsub_classinst, name); - subs[ind++].zsub_recipient = ""; if (!quiet && onoff == ON) { if ((retval = ZLocateUser(name,&numlocs,ZAUTH)) @@ -204,7 +229,11 @@ main(int argc, char *argv[]) exit(1); } for (ind=0;ind