Changeset f203cad


Ignore:
Timestamp:
Mar 27, 2011, 12:11:26 AM (10 years ago)
Author:
Anders Kaseorg <andersk@mit.edu>
Branches:
master, release-1.8, release-1.9
Children:
6a71113
Parents:
779bd3d
git-author:
Jason Gross <jgross@mit.edu> (03/26/11 04:56:41)
git-committer:
Anders Kaseorg <andersk@mit.edu> (03/27/11 00:11:26)
Message:
Ability to set exposure arbitrarily (like "zctl set exposure")

Zephyr variables 'exposure' and 'default_exposure' have been added.  The
'exposure' variable defaults to the value of 'default_exposure', which
defaults to the value in ~/.zephyr.vars, if there is one, or to
realm-visible.  When the value of default_exposure is set with :set
default_exposure ..., this value is written to ~/.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

    r779bd3d rf203cad  
    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( "default_exposure" /* %OwlVarStub */, "",
     373                      "none,opstaff,realm-visible,realm-announced,net-visible,net-announced",
     374                      "controls the persistent value for exposure",
     375                      "The default exposure level corresponds to the Zephyr exposure value\n"
     376                      "in ~/.zephyr.vars.  Defaults to realm-visible if there is no value in\n"
     377                      "~/.zephyr.vars.\n"
     378                      "See the description of exposure for the values this can be.",
     379                      NULL, owl_variable_default_exposure_set, owl_variable_default_exposure_get ),
     380
     381  OWLVAR_STRING_FULL( "exposure" /* %OwlVarStub */, "",
     382                      "none,opstaff,realm-visible,realm-announced,net-visible,net-announced",
     383                      "controls who can zlocate you",
     384                      "The exposure level, defaulting to the value of default_exposure,\n"
     385                      "can be one of the following (from least exposure to widest exposure,\n"
     386                      "as listed in zctl(1)):\n"
     387                      "\n"
     388                      "   none            - This completely disables Zephyr for the user. \n"
     389                      "                     The user is not registered with Zephyr.  No user\n"
     390                      "                     location information is retained by Zephyr.  No\n"
     391                      "                     login or logout announcements will be sent.  No\n"
     392                      "                     subscriptions will be entered for the user, and\n"
     393                      "                     no notices will be displayed by zwgc(1).\n"
     394                      "   opstaff         - The user is registered with Zephyr.  No login or\n"
     395                      "                     logout announcements will be sent, and location\n"
     396                      "                     information will only be visible to Operations\n"
     397                      "                     staff.  Default subscriptions and any additional\n"
     398                      "                     personal subscriptions will be entered for the\n"
     399                      "                     user.\n"
     400                      "   realm-visible   - The user is registered with Zephyr.  User\n"
     401                      "                     location information is retained by Zephyr and\n"
     402                      "                     made available only to users within the user’s\n"
     403                      "                     Kerberos realm.  No login or logout\n"
     404                      "                     announcements will be sent.  This is the system\n"
     405                      "                     default.  Default subscriptions and any\n"
     406                      "                     additional personal subscriptions will be\n"
     407                      "                     entered for the user.\n"
     408                      "   realm-announced - The user is registered with Zephyr.  User\n"
     409                      "                     location information is retained by Zephyr and\n"
     410                      "                     made available only to users authenticated\n"
     411                      "                     within the user’s Kerberos realm.  Login and\n"
     412                      "                     logout announcements will be sent, but only to\n"
     413                      "                     users within the user’s Kerberos realm who have\n"
     414                      "                     explicitly requested such via subscriptions. \n"
     415                      "                     Default subscriptions and any additional\n"
     416                      "                     personal subscriptions will be entered for the\n"
     417                      "                     user.\n"
     418                      "   net-visible     - The user is registered with Zephyr.  User\n"
     419                      "                     location information is retained by Zephyr and\n"
     420                      "                     made available to any authenticated user who\n"
     421                      "                     requests such.  Login and logout announcements\n"
     422                      "                     will be sent only to users within the user’s\n"
     423                      "                     Kerberos realm who have explicitly requested\n"
     424                      "                     such via subscriptions.  Default subscriptions\n"
     425                      "                     and any additional personal subscriptions will\n"
     426                      "                     be entered for the user.\n"
     427                      "   net-announced   - The user is registered with Zephyr.  User\n"
     428                      "                     location information is retained by Zephyr and\n"
     429                      "                     made available to any authenticated user who\n"
     430                      "                     requests such.  Login and logout announcements\n"
     431                      "                     will be sent to any user has requested such. \n"
     432                      "                     Default subscriptions and any additional\n"
     433                      "                     personal subscriptions will be entered for the\n"
     434                      "                     user.\n",
     435                      NULL, owl_variable_exposure_set, NULL /* use default for get */ ),
     436
    372437  /* This MUST be last... */
    373438  { NULL, 0, NULL, 0, NULL, NULL, NULL, NULL,
     
    470535}
    471536
     537int owl_variable_default_exposure_set(owl_variable *v, const void *newval)
     538{
     539  return owl_zephyr_set_default_exposure(newval);
     540}
     541
     542const void *owl_variable_default_exposure_get(const owl_variable *v)
     543{
     544  return owl_zephyr_get_default_exposure();
     545}
     546
     547int owl_variable_exposure_set(owl_variable *v, const void *newval)
     548{
     549  int ret = owl_zephyr_set_exposure(newval);
     550  if (ret != 0)
     551    return ret;
     552  return owl_variable_string_set_default(v, owl_zephyr_normalize_exposure(newval));
     553}
    472554
    473555/**************************************************************************/
  • zephyr.c

    rfe3b017 rf203cad  
    10191019{
    10201020#ifdef HAVE_LIBZEPHYR
    1021   char *exposure, *eset;
    1022   Code_t ret;
    1023 
    10241021  ZResetAuthentication();
    10251022
    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);
    1034   if (ret != ZERR_NONE)
    1035     owl_function_error("Error setting location: %s", error_message(ret));
     1023  /* ZSetLocation, and store the default value as the current value */
     1024  owl_global_set_exposure(&g, owl_global_get_default_exposure(&g));
    10361025#endif
    10371026}
     
    11541143  ZInitLocationInfo(zstr(host), zstr(val));
    11551144#endif
     1145}
     1146
     1147const char *owl_zephyr_normalize_exposure(const char *exposure)
     1148{
     1149  if (exposure == NULL)
     1150    return NULL;
     1151#ifdef HAVE_LIBZEPHYR
     1152  return ZParseExposureLevel(zstr(exposure));
     1153#else
     1154  return exposure;
     1155#endif
     1156}
     1157
     1158int owl_zephyr_set_default_exposure(const char *exposure)
     1159{
     1160#ifdef HAVE_LIBZEPHYR
     1161  Code_t ret;
     1162  if (exposure == NULL)
     1163    return -1;
     1164  exposure = ZParseExposureLevel(zstr(exposure));
     1165  if (exposure == NULL)
     1166    return -1;
     1167  ret = ZSetVariable(zstr("exposure"), zstr(exposure)); /* ZSetVariable does file I/O */
     1168  if (ret != ZERR_NONE) {
     1169    owl_function_error("Unable to set default exposure location: %s", error_message(ret));
     1170    return -1;
     1171  }
     1172#endif
     1173  return 0;
     1174}
     1175
     1176const char *owl_zephyr_get_default_exposure(void)
     1177{
     1178#ifdef HAVE_LIBZEPHYR
     1179  const char *exposure = ZGetVariable(zstr("exposure")); /* ZGetVariable does file I/O */
     1180  if (exposure == NULL)
     1181    return EXPOSE_REALMVIS;
     1182  exposure = ZParseExposureLevel(zstr(exposure));
     1183  if (exposure == NULL) /* The user manually entered an invalid value in ~/.zephyr.vars, or something weird happened. */
     1184    return EXPOSE_REALMVIS;
     1185  return exposure;
     1186#else
     1187  return "";
     1188#endif
     1189}
     1190
     1191int owl_zephyr_set_exposure(const char *exposure)
     1192{
     1193#ifdef HAVE_LIBZEPHYR
     1194  Code_t ret;
     1195  if (exposure == NULL)
     1196    return -1;
     1197  exposure = ZParseExposureLevel(zstr(exposure));
     1198  if (exposure == NULL)
     1199    return -1;
     1200  ret = ZSetLocation(zstr(exposure));
     1201  if (ret != ZERR_NONE) {
     1202    owl_function_error("Unable to set exposure level: %s.", error_message(ret));
     1203    return -1;
     1204  }
     1205#endif
     1206  return 0;
    11561207}
    11571208 
Note: See TracChangeset for help on using the changeset viewer.