Exemplo n.º 1
0
void shadow_init(void)
{
  int i;
  SET *set;
  /* set up search bases */
  if (shadow_bases[0] == NULL)
    for (i = 0; i < NSS_LDAP_CONFIG_MAX_BASES; i++)
      shadow_bases[i] = nslcd_cfg->bases[i];
  /* set up scope */
  if (shadow_scope == LDAP_SCOPE_DEFAULT)
    shadow_scope = nslcd_cfg->scope;
  /* set up attribute list */
  set = set_new();
  attmap_add_attributes(set, attmap_shadow_uid);
  attmap_add_attributes(set, attmap_shadow_userPassword);
  attmap_add_attributes(set, attmap_shadow_shadowLastChange);
  attmap_add_attributes(set, attmap_shadow_shadowMax);
  attmap_add_attributes(set, attmap_shadow_shadowMin);
  attmap_add_attributes(set, attmap_shadow_shadowWarning);
  attmap_add_attributes(set, attmap_shadow_shadowInactive);
  attmap_add_attributes(set, attmap_shadow_shadowExpire);
  attmap_add_attributes(set, attmap_shadow_shadowFlag);
  shadow_attrs = set_tolist(set);
  if (shadow_attrs == NULL)
  {
    log_log(LOG_CRIT, "malloc() failed to allocate memory");
    exit(EXIT_FAILURE);
  }
  set_free(set);
}
Exemplo n.º 2
0
/* the main program... */
int main(int UNUSED(argc),char UNUSED(*argv[]))
{
  SET *set;
  const char **list;
  int i;

  /* initialize */
  set=set_new();

  /* store some entries */
  set_add(set,"key1");
  set_add(set,"key2");
  set_add(set,"key3");
  set_add(set,"key2");

  /* check set contents */
  assert(set_contains(set,"key1"));
  assert(set_contains(set,"key2"));
  assert(set_contains(set,"key3"));
  assert(!set_contains(set,"key4"));
  assert(!set_contains(set,"KEY1"));

  /* loop over set contents */
  list=set_tolist(set);
  for (i=0;list[i]!=NULL;i++)
  {
    assert(isknownvalue(list[i]));
  }

  /* remove keys from the set */
  assert(isknownvalue(set_pop(set)));
  assert(isknownvalue(set_pop(set)));
  assert(isknownvalue(set_pop(set)));
  assert(set_pop(set)==NULL);

  /* free set */
  set_free(set);
  free(list);

  return 0;
}