diff options
author | Jonathon Jongsma <jjongsma@redhat.com> | 2014-07-18 16:51:05 -0500 |
---|---|---|
committer | Christophe Fergeau <cfergeau@redhat.com> | 2014-08-18 13:20:42 +0200 |
commit | 49abd71dae12d2b284aee7d6c9c8213b22738b19 (patch) | |
tree | c10b359d2d9372d43ff6097ae6c22b53cff56b7f /src/virt-viewer-auth.c | |
parent | 8b7f5db57356d3adca864585efe672a830ce5b87 (diff) | |
download | virt-viewer-49abd71dae12d2b284aee7d6c9c8213b22738b19.tar.gz virt-viewer-49abd71dae12d2b284aee7d6c9c8213b22738b19.tar.xz virt-viewer-49abd71dae12d2b284aee7d6c9c8213b22738b19.zip |
remote-viewer: allow username in ovirt URIs
When the user launches remote-viewer with an ovirt URI of the form
ovirt://user@host/vmname
Pre-populate the authentication dialog with the specified username. We
don't support specifying the password on the commandline, since that is
a potential security risk.
rhbz#1061826
Diffstat (limited to 'src/virt-viewer-auth.c')
-rw-r--r-- | src/virt-viewer-auth.c | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/src/virt-viewer-auth.c b/src/virt-viewer-auth.c index a5b6393..6745566 100644 --- a/src/virt-viewer-auth.c +++ b/src/virt-viewer-auth.c @@ -32,6 +32,10 @@ #include "virt-viewer-auth.h" +/* NOTE: if username is provided, and *username is non-NULL, the user input + * field will be pre-filled with this value. The existing string will be freed + * before setting the output parameter to the user-entered value. + */ int virt_viewer_auth_collect_credentials(GtkWindow *window, const char *type, @@ -60,6 +64,8 @@ virt_viewer_auth_collect_credentials(GtkWindow *window, promptPassword = GTK_WIDGET(gtk_builder_get_object(creds, "prompt-password")); gtk_widget_set_sensitive(credUsername, username != NULL); + if (username && *username) + gtk_entry_set_text(GTK_ENTRY(credUsername), *username); gtk_widget_set_sensitive(promptUsername, username != NULL); gtk_widget_set_sensitive(credPassword, password != NULL); gtk_widget_set_sensitive(promptPassword, password != NULL); @@ -82,8 +88,10 @@ virt_viewer_auth_collect_credentials(GtkWindow *window, gtk_widget_hide(dialog); if (response == GTK_RESPONSE_OK) { - if (username) + if (username) { + g_free(*username); *username = g_strdup(gtk_entry_get_text(GTK_ENTRY(credUsername))); + } if (password) *password = g_strdup(gtk_entry_get_text(GTK_ENTRY(credPassword))); } |