[2805] in BarnOwl Developers
[PATCH] Ability to set exposure arbitrarily (like "zctl set exposure")
daemon@ATHENA.MIT.EDU (Jason Gross)
Mon Nov 22 21:43:45 2010
From: Jason Gross <jgross@MIT.EDU>
To: barnowl-dev@mit.edu
Date: Mon, 22 Nov 2010 21:43:41 -0500
A zephyr variable 'exposure' has been added. It defaults to the value
in .zephyr.vars, if there is one, or to realm-visible. When the value
is set with :set exposure ..., this value is written to .zephyr.vars.
Additionally, OWLVAR_STRING_FULL has been modified to allow custom
setting of validset.
The description of the exposure variable is copied almost verbatim from
man zctl. We might want to cite this, or reword it?
---
variable.c | 83 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++--
zephyr.c | 24 ++---------------
2 files changed, 83 insertions(+), 24 deletions(-)
diff --git a/variable.c b/variable.c
index 8d80630..b070bc9 100644
--- a/variable.c
+++ b/variable.c
@@ -29,8 +29,8 @@
{ name, OWL_VARIABLE_STRING, default, 0, "<string>", summary,description, NULL, \
NULL, NULL, NULL, NULL, NULL, NULL }
-#define OWLVAR_STRING_FULL(name,default,summary,description,validate,set,get) \
- { name, OWL_VARIABLE_STRING, default, 0, "<string>", summary,description, NULL, \
+#define OWLVAR_STRING_FULL(name,default,validset,summary,description,validate,set,get) \
+ { name, OWL_VARIABLE_STRING, default, 0, validset, summary,description, NULL, \
validate, set, NULL, get, NULL, NULL }
/* enums are really integers, but where validset is a comma-separated
@@ -265,7 +265,7 @@ static owl_variable variables_to_init[] = {
"owl command to execute for alert actions",
"" ),
- OWLVAR_STRING_FULL( "tty" /* %OwlVarStub */, "", "tty name for zephyr location", "",
+ OWLVAR_STRING_FULL( "tty" /* %OwlVarStub */, "", "<string>", "tty name for zephyr location", "",
NULL, owl_variable_tty_set, NULL),
OWLVAR_STRING( "default_style" /* %OwlVarStub */, "default",
@@ -369,6 +369,64 @@ static owl_variable variables_to_init[] = {
"Note that this is currently risky as you might accidentally\n"
"delete a message right as it came in.\n" ),
+ OWLVAR_STRING_FULL( "exposure" /* %OwlVarStub */, "REALM-VISIBLE ", /* we don't actually want to set this as the default;
+ * the extra space allows us to just display it. */
+ "none,net-announced,realm-visible,realm-announced,opstaff,net-visible",
+ "controls who can zlocate you",
+ /* Copied almost verbatim from man zctl.
+ * XXX TODO: Cite or reword?
+ */
+ "The exposure-level can be one of the following \n"
+ "(listed from least exposure to widest exposure):\n"
+ " none - This completely disables Zephyr for the user. \n"
+ " The user is not registered with Zephyr. No user\n"
+ " location information is retained by Zephyr. No\n"
+ " login or logout announcements will be sent. No\n"
+ " subscriptions will be entered for the user, and\n"
+ " no notices will be displayed by zwgc(1).\n"
+ " net-announced - The user is registered with Zephyr. User\n"
+ " location information is retained by Zephyr and\n"
+ " made available to any authenticated user who\n"
+ " requests such. Login and logout announcements\n"
+ " will be sent to any user has requested such. \n"
+ " Default subscriptions and any additional\n"
+ " personal subscriptions will be entered for the\n"
+ " user.\n"
+ " realm-visible - The user is registered with Zephyr. User\n"
+ " location information is retained by Zephyr and\n"
+ " made available only to users within the user’s\n"
+ " Kerberos realm. No login or logout\n"
+ " announcements will be sent. This is the system\n"
+ " default. Default subscriptions and any\n"
+ " additional personal subscriptions will be\n"
+ " entered for the user.\n"
+ " realm-announced - The user is registered with Zephyr. User\n"
+ " location information is retained by Zephyr and\n"
+ " made available only to users authenticated\n"
+ " within the user’s Kerberos realm. Login and\n"
+ " logout announcements will be sent, but only to\n"
+ " users within the user’s Kerberos realm who have\n"
+ " explicitly requested such via subscriptions. \n"
+ " Default subscriptions and any additional\n"
+ " personal subscriptions will be entered for the\n"
+ " user.\n"
+ " opstaff - The user is registered with Zephyr. No login or\n"
+ " logout announcements will be sent, and location\n"
+ " information will only be visible to Operations\n"
+ " staff. Default subscriptions and any additional\n"
+ " personal subscriptions will be entered for the\n"
+ " user.\n"
+ " net-visible - The user is registered with Zephyr. User\n"
+ " location information is retained by Zephyr and\n"
+ " made available to any authenticated user who\n"
+ " requests such. Login and logout announcements\n"
+ " will be sent only to users within the user’s\n"
+ " Kerberos realm who have explicitly requested\n"
+ " such via subscriptions. Default subscriptions\n"
+ " and any additional personal subscriptions will\n"
+ " be entered for the user.\n",
+ NULL, owl_variable_exposure_set, owl_variable_exposure_get ),
+
/* This MUST be last... */
{ NULL, 0, NULL, 0, NULL, NULL, NULL, NULL,
NULL, NULL, NULL, NULL, NULL, NULL }
@@ -469,6 +527,25 @@ int owl_variable_tty_set(owl_variable *v, const void *newval)
return(owl_variable_string_set_default(v, newval));
}
+int owl_variable_exposure_set(owl_variable *v, const void *newval)
+{
+ const char *exposure = newval;
+ if (exposure == NULL)
+ return -1;
+ exposure = ZParseExposureLevel(zstr(exposure));
+ if (exposure == NULL)
+ return -1;
+ return ZSetLocation(zstr(exposure)) |
+ ZSetVariable(zstr("exposure"), zstr(exposure));
+}
+
+const void *owl_variable_exposure_get(const owl_variable *v)
+{
+ const char *exposure = ZParseExposureLevel(ZGetVariable(zstr("exposure")));
+ if (exposure == NULL)
+ exposure = EXPOSE_REALMVIS;
+ return exposure;
+}
/**************************************************************************/
/****************************** GENERAL ***********************************/
diff --git a/zephyr.c b/zephyr.c
index eb39065..3945dc4 100644
--- a/zephyr.c
+++ b/zephyr.c
@@ -1029,30 +1029,12 @@ char *owl_zephyr_makesubline(const char *class, const char *inst, const char *re
void owl_zephyr_zlog_in(void)
{
#ifdef HAVE_LIBZEPHYR
- const char *exposure, *eset;
int ret;
ZResetAuthentication();
-
- eset=EXPOSE_REALMVIS;
- exposure=ZGetVariable(zstr("exposure"));
- if (exposure==NULL) {
- eset=EXPOSE_REALMVIS;
- } else if (!strcasecmp(exposure,EXPOSE_NONE)) {
- eset = EXPOSE_NONE;
- } else if (!strcasecmp(exposure,EXPOSE_OPSTAFF)) {
- eset = EXPOSE_OPSTAFF;
- } else if (!strcasecmp(exposure,EXPOSE_REALMVIS)) {
- eset = EXPOSE_REALMVIS;
- } else if (!strcasecmp(exposure,EXPOSE_REALMANN)) {
- eset = EXPOSE_REALMANN;
- } else if (!strcasecmp(exposure,EXPOSE_NETVIS)) {
- eset = EXPOSE_NETVIS;
- } else if (!strcasecmp(exposure,EXPOSE_NETANN)) {
- eset = EXPOSE_NETANN;
- }
-
- ret=ZSetLocation(zstr(eset));
+
+ ret = ZSetLocation(ZParseExposureLevel(zstr(owl_global_get_exposure(&g))));
+
if (ret != ZERR_NONE) {
/*
owl_function_makemsg("Error setting location: %s", error_message(ret));
--
1.7.1