Changeset e778351


Ignore:
Timestamp:
Mar 25, 2011, 10:58:23 PM (13 years ago)
Author:
Jason Gross <jgross@mit.edu>
Parents:
f27b044
Message:
Ability to set exposure arbitrarily (like "zctl set exposure")

A zephyr variable 'exposure' has been added.  It defaults to the value
in ~/.zephyr.vars, if there is one, or to realm-visible.  Setting this
variable does not affect the value in ~/.zephyr.vars.

Additionally, OWLVAR_STRING_FULL has been modified to allow custom
setting of validset.

This fixes ticket # 65.
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • variable.c

    rf27b044 re778351  
    3030        NULL, NULL, NULL, NULL, NULL, NULL }
    3131
    32 #define OWLVAR_STRING_FULL(name,default,summary,description,validate,set,get) \
    33         { name, OWL_VARIABLE_STRING, default, 0, "<string>", summary,description, NULL, \
     32#define OWLVAR_STRING_FULL(name,default,validset,summary,description,validate,set,get) \
     33        { name, OWL_VARIABLE_STRING, default, 0, validset, summary,description, NULL, \
    3434        validate, set, NULL, get, NULL, NULL }
    3535
     
    266266                 "" ),
    267267
    268   OWLVAR_STRING_FULL( "tty" /* %OwlVarStub */, "", "tty name for zephyr location", "",
     268  OWLVAR_STRING_FULL( "tty" /* %OwlVarStub */, "", "<string>", "tty name for zephyr location", "",
    269269                      NULL, owl_variable_tty_set, NULL),
    270270
     
    370370               "delete a message right as it came in.\n" ),
    371371
     372  OWLVAR_STRING_FULL( "exposure" /* %OwlVarStub */, "",
     373                      "none,opstaff,realm-visible,realm-announced,net-visible,net-announced",
     374                      "controls who can zlocate you",
     375                      "The exposure-level defaults realm-visible, unless configured otherwise\n"
     376                      "in ~/.zephyr.vars, and can be one of the following\n"
     377                      "(listed from least exposure to widest exposure, as listed in zctl(1)):\n"
     378                      "   none            - This completely disables Zephyr for the user. \n"
     379                      "                     The user is not registered with Zephyr.  No user\n"
     380                      "                     location information is retained by Zephyr.  No\n"
     381                      "                     login or logout announcements will be sent.  No\n"
     382                      "                     subscriptions will be entered for the user, and\n"
     383                      "                     no notices will be displayed by zwgc(1).\n"
     384                      "   opstaff         - The user is registered with Zephyr.  No login or\n"
     385                      "                     logout announcements will be sent, and location\n"
     386                      "                     information will only be visible to Operations\n"
     387                      "                     staff.  Default subscriptions and any additional\n"
     388                      "                     personal subscriptions will be entered for the\n"
     389                      "                     user.\n"
     390                      "   realm-visible   - The user is registered with Zephyr.  User\n"
     391                      "                     location information is retained by Zephyr and\n"
     392                      "                     made available only to users within the user’s\n"
     393                      "                     Kerberos realm.  No login or logout\n"
     394                      "                     announcements will be sent.  This is the system\n"
     395                      "                     default.  Default subscriptions and any\n"
     396                      "                     additional personal subscriptions will be\n"
     397                      "                     entered for the user.\n"
     398                      "   realm-announced - The user is registered with Zephyr.  User\n"
     399                      "                     location information is retained by Zephyr and\n"
     400                      "                     made available only to users authenticated\n"
     401                      "                     within the user’s Kerberos realm.  Login and\n"
     402                      "                     logout announcements will be sent, but only to\n"
     403                      "                     users within the user’s Kerberos realm who have\n"
     404                      "                     explicitly requested such via subscriptions. \n"
     405                      "                     Default subscriptions and any additional\n"
     406                      "                     personal subscriptions will be entered for the\n"
     407                      "                     user.\n"
     408                      "   net-visible     - The user is registered with Zephyr.  User\n"
     409                      "                     location information is retained by Zephyr and\n"
     410                      "                     made available to any authenticated user who\n"
     411                      "                     requests such.  Login and logout announcements\n"
     412                      "                     will be sent only to users within the user’s\n"
     413                      "                     Kerberos realm who have explicitly requested\n"
     414                      "                     such via subscriptions.  Default subscriptions\n"
     415                      "                     and any additional personal subscriptions will\n"
     416                      "                     be entered for the user.\n"
     417                      "   net-announced   - The user is registered with Zephyr.  User\n"
     418                      "                     location information is retained by Zephyr and\n"
     419                      "                     made available to any authenticated user who\n"
     420                      "                     requests such.  Login and logout announcements\n"
     421                      "                     will be sent to any user has requested such. \n"
     422                      "                     Default subscriptions and any additional\n"
     423                      "                     personal subscriptions will be entered for the\n"
     424                      "                     user.\n",
     425                      NULL, owl_variable_exposure_set, owl_variable_exposure_get ),
     426
    372427  /* This MUST be last... */
    373428  { NULL, 0, NULL, 0, NULL, NULL, NULL, NULL,
     
    470525}
    471526
     527int owl_variable_exposure_set(owl_variable *v, const void *newval)
     528{
     529  return owl_zephyr_set_exposure(newval);
     530}
     531
     532const void *owl_variable_exposure_get(const owl_variable *v)
     533{
     534  return owl_zephyr_get_exposure();
     535}
    472536
    473537/**************************************************************************/
  • zephyr.c

    rfe3b017 re778351  
    10191019{
    10201020#ifdef HAVE_LIBZEPHYR
    1021   char *exposure, *eset;
    10221021  Code_t ret;
    10231022
    10241023  ZResetAuthentication();
    10251024
    1026   eset = EXPOSE_REALMVIS;
    1027   exposure = ZGetVariable(zstr("exposure"));
    1028   if (exposure)
    1029     exposure = ZParseExposureLevel(exposure);
    1030   if (exposure)
    1031     eset = exposure;
    1032    
    1033   ret = ZSetLocation(eset);
     1025  ret = ZSetLocation(zstr(owl_global_get_exposure(&g)));
     1026
    10341027  if (ret != ZERR_NONE)
    10351028    owl_function_error("Error setting location: %s", error_message(ret));
     
    11531146#ifdef HAVE_LIBZEPHYR
    11541147  ZInitLocationInfo(zstr(host), zstr(val));
     1148#endif
     1149}
     1150
     1151int owl_zephyr_set_exposure(const char *exposure)
     1152{
     1153#ifdef HAVE_LIBZEPHYR
     1154  Code_t ret;
     1155  if (exposure == NULL)
     1156    return -1;
     1157  exposure = ZParseExposureLevel(zstr(exposure));
     1158  if (exposure == NULL)
     1159    return -1;
     1160  ret = ZSetLocation(zstr(exposure));
     1161  if (ret != ZERR_NONE) {
     1162    owl_function_debugmsg("Unable to set exposure location to %s (%s)", exposure, error_message(ret));
     1163    return -1; /* I don't like this.  We should return -1, because we failed,
     1164                * but the user gets a message that implies that the value they
     1165                * gave is wrong.
     1166                */
     1167  }
     1168  ret = ZSetVariable(zstr("exposure"), zstr(exposure));
     1169  if (ret != ZERR_NONE) {
     1170    owl_function_debugmsg("Unable to set exposure variable to %s (%s)", exposure, error_message(ret));
     1171    return -1; /* ditto the above comment */
     1172  }
     1173#endif
     1174  return 0;
     1175}
     1176
     1177const char *owl_zephyr_get_exposure(void)
     1178{
     1179#ifdef HAVE_LIBZEPHYR
     1180  const char *exposure = ZParseExposureLevel(ZGetVariable(zstr("exposure")));
     1181  if (exposure == NULL)
     1182    exposure = EXPOSE_REALMVIS;
     1183  return exposure;
     1184#else
     1185  return "";
    11551186#endif
    11561187}
Note: See TracChangeset for help on using the changeset viewer.