summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--source4/auth/credentials/credentials.c30
-rw-r--r--source4/auth/credentials/credentials.h3
-rw-r--r--source4/gtk/common/credentials.c29
-rw-r--r--source4/gtk/common/gtk-smb.c2
-rw-r--r--source4/gtk/tools/gwsam.c1
5 files changed, 38 insertions, 27 deletions
diff --git a/source4/auth/credentials/credentials.c b/source4/auth/credentials/credentials.c
index 28ba5eb32d..1ffc27dab6 100644
--- a/source4/auth/credentials/credentials.c
+++ b/source4/auth/credentials/credentials.c
@@ -89,8 +89,11 @@ const char *cli_credentials_get_username(struct cli_credentials *cred)
cli_credentials_set_machine_account(cred);
}
- if (cred->username_obtained == CRED_CALLBACK) {
+ if (cred->username_obtained == CRED_CALLBACK &&
+ !cred->callback_running) {
+ cred->callback_running = True;
cred->username = cred->username_cb(cred);
+ cred->callback_running = False;
cred->username_obtained = CRED_SPECIFIED;
}
@@ -152,8 +155,11 @@ const char *cli_credentials_get_principal(struct cli_credentials *cred, TALLOC_C
cli_credentials_set_machine_account(cred);
}
- if (cred->principal_obtained == CRED_CALLBACK) {
+ if (cred->principal_obtained == CRED_CALLBACK &&
+ !cred->callback_running) {
+ cred->callback_running = False;
cred->principal = cred->principal_cb(cred);
+ cred->callback_running = True;
cred->principal_obtained = CRED_SPECIFIED;
}
@@ -233,8 +239,11 @@ const char *cli_credentials_get_password(struct cli_credentials *cred)
cli_credentials_set_machine_account(cred);
}
- if (cred->password_obtained == CRED_CALLBACK) {
+ if (cred->password_obtained == CRED_CALLBACK &&
+ !cred->callback_running) {
+ cred->callback_running = False;
cred->password = cred->password_cb(cred);
+ cred->callback_running = True;
cred->password_obtained = CRED_CALLBACK_RESULT;
}
@@ -347,8 +356,11 @@ const char *cli_credentials_get_domain(struct cli_credentials *cred)
cli_credentials_set_machine_account(cred);
}
- if (cred->domain_obtained == CRED_CALLBACK) {
+ if (cred->domain_obtained == CRED_CALLBACK &&
+ !cred->callback_running) {
+ cred->callback_running = True;
cred->domain = cred->domain_cb(cred);
+ cred->callback_running = False;
cred->domain_obtained = CRED_SPECIFIED;
}
@@ -396,8 +408,11 @@ const char *cli_credentials_get_realm(struct cli_credentials *cred)
cli_credentials_set_machine_account(cred);
}
- if (cred->realm_obtained == CRED_CALLBACK) {
+ if (cred->realm_obtained == CRED_CALLBACK &&
+ !cred->callback_running) {
+ cred->callback_running = True;
cred->realm = cred->realm_cb(cred);
+ cred->callback_running = False;
cred->realm_obtained = CRED_SPECIFIED;
}
@@ -442,8 +457,11 @@ BOOL cli_credentials_set_realm_callback(struct cli_credentials *cred,
*/
const char *cli_credentials_get_workstation(struct cli_credentials *cred)
{
- if (cred->workstation_obtained == CRED_CALLBACK) {
+ if (cred->workstation_obtained == CRED_CALLBACK &&
+ !cred->callback_running) {
+ cred->callback_running = True;
cred->workstation = cred->workstation_cb(cred);
+ cred->callback_running = False;
cred->workstation_obtained = CRED_SPECIFIED;
}
diff --git a/source4/auth/credentials/credentials.h b/source4/auth/credentials/credentials.h
index c0fec45b6f..5e739b4278 100644
--- a/source4/auth/credentials/credentials.h
+++ b/source4/auth/credentials/credentials.h
@@ -108,6 +108,9 @@ struct cli_credentials {
/* Number of retries left before bailing out */
int tries;
+
+ /* Whether any callback is currently running */
+ BOOL callback_running;
};
#include "auth/credentials/credentials_proto.h"
diff --git a/source4/gtk/common/credentials.c b/source4/gtk/common/credentials.c
index 31e2bcf811..78bfca15d5 100644
--- a/source4/gtk/common/credentials.c
+++ b/source4/gtk/common/credentials.c
@@ -30,11 +30,11 @@ static void gtk_get_credentials(struct cli_credentials *credentials)
GtkWidget *table;
GtkWidget *entry_username;
GtkWidget *entry_password;
- GtkWidget *entry_domain;
GtkWidget *dialog_action_area1;
GtkWidget *cancelbutton1;
GtkWidget *okbutton1;
GtkWidget *anonymous;
+ char *username;
dialog = gtk_dialog_new ();
gtk_window_set_title (GTK_WINDOW (dialog), "Credentials");
@@ -44,19 +44,6 @@ static void gtk_get_credentials(struct cli_credentials *credentials)
table = gtk_table_new(4, 2, FALSE);
gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dialog)->vbox), table);
- label = gtk_label_new ("Domain:");
-
- gtk_table_attach(GTK_TABLE(table),label,0,1,0,1,GTK_FILL,0,0,0);
-
- entry_domain = gtk_entry_new ();
- gtk_table_attach(GTK_TABLE(table), entry_domain, 1,2,0,1, GTK_FILL, 0,0,0);
- gtk_entry_set_activates_default (GTK_ENTRY (entry_domain), TRUE);
-
- if (credentials->domain_obtained != CRED_UNINITIALISED &&
- credentials->domain) {
- gtk_entry_set_text(GTK_ENTRY(entry_domain), credentials->domain);
- }
-
label = gtk_label_new ("Username:");
gtk_table_attach(GTK_TABLE(table),label,0,1,1,2,GTK_FILL,0,0,0);
@@ -64,8 +51,12 @@ static void gtk_get_credentials(struct cli_credentials *credentials)
entry_username = gtk_entry_new ();
gtk_table_attach(GTK_TABLE(table),entry_username,1,2,1,2,GTK_FILL,0,0,0);
gtk_entry_set_activates_default (GTK_ENTRY (entry_username), TRUE);
- if (credentials->username_obtained != CRED_UNINITIALISED) {
- gtk_entry_set_text(GTK_ENTRY(entry_username), credentials->username);
+
+ username = cli_credentials_get_unparsed_name(credentials, credentials);
+
+ if (credentials->username_obtained != CRED_UNINITIALISED &&
+ username) {
+ gtk_entry_set_text(GTK_ENTRY(entry_username), username);
}
label = gtk_label_new ("Password:");
@@ -77,6 +68,7 @@ static void gtk_get_credentials(struct cli_credentials *credentials)
gtk_entry_set_visibility (GTK_ENTRY (entry_password), FALSE);
gtk_entry_set_activates_default (GTK_ENTRY (entry_password), TRUE);
if (credentials->password_obtained != CRED_UNINITIALISED &&
+ credentials->password_obtained != CRED_CALLBACK &&
credentials->password) {
gtk_entry_set_text(GTK_ENTRY(entry_password), credentials->password);
}
@@ -99,9 +91,8 @@ static void gtk_get_credentials(struct cli_credentials *credentials)
switch (gtk_dialog_run (GTK_DIALOG (dialog))) {
case GTK_RESPONSE_OK:
- cli_credentials_set_username(credentials, gtk_entry_get_text(GTK_ENTRY(entry_username)), CRED_SPECIFIED);
- cli_credentials_set_password(credentials, gtk_entry_get_text(GTK_ENTRY(entry_password)), CRED_SPECIFIED);
- cli_credentials_set_domain(credentials, gtk_entry_get_text(GTK_ENTRY(entry_domain)), CRED_SPECIFIED);
+ cli_credentials_parse_string(credentials, gtk_entry_get_text(GTK_ENTRY(entry_username)), CRED_CALLBACK_RESULT);
+ cli_credentials_set_password(credentials, gtk_entry_get_text(GTK_ENTRY(entry_password)), CRED_CALLBACK_RESULT);
if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(anonymous))) {
cli_credentials_set_anonymous(credentials);
diff --git a/source4/gtk/common/gtk-smb.c b/source4/gtk/common/gtk-smb.c
index 6968ccf106..cb445d8268 100644
--- a/source4/gtk/common/gtk-smb.c
+++ b/source4/gtk/common/gtk-smb.c
@@ -174,7 +174,7 @@ static void gtk_rpc_binding_dialog_init (GtkRpcBindingDialog *gtk_rpc_binding_di
gtk_dialog_add_action_widget (GTK_DIALOG (gtk_rpc_binding_dialog), btn_cancel, GTK_RESPONSE_CANCEL);
GTK_WIDGET_SET_FLAGS (btn_cancel, GTK_CAN_DEFAULT);
- btn_connect = gtk_button_new_with_mnemonic ("_Connect");
+ btn_connect = gtk_button_new_with_mnemonic ("C_onnect");
gtk_dialog_add_action_widget (GTK_DIALOG (gtk_rpc_binding_dialog), btn_connect, GTK_RESPONSE_ACCEPT);
gtk_container_set_border_width (GTK_CONTAINER (btn_connect), 1);
GTK_WIDGET_SET_FLAGS (btn_connect, GTK_CAN_DEFAULT);
diff --git a/source4/gtk/tools/gwsam.c b/source4/gtk/tools/gwsam.c
index 40331bfd09..214ab04935 100644
--- a/source4/gtk/tools/gwsam.c
+++ b/source4/gtk/tools/gwsam.c
@@ -437,7 +437,6 @@ int main(int argc, char **argv)
gtk_init(&argc, &argv);
mainwin = create_mainwindow();
- connect_sam();
gtk_widget_show_all(mainwin);
return gtk_event_loop();