summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Jeffrey Hutzelman <jhutz@cmu.edu>2013-02-22 21:17:44 -0500
committerGravatar Karl Ramm <kcr@1ts.org>2013-02-26 23:01:10 -0500
commit18e990a4f37a750ff71a2c5c9206afcd95df6208 (patch)
tree5f3ceffa9c90bbce6c6a4635de487302ae3d32e1
parent58a713e13c61dd4ce0b7f9f81685879353c0b911 (diff)
Allow zctl flush_locs to take a user argument
Provide a new library function, ZFlushUserLocations(), to flush locations for a specified user. This can be called using zctl flush_locs, which now takes an optional username parameter. This is the client side of #102
-rw-r--r--clients/zctl/zctl.1.in8
-rw-r--r--clients/zctl/zctl.c11
-rw-r--r--h/internal.h2
-rw-r--r--h/zephyr/zephyr.h1
-rw-r--r--lib/ZLocations.c18
5 files changed, 28 insertions, 12 deletions
diff --git a/clients/zctl/zctl.1.in b/clients/zctl/zctl.1.in
index d3835d3..ec9dbf0 100644
--- a/clients/zctl/zctl.1.in
+++ b/clients/zctl/zctl.1.in
@@ -66,10 +66,12 @@ from the subscriptions file as an un-subscription.
Set default subscriptions file to \fIfile\fR. If \fIfile\fR isn't specified,
show what the current subscriptions file is.
.TP
-.B flush_locs
+.B flush_locs \fR[ \fIuser\fR ]
Tell the Zephyr servers to flush all location information associated with
-the user. This should only be used to remove any incorrect data that may have
-been left after a system crash.
+\fIuser\fR, or with the user running the command if none is given. This
+should only be used to remove any incorrect data that may have been left
+after a system crash. Note that only Operations staff may flush location
+information associated with another user.
.TP
.B hide
Hide your location as maintained by the Zephyr server. This does not
diff --git a/clients/zctl/zctl.c b/clients/zctl/zctl.c
index 706f3cd..1dfa792 100644
--- a/clients/zctl/zctl.c
+++ b/clients/zctl/zctl.c
@@ -217,12 +217,17 @@ flush_locations(int argc,
{
int retval;
- if (argc > 1) {
- fprintf(stderr,"Usage: %s\n",argv[0]);
+ if (argc > 2) {
+ fprintf(stderr,"Usage: %s [user]\n",argv[0]);
return;
}
- if ((retval = ZFlushMyLocations()) != ZERR_NONE)
+ if (argc > 1)
+ retval = ZFlushUserLocations(argv[1]);
+ else
+ retval = ZFlushMyLocations();
+
+ if (retval != ZERR_NONE)
com_err(whoami, retval, "while flushing locations");
}
diff --git a/h/internal.h b/h/internal.h
index 8aa7ffd..0753e67 100644
--- a/h/internal.h
+++ b/h/internal.h
@@ -117,7 +117,7 @@ Code_t Z_FormatRawHeader (ZNotice_t *, char*, int,
Code_t Z_ReadEnqueue (void);
Code_t Z_ReadWait (void);
int Z_PacketWaiting (void);
-Code_t Z_SendLocation (char*, char*, Z_AuthProc, char*);
+Code_t Z_SendLocation (char*, char*, char*, Z_AuthProc, char*);
Code_t Z_SendFragmentedNotice (ZNotice_t *notice, int len,
Z_AuthProc cert_func,
Z_SendProc send_func);
diff --git a/h/zephyr/zephyr.h b/h/zephyr/zephyr.h
index a7eb17f..faa8140 100644
--- a/h/zephyr/zephyr.h
+++ b/h/zephyr/zephyr.h
@@ -209,6 +209,7 @@ Code_t ZInitLocationInfo(char *hostname, char *tty);
Code_t ZSetLocation(char *exposure);
Code_t ZUnsetLocation(void);
Code_t ZFlushMyLocations(void);
+Code_t ZFlushUserLocations(char *);
char *ZParseExposureLevel(char *text);
Code_t ZFormatRawNotice(ZNotice_t *, char**, int *);
Code_t ZRetrieveSubscriptions(unsigned short, int*);
diff --git a/lib/ZLocations.c b/lib/ZLocations.c
index 95e180a..e7537da 100644
--- a/lib/ZLocations.c
+++ b/lib/ZLocations.c
@@ -61,21 +61,28 @@ ZInitLocationInfo(char *hostname,
Code_t
ZSetLocation(char *exposure)
{
- return (Z_SendLocation(LOGIN_CLASS, exposure, ZAUTH,
+ return (Z_SendLocation(LOGIN_CLASS, exposure, ZGetSender(), ZAUTH,
"$sender logged in to $1 on $3 at $2"));
}
Code_t
ZUnsetLocation(void)
{
- return (Z_SendLocation(LOGIN_CLASS, LOGIN_USER_LOGOUT, ZNOAUTH,
- "$sender logged out of $1 on $3 at $2"));
+ return (Z_SendLocation(LOGIN_CLASS, LOGIN_USER_LOGOUT, ZGetSender(),
+ ZNOAUTH, "$sender logged out of $1 on $3 at $2"));
}
Code_t
ZFlushMyLocations(void)
{
- return (Z_SendLocation(LOGIN_CLASS, LOGIN_USER_FLUSH, ZAUTH, ""));
+ return (Z_SendLocation(LOGIN_CLASS, LOGIN_USER_FLUSH, ZGetSender(),
+ ZAUTH, ""));
+}
+
+Code_t
+ZFlushUserLocations(char *target)
+{
+ return (Z_SendLocation(LOGIN_CLASS, LOGIN_USER_FLUSH, target, ZAUTH, ""));
}
char *
@@ -108,6 +115,7 @@ wait_for_srvack(ZNotice_t *notice, void *uid)
Code_t
Z_SendLocation(char *class,
char *opcode,
+ char *target,
Z_AuthProc auth,
char *format)
{
@@ -124,7 +132,7 @@ Z_SendLocation(char *class,
notice.z_kind = ACKED;
notice.z_port = (u_short) ((wg_port == -1) ? 0 : wg_port);
notice.z_class = class;
- notice.z_class_inst = ZGetSender();
+ notice.z_class_inst = target;
notice.z_opcode = opcode;
notice.z_sender = 0;
notice.z_recipient = "";