[gq-commit] gq/src common.h,1.14,1.15 configfile.c,1.23,1.24 configfile.h,1.14,1.15 formfill.c,1.27,
Status: Beta
Brought to you by:
sur5r
Update of /cvsroot/gqclient/gq/src In directory usw-pr-cvs1:/tmp/cvs-serv2695 Modified Files: common.h configfile.c configfile.h formfill.c formfill.h gq.c input.c prefs.c tinput.c util.c Log Message: * Added two new configurations options regarding how gq deals with referrals + Show referrals This causes the LDAP connections to turn on the ManageDSAit option, thus retrieving LDAP referrals as normal objects. + Hide internal attributes In order to be able to show the "ref" attribute of referrals, we have to retrieve normally hidden attributes as well. When this option is set most such attributes will not be shown. Referral support currently is only there to be able to find out how to properly deal with referrals. This requires testing against many different LDAP servers to find out what is "right". Index: common.h =================================================================== RCS file: /cvsroot/gqclient/gq/src/common.h,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** common.h 13 Jun 2002 10:02:51 -0000 1.14 --- common.h 12 Jul 2002 20:27:52 -0000 1.15 *************** *** 81,84 **** --- 81,86 ---- long local_cache_timeout; int ask_pw; + int show_ref; + int hide_internal; LDAP *connection; Index: configfile.c =================================================================== RCS file: /cvsroot/gqclient/gq/src/configfile.c,v retrieving revision 1.23 retrieving revision 1.24 diff -C2 -d -r1.23 -r1.24 *** configfile.c 3 Jul 2002 18:49:45 -0000 1.23 --- configfile.c 12 Jul 2002 20:27:52 -0000 1.24 *************** *** 78,81 **** --- 78,83 ---- { "local-cache-timeout", T_LOCAL_CACHE_TIMEOUT, NEEDS_CLOSE|NEEDS_DATA }, { "ask-pw", T_ASK_PW, NEEDS_CLOSE|NEEDS_DATA }, + { "hide-internal", T_HIDE_INTERNAL, NEEDS_CLOSE|NEEDS_DATA }, + { "show-ref", T_SHOW_REF, NEEDS_CLOSE|NEEDS_DATA }, /* templates */ *************** *** 459,462 **** --- 461,470 ---- f->cur_ldapserver->ask_pw = config_get_bool(f); break; + case T_HIDE_INTERNAL: + f->cur_ldapserver->hide_internal = config_get_bool(f); + break; + case T_SHOW_REF: + f->cur_ldapserver->show_ref = config_get_bool(f); + break; } *************** *** 777,780 **** --- 785,792 ---- if(server->ask_pw != DEFAULT_ASK_PW) config_write_bool(wc, server->ask_pw, "ask-pw"); + if(server->hide_internal != DEFAULT_HIDE_INTERNAL) + config_write_bool(wc, server->hide_internal, "hide-internal"); + if(server->show_ref != DEFAULT_SHOW_REF) + config_write_bool(wc, server->show_ref, "show-ref"); wc->indent--; *************** *** 855,858 **** --- 867,872 ---- server->local_cache_timeout = DEFAULT_LOCAL_CACHE_TIMEOUT; server->ask_pw = DEFAULT_ASK_PW; + server->hide_internal = DEFAULT_HIDE_INTERNAL; + server->show_ref = DEFAULT_SHOW_REF; server->connection = NULL; server->missing_closes = 0; Index: configfile.h =================================================================== RCS file: /cvsroot/gqclient/gq/src/configfile.h,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** configfile.h 3 Jul 2002 18:49:45 -0000 1.14 --- configfile.h 12 Jul 2002 20:27:52 -0000 1.15 *************** *** 67,70 **** --- 67,72 ---- #define T_LOCAL_CACHE_TIMEOUT 33 #define T_ASK_PW 34 + #define T_HIDE_INTERNAL 35 + #define T_SHOW_REF 36 /* template tokens */ *************** *** 100,103 **** --- 102,107 ---- #define DEFAULT_LOCAL_CACHE_SIZE (512*1024) #define DEFAULT_ASK_PW 1 + #define DEFAULT_HIDE_INTERNAL 1 + #define DEFAULT_SHOW_REF 1 enum searchtype { Index: formfill.c =================================================================== RCS file: /cvsroot/gqclient/gq/src/formfill.c,v retrieving revision 1.27 retrieving revision 1.28 diff -C2 -d -r1.27 -r1.28 *** formfill.c 18 Jun 2002 22:07:14 -0000 1.27 --- formfill.c 12 Jul 2002 20:27:52 -0000 1.28 *************** *** 42,45 **** --- 42,56 ---- #include "i18n.h" + static GList *internalAttrs = NULL; + + void init_internalAttrs() { + internalAttrs = g_list_append(internalAttrs, "creatorsName"); + internalAttrs = g_list_append(internalAttrs, "creatorsName"); + internalAttrs = g_list_append(internalAttrs, "createTimestamp"); + internalAttrs = g_list_append(internalAttrs, "modifiersName"); + internalAttrs = g_list_append(internalAttrs, "modifyTimestamp"); + internalAttrs = g_list_append(internalAttrs, "subschemaSubentry"); + } + struct formfill *new_formfill(void) { *************** *** 149,152 **** --- 160,164 ---- struct berval **bervals; char *c = NULL; + char *attrs[] = { "+", "*", NULL }; formlist = NULL; *************** *** 167,171 **** msg = ldap_search_s(ld, dn, LDAP_SCOPE_BASE, "(objectclass=*)", ! NULL, 0, &res); if (msg == LDAP_SERVER_DOWN) { --- 179,183 ---- msg = ldap_search_s(ld, dn, LDAP_SCOPE_BASE, "(objectclass=*)", ! attrs, 0, &res); if (msg == LDAP_SERVER_DOWN) { *************** *** 186,194 **** for(attr = ldap_first_attribute(ld, entry, &ber); attr ; attr = ldap_next_attribute(ld, entry, ber)) { if( (form = new_formfill()) == NULL) { ldap_memfree(attr); break; } ! c = attr_strip(attr); strncpy(form->attrname, c, MAX_ATTR_LEN); if (c) g_free(c); --- 198,228 ---- for(attr = ldap_first_attribute(ld, entry, &ber); attr ; attr = ldap_next_attribute(ld, entry, ber)) { + + /* filter out some internal attributes... */ + GList *filterout = NULL; + gboolean filtered = FALSE; + + c = attr_strip(attr); + if (server->hide_internal) { + for (filterout = internalAttrs ; filterout ; + filterout = filterout->next) { + if (strcasecmp(c, filterout->data) == 0) { + filtered = TRUE; + break; + } + } + if (filtered) { + ldap_memfree(attr); + if (c) g_free(c); + continue; + } + } + if( (form = new_formfill()) == NULL) { ldap_memfree(attr); + if (c) g_free(c); break; } ! strncpy(form->attrname, c, MAX_ATTR_LEN); if (c) g_free(c); *************** *** 398,401 **** --- 432,444 ---- void set_displaytype(struct ldapserver *server, struct formfill *form) { + /* this is ugly... all of this needs a cleanup!!!! - FIXME */ + LDAPAttributeType *at = + find_canonical_at_by_at(server->ss, form->attrname); + + if (at && at->at_no_user_mod) { + printf("no user mod\n"); + form->flags |= FLAG_NO_USER_MOD; + } + form->syntax = get_syntax_handler_of_attr(server, form->attrname, NULL); form->displaytype = find_displaytype(server, form); Index: formfill.h =================================================================== RCS file: /cvsroot/gqclient/gq/src/formfill.h,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** formfill.h 9 Jul 2002 10:43:38 -0000 1.17 --- formfill.h 12 Jul 2002 20:27:52 -0000 1.18 *************** *** 63,66 **** --- 63,69 ---- #define FLAG_SINGLE_VALUE 0x08 + /* Used to disable widgets for attributes marked as no_user_mod */ + #define FLAG_NO_USER_MOD 0x80 + /* actually, we do not really need the following FLAG_* values, we only use them as tokens in dt_password.c right now */ *************** *** 92,95 **** --- 95,99 ---- }; + void init_internalAttrs(); struct formfill *new_formfill(void); Index: gq.c =================================================================== RCS file: /cvsroot/gqclient/gq/src/gq.c,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** gq.c 27 Jun 2002 08:15:47 -0000 1.11 --- gq.c 12 Jul 2002 20:27:52 -0000 1.12 *************** *** 87,90 **** --- 87,92 ---- create_mainwin(); init_syntaxes(); + init_internalAttrs(); + g_log_set_always_fatal (G_LOG_LEVEL_CRITICAL); Index: input.c =================================================================== RCS file: /cvsroot/gqclient/gq/src/input.c,v retrieving revision 1.39 retrieving revision 1.40 diff -C2 -d -r1.39 -r1.40 *** input.c 9 Jul 2002 10:41:52 -0000 1.39 --- input.c 12 Jul 2002 20:27:52 -0000 1.40 *************** *** 486,489 **** --- 486,493 ---- form->widgetList = g_list_append(form->widgetList, widget); + + if (form->flags & FLAG_NO_USER_MOD) { + gtk_widget_set_sensitive(widget, 0); + } } else { widget = widgetList ? widgetList->data : NULL; *************** *** 865,868 **** --- 869,873 ---- if(res != LDAP_SUCCESS) { error_push(add_context, ldap_err2string(res)); + push_ldap_addl_error(ld, add_context); error_flush(add_context); set_normalcursor(); *************** *** 1006,1009 **** --- 1011,1015 ---- } else { error_push(mod_context, ldap_err2string(res)); + push_ldap_addl_error(ld, mod_context); } ldap_mods_free(mods, 1); *************** *** 1097,1100 **** --- 1103,1107 ---- #endif error_push(context, message->str); + push_ldap_addl_error(ld, context); error = 2; } Index: prefs.c =================================================================== RCS file: /cvsroot/gqclient/gq/src/prefs.c,v retrieving revision 1.23 retrieving revision 1.24 diff -C2 -d -r1.23 -r1.24 *** prefs.c 3 Jul 2002 20:53:16 -0000 1.23 --- prefs.c 12 Jul 2002 20:27:52 -0000 1.24 *************** *** 166,169 **** --- 166,177 ---- server->ask_pw = GTK_TOGGLE_BUTTON(field)->active ? 1 : 0; + /* Hide internal */ + field = get_widget(window, "hide_internal"); + server->hide_internal = GTK_TOGGLE_BUTTON(field)->active ? 1 : 0; + + /* Show ref */ + field = get_widget(window, "show_ref"); + server->show_ref = GTK_TOGGLE_BUTTON(field)->active ? 1 : 0; + /* Cache connection */ field = get_widget(window, "cacheconn"); *************** *** 267,275 **** GtkWidget *editwindow, *notebook; GtkWidget *main_vbox, *vbox1, *vbox2, *hbox; ! GtkWidget *table1, *table2; GtkWidget *label, *entry, *button; GtkWidget *okbutton, *cancelbutton; GtkWidget *bindpw, *bindpw2; ! int y, editing_new_server; char title[MAX_SERVERNAME_LEN + 8]; char tmp[16]; --- 275,283 ---- GtkWidget *editwindow, *notebook; GtkWidget *main_vbox, *vbox1, *vbox2, *hbox; ! GtkWidget *table1, *table2, *table3; GtkWidget *label, *entry, *button; GtkWidget *okbutton, *cancelbutton; GtkWidget *bindpw, *bindpw2; ! int y, z, editing_new_server; char title[MAX_SERVERNAME_LEN + 8]; char tmp[16]; *************** *** 416,419 **** --- 424,436 ---- y = 0; + table3 = gtk_table_new(3, 2, FALSE); + gtk_object_set_data(GTK_OBJECT(editwindow), "table3", table3); + gtk_widget_show(table3); + gtk_box_pack_start(GTK_BOX(vbox2), table3, TRUE, TRUE, 0); + gtk_container_border_width(GTK_CONTAINER(table3), 10); + gtk_table_set_row_spacings(GTK_TABLE(table3), 5); + gtk_table_set_col_spacings(GTK_TABLE(table3), 13); + z = 0; + /* Bind DN */ label = gtk_label_new(_("Bind DN")); *************** *** 556,559 **** --- 573,577 ---- gtk_table_attach(GTK_TABLE(table2), entry, 1, 2, y, y + 1, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); + y++; #endif *************** *** 572,576 **** GTK_WIDGET_UNSET_FLAGS(GTK_CHECK_BUTTON(button), GTK_CAN_FOCUS); gtk_widget_show(button); ! gtk_box_pack_start(GTK_BOX(vbox2), button, FALSE, TRUE, 2); /* Cache connections */ --- 590,606 ---- GTK_WIDGET_UNSET_FLAGS(GTK_CHECK_BUTTON(button), GTK_CAN_FOCUS); gtk_widget_show(button); ! gtk_table_attach(GTK_TABLE(table3), button, 0, 1, z, z + 1, ! GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); ! ! /* Hide internal attributes */ ! button = gtk_check_button_new_with_label(_("Hide internal attributes")); ! gtk_object_set_data(GTK_OBJECT(editwindow), "hide_internal", button); ! if(server->hide_internal) ! gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(button), TRUE); ! GTK_WIDGET_UNSET_FLAGS(GTK_CHECK_BUTTON(button), GTK_CAN_FOCUS); ! gtk_widget_show(button); ! gtk_table_attach(GTK_TABLE(table3), button, 1, 2, z, z + 1, ! GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); ! z++; /* Cache connections */ *************** *** 581,585 **** GTK_WIDGET_UNSET_FLAGS(GTK_CHECK_BUTTON(button), GTK_CAN_FOCUS); gtk_widget_show(button); ! gtk_box_pack_start(GTK_BOX(vbox2), button, FALSE, TRUE, 2); /* Enable TLS */ --- 611,627 ---- GTK_WIDGET_UNSET_FLAGS(GTK_CHECK_BUTTON(button), GTK_CAN_FOCUS); gtk_widget_show(button); ! gtk_table_attach(GTK_TABLE(table3), button, 0, 1, z, z + 1, ! GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); ! ! /* Show ref */ ! button = gtk_check_button_new_with_label(_("Show referrals")); ! gtk_object_set_data(GTK_OBJECT(editwindow), "show_ref", button); ! if(server->show_ref) ! gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(button), TRUE); ! GTK_WIDGET_UNSET_FLAGS(GTK_CHECK_BUTTON(button), GTK_CAN_FOCUS); ! gtk_widget_show(button); ! gtk_table_attach(GTK_TABLE(table3), button, 1, 2, z, z + 1, ! GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); ! z++; /* Enable TLS */ *************** *** 590,594 **** GTK_WIDGET_UNSET_FLAGS(GTK_CHECK_BUTTON(button), GTK_CAN_FOCUS); gtk_widget_show(button); ! gtk_box_pack_start(GTK_BOX(vbox2), button, FALSE, TRUE, 0); /* OK and Cancel buttons */ --- 632,638 ---- GTK_WIDGET_UNSET_FLAGS(GTK_CHECK_BUTTON(button), GTK_CAN_FOCUS); gtk_widget_show(button); ! gtk_table_attach(GTK_TABLE(table3), button, 0, 1, z, z + 1, ! GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); ! z++; /* OK and Cancel buttons */ Index: tinput.c =================================================================== RCS file: /cvsroot/gqclient/gq/src/tinput.c,v retrieving revision 1.37 retrieving revision 1.38 diff -C2 -d -r1.37 -r1.38 *** tinput.c 18 Jun 2002 22:07:14 -0000 1.37 --- tinput.c 12 Jul 2002 20:27:52 -0000 1.38 *************** *** 256,259 **** --- 256,262 ---- form->flags |= FLAG_SINGLE_VALUE; } + if (at && at->at_no_user_mod) { + form->flags |= FLAG_NO_USER_MOD; + } set_displaytype(server, form); formlist = formlist_append(formlist, form); *************** *** 278,281 **** --- 281,287 ---- if (at && at->at_single_value) { form->flags |= FLAG_SINGLE_VALUE; + } + if (at && at->at_no_user_mod) { + form->flags |= FLAG_NO_USER_MOD; } } Index: util.c =================================================================== RCS file: /cvsroot/gqclient/gq/src/util.c,v retrieving revision 1.41 retrieving revision 1.42 diff -C2 -d -r1.41 -r1.42 *** util.c 3 Jul 2002 20:13:05 -0000 1.41 --- util.c 12 Jul 2002 20:27:52 -0000 1.42 *************** *** 220,223 **** --- 220,247 ---- } + + if (ld && server->show_ref) { + LDAPControl c; + LDAPControl *ctrls[2]; + ctrls[0] = &c; + ctrls[1] = NULL; + + c.ldctl_oid = LDAP_CONTROL_MANAGEDSAIT; + c.ldctl_value.bv_val = NULL; + c.ldctl_value.bv_len = 0; + c.ldctl_iscritical = 1; + + rc = ldap_set_option(ld, LDAP_OPT_SERVER_CONTROLS, ctrls); + + if (rc != LDAP_OPT_SUCCESS ) { + error_push(open_context, + _("Could not set critical ManageDSAit control")); + push_ldap_addl_error(ld, open_context); + + ldap_unbind(ld); + ld = NULL; + } + } + *ld_out = ld; return rc; |