adding zephyr-im master branch
This commit is contained in:
56
clients/zlocate/Makefile.in
Normal file
56
clients/zlocate/Makefile.in
Normal file
@ -0,0 +1,56 @@
|
||||
SHELL=@SHELL@
|
||||
|
||||
prefix=@prefix@
|
||||
exec_prefix=@exec_prefix@
|
||||
datadir=@datadir@
|
||||
sysconfdir=@sysconfdir@
|
||||
sbindir=@sbindir@
|
||||
lsbindir=@lsbindir@
|
||||
datarootdir=@datarootdir@
|
||||
|
||||
includedir=@includedir@
|
||||
mandir=@mandir@
|
||||
libdir=@libdir@
|
||||
bindir=@bindir@
|
||||
top_builddir=../..
|
||||
|
||||
srcdir=@srcdir@
|
||||
top_srcdir=@top_srcdir@
|
||||
BUILDTOP=../..
|
||||
VPATH=@srcdir@
|
||||
LIBTOOL=@LIBTOOL@
|
||||
CC=@CC@
|
||||
INSTALL=@INSTALL@
|
||||
|
||||
LIBZEPHYR=${BUILDTOP}/lib/libzephyr.la
|
||||
CPPFLAGS=@CPPFLAGS@
|
||||
CFLAGS=@CFLAGS@
|
||||
ALL_CFLAGS=${CFLAGS} -I${top_srcdir}/h -I${BUILDTOP}/h ${CPPFLAGS}
|
||||
LDFLAGS=@LDFLAGS@
|
||||
LIBS=${LIBZEPHYR} @LIBS@ -lcom_err
|
||||
|
||||
OBJS= zlocate.o
|
||||
|
||||
all: zlocate
|
||||
|
||||
zlocate: ${OBJS} ${LIBZEPHYR}
|
||||
${LIBTOOL} --mode=link ${CC} ${LDFLAGS} -o $@ ${OBJS} ${LIBS}
|
||||
|
||||
.c.o:
|
||||
${CC} -c ${ALL_CFLAGS} $<
|
||||
|
||||
check:
|
||||
|
||||
install: zlocate
|
||||
${LIBTOOL} --mode=install ${INSTALL} -m 755 zlocate ${DESTDIR}${bindir}
|
||||
${INSTALL} -m 644 ${srcdir}/zlocate.1 ${DESTDIR}${mandir}/man1
|
||||
|
||||
clean:
|
||||
${LIBTOOL} --mode=clean rm -f zlocate
|
||||
rm -f ${OBJS}
|
||||
|
||||
${OBJS}: ${top_srcdir}/h/sysdep.h ${BUILDTOP}/h/config.h
|
||||
${OBJS}: ${BUILDTOP}/h/zephyr/zephyr.h ${BUILDTOP}/h/zephyr/zephyr_err.h
|
||||
|
||||
.PHONY: all check install clean
|
||||
|
76
clients/zlocate/zlocate.1
Normal file
76
clients/zlocate/zlocate.1
Normal file
@ -0,0 +1,76 @@
|
||||
.\" $Id$
|
||||
.\"
|
||||
.\" Copyright 1987,1988 by the Massachusetts Institute of Technology
|
||||
.\" All rights reserved. The file /usr/include/zephyr/mit-copyright.h
|
||||
.\" specifies the terms and conditions for redistribution.
|
||||
.\"
|
||||
.\"
|
||||
.TH ZLOCATE 1 "April 17, 1990" "MIT Project Athena"
|
||||
.ds ]W MIT Project Athena
|
||||
.SH NAME
|
||||
zlocate \- find a user using Zephyr
|
||||
.SH SYNOPSIS
|
||||
.B zlocate
|
||||
[
|
||||
.B -a
|
||||
|
|
||||
.B -d
|
||||
] [
|
||||
.B -1
|
||||
] [
|
||||
.B -p
|
||||
] user ...
|
||||
.SH DESCRIPTION
|
||||
.I Zlocate
|
||||
uses the
|
||||
.I Zephyr(1)
|
||||
Notification Service to find where a user is currently logged in. If
|
||||
the user is not logged in, or has set his location information such that
|
||||
you do not have access to see it,
|
||||
.I zlocate
|
||||
prints "Hidden or not logged-in". Otherwise, each machine that the
|
||||
user is currently logged into is printed, along with the time of
|
||||
login and location. The location is usually the X window system display
|
||||
name of the user's display, but may be the terminal name if he is not
|
||||
using X or for some other reason is only using the terminal interface to
|
||||
.I zwgc(1).
|
||||
|
||||
By default, all zlocate requests are authenticated using
|
||||
.IR Kerberos .
|
||||
If you do not have Kerberos tickets, or for some other reason do not
|
||||
want to authenticate, the
|
||||
.B -d
|
||||
option will turn off authentication. The
|
||||
.B -a
|
||||
option is the default, authentication on.
|
||||
|
||||
When locating multiple users,
|
||||
.I zlocate
|
||||
will display the user name on a line by itself, followed by the locations for that user. To display the user name on the same line as the output, use the
|
||||
.B -1
|
||||
option (the numeral one).
|
||||
|
||||
To look up multiple users in parallel asynchronously, use the
|
||||
.B -p
|
||||
option.
|
||||
|
||||
.SH DIAGNOSTICS
|
||||
.I zlocate
|
||||
exits with status zero (0) if at least one user was found, and one (1)
|
||||
if no users were found.
|
||||
.SH SEE ALSO
|
||||
zctl(1), zephyr(1), znol(1), zwgc(1), zhm(8), zephyrd(8), X(1)
|
||||
.br
|
||||
Project Athena Technical Plan Section E.4.1, `Zephyr Notification
|
||||
Service'
|
||||
.SH AUTHORS
|
||||
.PP
|
||||
Robert S. French (MIT-Project Athena)
|
||||
.br
|
||||
Marc Horowitz (MIT-Project Athena)
|
||||
.SH RESTRICTIONS
|
||||
Copyright (c) 1987,1988 by the Massachusetts Institute of Technology.
|
||||
All Rights Reserved.
|
||||
.br
|
||||
.I zephyr(1)
|
||||
specifies the terms and conditions for redistribution.
|
182
clients/zlocate/zlocate.c
Normal file
182
clients/zlocate/zlocate.c
Normal file
@ -0,0 +1,182 @@
|
||||
/* This file is part of the Project Athena Zephyr Notification System.
|
||||
* It contains code for the "zlocate" command.
|
||||
*
|
||||
* Created by: Robert French
|
||||
*
|
||||
* $Id$
|
||||
*
|
||||
* Copyright (c) 1987 by the Massachusetts Institute of Technology.
|
||||
* For copying and distribution information, see the file
|
||||
* "mit-copyright.h".
|
||||
*/
|
||||
|
||||
#include <sysdep.h>
|
||||
#include <zephyr/zephyr.h>
|
||||
#include <sys/socket.h>
|
||||
|
||||
#if !defined(lint) && !defined(SABER)
|
||||
static const char rcsid_zlocate_c[] = "$Id$";
|
||||
#endif
|
||||
|
||||
int numusers=0, numleft=0, parallel=0, oneline=0;
|
||||
char *whoami;
|
||||
|
||||
static RETSIGTYPE
|
||||
timeout(int sig)
|
||||
{
|
||||
fprintf (stderr, "%s: no response from server\n", whoami);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
static void
|
||||
usage(void)
|
||||
{
|
||||
printf("Usage: %s [ -a | -d ] [ -p ] [ -1 ] user ... \n",whoami);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
static void
|
||||
print_locs(char *user,
|
||||
int nlocs)
|
||||
{
|
||||
int one = 1, retval;
|
||||
ZLocations_t locations;
|
||||
|
||||
if ((!oneline) && (numusers>1))
|
||||
printf("\t%s:\n",user);
|
||||
|
||||
if ((!oneline) && (nlocs == 0))
|
||||
printf("Hidden or not logged-in\n");
|
||||
|
||||
for (;nlocs;nlocs--) {
|
||||
if ((retval = ZGetLocations(&locations,&one)) != ZERR_NONE) {
|
||||
com_err(whoami,retval,"while getting location");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (oneline) {
|
||||
printf("%s:\t%s\t%s\t%s\n",user,locations.host,locations.tty,
|
||||
locations.time);
|
||||
} else {
|
||||
printf("%-42s %-7s %s\n",locations.host, locations.tty, locations.time);
|
||||
}
|
||||
}
|
||||
|
||||
if ((!oneline) && (numusers > 1) && (numleft > 0))
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
/*ARGSUSED*/
|
||||
int
|
||||
main(int argc,
|
||||
char *argv[])
|
||||
{
|
||||
char user[BUFSIZ],*whichuser;
|
||||
ZAsyncLocateData_t ald;
|
||||
int retval,i,numlocs,numfound,loc,auth,rlen;
|
||||
ZNotice_t notice;
|
||||
#ifdef _POSIX_VERSION
|
||||
struct sigaction sa;
|
||||
#endif
|
||||
|
||||
whoami = argv[0];
|
||||
auth = -1;
|
||||
|
||||
argv++;
|
||||
argc--;
|
||||
|
||||
for (i=0; i < argc; i++)
|
||||
if (argv[i][0] == '-')
|
||||
switch (argv[i][1]) {
|
||||
case 'a':
|
||||
if (auth != -1) usage();
|
||||
auth = 1;
|
||||
break;
|
||||
case 'd':
|
||||
if (auth != -1) usage();
|
||||
auth = 0;
|
||||
break;
|
||||
case 'p':
|
||||
parallel = 1;
|
||||
break;
|
||||
case '1':
|
||||
oneline = 1;
|
||||
break;
|
||||
default:
|
||||
usage();
|
||||
break;
|
||||
}
|
||||
else
|
||||
numusers++;
|
||||
|
||||
if (numusers == 0)
|
||||
usage();
|
||||
|
||||
if (auth == -1) auth = 1;
|
||||
|
||||
if ((retval = ZInitialize()) != ZERR_NONE) {
|
||||
com_err(whoami,retval,"while initializing");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
numleft = numusers;
|
||||
numfound = 0;
|
||||
rlen = strlen(ZGetRealm());
|
||||
|
||||
i = 0;
|
||||
for (loc = 0; loc < argc; loc++) {
|
||||
if (argv[loc][0] == '-') continue;
|
||||
|
||||
(void) strncpy(user,argv[loc],sizeof(user) - rlen - 2);
|
||||
user[sizeof(user) - rlen - 2] = '\0';
|
||||
if (!strchr(user,'@')) {
|
||||
(void) strcat(user,"@");
|
||||
(void) strcat(user,ZGetRealm());
|
||||
}
|
||||
if (parallel) {
|
||||
if ((retval = ZRequestLocations(user, &ald, i ? UNSAFE : UNACKED,
|
||||
auth?ZAUTH:ZNOAUTH)) != ZERR_NONE) {
|
||||
com_err(whoami,retval,"requesting location of %s",user);
|
||||
exit(1);
|
||||
}
|
||||
i = 1;
|
||||
} else {
|
||||
if ((retval = ZLocateUser(user,&numlocs,auth?ZAUTH:ZNOAUTH)) != ZERR_NONE) {
|
||||
com_err(whoami,retval,"while locating user %s",user);
|
||||
exit(1);
|
||||
}
|
||||
print_locs(user,numlocs);
|
||||
numfound += numlocs;
|
||||
}
|
||||
}
|
||||
|
||||
if (parallel) {
|
||||
#ifdef _POSIX_VERSION
|
||||
sigemptyset(&sa.sa_mask);
|
||||
sa.sa_flags = 0;
|
||||
sa.sa_handler = timeout;
|
||||
sigaction(SIGALRM, &sa, (struct sigaction *)0);
|
||||
#else
|
||||
signal (SIGALRM, timeout);
|
||||
#endif
|
||||
while (numleft-- > 0) {
|
||||
alarm(SRV_TIMEOUT);
|
||||
if ((retval = ZReceiveNotice(¬ice, NULL)) != ZERR_NONE) {
|
||||
com_err(whoami,retval,"while searching notice queue");
|
||||
continue;
|
||||
}
|
||||
if ((retval = ZParseLocations(¬ice, (ZAsyncLocateData_t *)NULL,
|
||||
&numlocs, &whichuser)) != ZERR_NONE) {
|
||||
com_err(whoami,retval,"while parsing locations");
|
||||
continue;
|
||||
}
|
||||
if (numlocs >= 0) {
|
||||
print_locs(whichuser,numlocs);
|
||||
free(whichuser);
|
||||
numfound += numlocs;
|
||||
}
|
||||
ZFreeNotice(¬ice);
|
||||
}
|
||||
}
|
||||
return((numfound > 0) ? 0 : 1);
|
||||
}
|
Reference in New Issue
Block a user