[NetworkManager-openconnect: 1/2] auth-dialog: Don't exit early in non-interactive mode




commit d0a85db8b593193ef594db9a51292f79d9b2afac
Author: Kevin Murphy <kemurphy oculus com>
Date:   Thu Feb 20 19:37:14 2020 -0800

    auth-dialog: Don't exit early in non-interactive mode
    
    The early exit has a couple consequences:
    - Whatever is driving this auth dialog may perceive the lack of stdout
      as discarding any secrets (some of which may be agent-owned and
      consequently removed from the keyring).
    - nm-applet may or may not see a SIGPIPE, leading to inconsistent
      behavior regarding aforementioned agent-owned secrets.
    
    Instead, let's just not show any UI if we're not running interactively,
    but continue to follow the stdin/stdout protocol.

 auth-dialog/main.c | 41 +++++++++++++++++++----------------------
 1 file changed, 19 insertions(+), 22 deletions(-)
---
diff --git a/auth-dialog/main.c b/auth-dialog/main.c
index 5c1518e..247ee01 100644
--- a/auth-dialog/main.c
+++ b/auth-dialog/main.c
@@ -1755,9 +1755,6 @@ int main (int argc, char **argv)
                }
        }
 
-       if (!allow_interaction)
-               return 0;
-
        if (optind != argc) {
                fprintf(stderr, "Superfluous command line options\n");
                return 1;
@@ -1788,34 +1785,34 @@ int main (int argc, char **argv)
                return 1;
        }
 
+       if (allow_interaction) {
 #if OPENCONNECT_CHECK_VER(3,4)
-       openconnect_set_token_callbacks (_ui_data->vpninfo, _ui_data, NULL, update_token);
+               openconnect_set_token_callbacks (_ui_data->vpninfo, _ui_data, NULL, update_token);
 #endif
 
-       build_main_dialog(_ui_data);
-
-       openconnect_init_ssl();
+               build_main_dialog(_ui_data);
 
-       /* These can't be done until token password handled */
-       gtk_widget_set_sensitive (_ui_data->combo, FALSE);
-       gtk_widget_set_sensitive (_ui_data->connect_button, FALSE);
+               openconnect_init_ssl();
 
-       init_thread = g_thread_new("init_connection", (GThreadFunc)init_connection, _ui_data);
-       g_thread_unref(init_thread);
+               /* These can't be done until token password handled */
+               gtk_widget_set_sensitive (_ui_data->combo, FALSE);
+               gtk_widget_set_sensitive (_ui_data->connect_button, FALSE);
 
-       gtk_window_present(GTK_WINDOW(_ui_data->dialog));
-       gtk_main();
+               init_thread = g_thread_new("init_connection", (GThreadFunc)init_connection, _ui_data);
+               g_thread_unref(init_thread);
 
-       if (!g_hash_table_size (_ui_data->secrets))
-               return 0;
+               gtk_window_present(GTK_WINDOW(_ui_data->dialog));
+               gtk_main();
+       }
 
        /* Dump all secrets to stdout */
-       g_hash_table_iter_init (&iter, _ui_data->secrets);
-       while (g_hash_table_iter_next (&iter, (gpointer *)&key,
-                                      (gpointer *)&value))
-               printf("%s\n%s\n", key, value);
-       printf("\n\n");
-       fflush(stdout);
+       if (g_hash_table_size (_ui_data->secrets) > 0) {
+               g_hash_table_iter_init (&iter, _ui_data->secrets);
+               while (g_hash_table_iter_next (&iter, (gpointer *)&key, (gpointer *)&value))
+                       printf("%s\n%s\n", key, value);
+               printf("\n\n");
+               fflush(stdout);
+       }
 
        wait_for_quit ();
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]