diff options
author | Derrick Brashear <shadow@dementix.org> | 2001-06-29 14:23:01 -0400 |
---|---|---|
committer | Jeffrey Hutzelman <jhutz@cmu.edu> | 2012-11-24 18:13:15 -0500 |
commit | 5c362db8305068a22e5e00915c7e2139d3a3f904 (patch) | |
tree | c10c33485cb583f7ed7c420fe7fba77ac4c29bd8 /clients | |
parent | 090cf270e57a2ded9787f62bf9f40e89bb929675 (diff) |
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.
Diffstat (limited to 'clients')
-rw-r--r-- | clients/znol/znol.c | 37 |
1 files changed, 33 insertions, 4 deletions
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<SUBSATONCE;ind++) - free(subs[ind].zsub_classinst); + { + if (subs[ind].zsub_recipient[0] != '\0') + free(subs[ind].zsub_recipient); + free(subs[ind].zsub_classinst); + } ind = 0; } } |