about summary refs log tree commit diff stats
path: root/src
diff options
context:
space:
mode:
authorJames Booth <boothj5@gmail.com>2015-11-10 23:14:59 +0000
committerJames Booth <boothj5@gmail.com>2015-11-10 23:14:59 +0000
commitfcfdc175b6c94d1fd57e5a26b31f411a07ba3198 (patch)
tree42c5a9eab4a0208da006c45f8d7215fdbdd259aa /src
parent0bb596e14a34cacbe58da3bed62371bc17e53f11 (diff)
downloadprofani-tty-fcfdc175b6c94d1fd57e5a26b31f411a07ba3198.tar.gz
Allow /quit during TLS certificate verification prompt
Diffstat (limited to 'src')
-rw-r--r--src/event/server_events.c23
-rw-r--r--src/profanity.c9
-rw-r--r--src/profanity.h2
3 files changed, 26 insertions, 8 deletions
diff --git a/src/event/server_events.c b/src/event/server_events.c
index 58add417..d5022d35 100644
--- a/src/event/server_events.c
+++ b/src/event/server_events.c
@@ -47,6 +47,7 @@
 #include "roster_list.h"
 #include "window_list.h"
 #include "config/tlscerts.h"
+#include "profanity.h"
 
 #ifdef HAVE_LIBOTR
 #include "otr/otr.h"
@@ -733,9 +734,9 @@ sv_ev_certfail(const char *const errormsg, TLSCertificate *cert)
     cons_show_error("TLS certificate verification failed: %s", errormsg);
     cons_show_tlscert(cert);
     cons_show("");
-    cons_show("Use '/tls allow' to accept this certificate");
-    cons_show("Use '/tls always' to accept this certificate permanently");
-    cons_show("Use '/tls deny' to reject this certificate");
+    cons_show("Use '/tls allow' to accept this certificate.");
+    cons_show("Use '/tls always' to accept this certificate permanently.");
+    cons_show("Use '/tls deny' to reject this certificate.");
     cons_show("");
     ui_update();
 
@@ -743,10 +744,11 @@ sv_ev_certfail(const char *const errormsg, TLSCertificate *cert)
 
     while ((g_strcmp0(cmd, "/tls allow") != 0)
                 && (g_strcmp0(cmd, "/tls always") != 0)
-                && (g_strcmp0(cmd, "/tls deny") != 0)) {
-        cons_show("Use '/tls allow' to accept this certificate");
-        cons_show("Use '/tls always' to accept this certificate permanently");
-        cons_show("Use '/tls deny' to reject this certificate");
+                && (g_strcmp0(cmd, "/tls deny") != 0)
+                && (g_strcmp0(cmd, "/quit") != 0)) {
+        cons_show("Use '/tls allow' to accept this certificate.");
+        cons_show("Use '/tls always' to accept this certificate permanently.");
+        cons_show("Use '/tls deny' to reject this certificate.");
         cons_show("");
         ui_update();
         free(cmd);
@@ -754,16 +756,23 @@ sv_ev_certfail(const char *const errormsg, TLSCertificate *cert)
     }
 
     if (g_strcmp0(cmd, "/tls allow") == 0) {
+        cons_show("Coninuing with connection.");
         tlscerts_set_current(cert->fingerprint);
         free(cmd);
         return 1;
     } else if (g_strcmp0(cmd, "/tls always") == 0) {
+        cons_show("Adding %s to trusted certificates.", cert->fingerprint);
         if (!tlscerts_exists(cert->fingerprint)) {
             tlscerts_add(cert);
         }
         free(cmd);
         return 1;
+    } else if (g_strcmp0(cmd, "/quit") == 0) {
+        prof_set_quit();
+        free(cmd);
+        return 0;
     } else {
+        cons_show("Aborting connection.");
         free(cmd);
         return 0;
     }
diff --git a/src/profanity.c b/src/profanity.c
index a3afb3c2..6e973a72 100644
--- a/src/profanity.c
+++ b/src/profanity.c
@@ -90,6 +90,7 @@ resource_presence_t saved_presence;
 char *saved_status;
 
 static gboolean cont = TRUE;
+static gboolean force_quit = FALSE;
 
 void
 prof_run(char *log_level, char *account_name)
@@ -104,7 +105,7 @@ prof_run(char *log_level, char *account_name)
     saved_status = NULL;
 
     char *line = NULL;
-    while(cont) {
+    while(cont && !force_quit) {
         log_stderr_handler();
         _check_autoaway();
 
@@ -128,6 +129,12 @@ prof_run(char *log_level, char *account_name)
 }
 
 void
+prof_set_quit(void)
+{
+    force_quit = TRUE;
+}
+
+void
 prof_handle_idle(void)
 {
     jabber_conn_status_t status = jabber_get_connection_status();
diff --git a/src/profanity.h b/src/profanity.h
index 123e2f00..f19f5f36 100644
--- a/src/profanity.h
+++ b/src/profanity.h
@@ -45,4 +45,6 @@ void prof_handle_activity(void);
 
 gboolean process_input(char *inp);
 
+void prof_set_quit(void);
+
 #endif