From 674a8aaf7ec08f9ec8be79e41cc7d4c8f3e81970 Mon Sep 17 00:00:00 2001 From: moppman Date: Fri, 14 Feb 2020 14:58:48 +0100 Subject: Disallow sendfile in e2ee chat sessions --- src/command/cmd_funcs.c | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/src/command/cmd_funcs.c b/src/command/cmd_funcs.c index 93b002f4..8ac15535 100644 --- a/src/command/cmd_funcs.c +++ b/src/command/cmd_funcs.c @@ -4797,6 +4797,41 @@ cmd_sendfile(ProfWin *window, const char *const command, gchar **args) return TRUE; } + switch (window->type) { + case WIN_MUC: + { + ProfMucWin *mucwin = (ProfMucWin*)window; + assert(mucwin->memcheck == PROFMUCWIN_MEMCHECK); + if (mucwin->is_omemo) { //no pgp or otr available in MUCs + cons_show_error("Uploading '%s' failed: Encrypted file uploads not yet implemented!", filename); + win_println(window, THEME_ERROR, '-', "Sending encrypted files via http_upload is not possible yet."); + free(filename); + return TRUE; + } + break; + } + case WIN_CHAT: + { + ProfChatWin *chatwin = (ProfChatWin*)window; + assert(chatwin->memcheck == PROFCHATWIN_MEMCHECK); + if (chatwin->pgp_send || chatwin->is_omemo || chatwin->is_otr) { + cons_show_error("Uploading '%s' failed: Encrypted file uploads not yet implemented!", filename); + win_println(window, THEME_ERROR, '-', "Sending encrypted files via http_upload is not possible yet."); + free(filename); + return TRUE; + } + break; + } + case WIN_PRIVATE: + { + break; //we don't support encryption in private muc windows anyway + } + default: + cons_show_error("Unsupported window for file transmission."); + free(filename); + return TRUE; + } + if (access(filename, R_OK) != 0) { cons_show_error("Uploading '%s' failed: File not found!", filename); free(filename); -- cgit 1.4.1-2-gfad0 From 36713a2ed73368cf1892ce1fa43bb74106657391 Mon Sep 17 00:00:00 2001 From: Michael Vetter Date: Mon, 17 Feb 2020 08:31:46 +0100 Subject: Make /sendfile in OMEMO session configurable `/omemo sendfile on` allows unencrypted file transfer in an OMEMO session. Regards https://github.com/profanity-im/profanity/pull/1270 --- src/command/cmd_ac.c | 14 +++++++++++++- src/command/cmd_defs.c | 5 ++++- src/command/cmd_funcs.c | 34 ++++++++++++++++++++++++++-------- src/command/cmd_funcs.h | 1 + src/config/preferences.c | 3 +++ src/config/preferences.h | 1 + src/ui/console.c | 6 ++++++ 7 files changed, 54 insertions(+), 10 deletions(-) diff --git a/src/command/cmd_ac.c b/src/command/cmd_ac.c index 386e8939..0e65c3fd 100644 --- a/src/command/cmd_ac.c +++ b/src/command/cmd_ac.c @@ -176,6 +176,7 @@ static Autocomplete otr_policy_ac; static Autocomplete omemo_ac; static Autocomplete omemo_log_ac; static Autocomplete omemo_policy_ac; +static Autocomplete omemo_sendfile_ac; static Autocomplete connect_property_ac; static Autocomplete tls_property_ac; static Autocomplete alias_ac; @@ -626,6 +627,7 @@ cmd_ac_init(void) autocomplete_add(omemo_ac, "clear_device_list"); autocomplete_add(omemo_ac, "policy"); autocomplete_add(omemo_ac, "char"); + autocomplete_add(omemo_ac, "sendfile"); omemo_log_ac = autocomplete_new(); autocomplete_add(omemo_log_ac, "on"); @@ -637,6 +639,10 @@ cmd_ac_init(void) autocomplete_add(omemo_policy_ac, "automatic"); autocomplete_add(omemo_policy_ac, "always"); + omemo_sendfile_ac = autocomplete_new(); + autocomplete_add(omemo_sendfile_ac, "on"); + autocomplete_add(omemo_sendfile_ac, "off"); + connect_property_ac = autocomplete_new(); autocomplete_add(connect_property_ac, "server"); autocomplete_add(connect_property_ac, "port"); @@ -1187,6 +1193,7 @@ cmd_ac_reset(ProfWin *window) autocomplete_reset(omemo_ac); autocomplete_reset(omemo_log_ac); autocomplete_reset(omemo_policy_ac); + autocomplete_reset(omemo_sendfile_ac); autocomplete_reset(connect_property_ac); autocomplete_reset(tls_property_ac); autocomplete_reset(alias_ac); @@ -1331,6 +1338,7 @@ cmd_ac_uninit(void) autocomplete_free(omemo_ac); autocomplete_free(omemo_log_ac); autocomplete_free(omemo_policy_ac); + autocomplete_free(omemo_sendfile_ac); autocomplete_free(connect_property_ac); autocomplete_free(tls_property_ac); autocomplete_free(alias_ac); @@ -2303,6 +2311,11 @@ _omemo_autocomplete(ProfWin *window, const char *const input, gboolean previous) return found; } + found = autocomplete_param_with_ac(input, "/omemo sendfile", omemo_sendfile_ac, TRUE, previous); + if (found) { + return found; + } + jabber_conn_status_t conn_status = connection_get_status(); if (conn_status == JABBER_CONNECTED) { @@ -2316,7 +2329,6 @@ _omemo_autocomplete(ProfWin *window, const char *const input, gboolean previous) return found; } - #ifdef HAVE_OMEMO if (window->type == WIN_CHAT) { ProfChatWin *chatwin = (ProfChatWin*)window; diff --git a/src/command/cmd_defs.c b/src/command/cmd_defs.c index 78a2e342..5d3d0067 100644 --- a/src/command/cmd_defs.c +++ b/src/command/cmd_defs.c @@ -2236,7 +2236,8 @@ static struct cmd_t command_defs[] = { "fingerprint", cmd_omemo_fingerprint }, { "char", cmd_omemo_char }, { "policy", cmd_omemo_policy }, - { "clear_device_list", cmd_omemo_clear_device_list }) + { "clear_device_list", cmd_omemo_clear_device_list }, + { "sendfile", cmd_omemo_sendfile} ) CMD_NOMAINFUNC CMD_TAGS( CMD_TAG_CHAT, @@ -2250,6 +2251,7 @@ static struct cmd_t command_defs[] = "/omemo fingerprint []", "/omemo char ", "/omemo policy manual|automatic|always", + "/omemo sendfile on|off", "/omemo clear_device_list") CMD_DESC( "OMEMO commands to manage keys, and perform encryption during chat sessions.") @@ -2264,6 +2266,7 @@ static struct cmd_t command_defs[] = { "policy manual", "Set the global OMEMO policy to manual, OMEMO sessions must be started manually." }, { "policy automatic", "Set the global OMEMO policy to opportunistic, an OMEMO session will be attempted upon starting a conversation." }, { "policy always", "Set the global OMEMO policy to always, an error will be displayed if an OMEMO session cannot be initiated upon starting a conversation." }, + { "sendfile", "Allow /sendfile to send unencrypted files while in an OMEMO session."}, { "clear_device_list", "Clear your own device list on server side. Each client will reannounce itself when connected back."}) CMD_EXAMPLES( "/omemo gen", diff --git a/src/command/cmd_funcs.c b/src/command/cmd_funcs.c index 8ac15535..e5c540c3 100644 --- a/src/command/cmd_funcs.c +++ b/src/command/cmd_funcs.c @@ -4802,8 +4802,10 @@ cmd_sendfile(ProfWin *window, const char *const command, gchar **args) { ProfMucWin *mucwin = (ProfMucWin*)window; assert(mucwin->memcheck == PROFMUCWIN_MEMCHECK); - if (mucwin->is_omemo) { //no pgp or otr available in MUCs - cons_show_error("Uploading '%s' failed: Encrypted file uploads not yet implemented!", filename); + + // only omemo, no pgp/otr available in MUCs + if (mucwin->is_omemo && !prefs_get_boolean(PREF_OMEMO_SENDFILE)) { + cons_show_error("Uploading '%s' failed: Encrypted file uploads not yet implemented!", filename); win_println(window, THEME_ERROR, '-', "Sending encrypted files via http_upload is not possible yet."); free(filename); return TRUE; @@ -4814,12 +4816,15 @@ cmd_sendfile(ProfWin *window, const char *const command, gchar **args) { ProfChatWin *chatwin = (ProfChatWin*)window; assert(chatwin->memcheck == PROFCHATWIN_MEMCHECK); - if (chatwin->pgp_send || chatwin->is_omemo || chatwin->is_otr) { - cons_show_error("Uploading '%s' failed: Encrypted file uploads not yet implemented!", filename); - win_println(window, THEME_ERROR, '-', "Sending encrypted files via http_upload is not possible yet."); - free(filename); - return TRUE; - } + + if ((chatwin->is_omemo && !prefs_get_boolean(PREF_OMEMO_SENDFILE)) + || (chatwin->pgp_send) + || (chatwin->is_otr)) { + cons_show_error("Uploading '%s' failed: Encrypted file uploads not yet implemented!", filename); + win_println(window, THEME_ERROR, '-', "Sending encrypted files via http_upload is not possible yet."); + free(filename); + return TRUE; + } break; } case WIN_PRIVATE: @@ -8575,6 +8580,19 @@ cmd_omemo_policy(ProfWin *window, const char *const command, gchar **args) #endif } +gboolean +cmd_omemo_sendfile(ProfWin *window, const char *const command, gchar **args) +{ +#ifdef HAVE_OMEMO + _cmd_set_boolean_preference(args[1], command, "Sending unencrypted files in an OMEMO session via /sendfile", PREF_OMEMO_SENDFILE); + + return TRUE; +#else + cons_show("This version of Profanity has not been built with OMEMO support enabled"); + return TRUE; +#endif +} + gboolean cmd_save(ProfWin *window, const char *const command, gchar **args) { diff --git a/src/command/cmd_funcs.h b/src/command/cmd_funcs.h index f283c910..389c35de 100644 --- a/src/command/cmd_funcs.h +++ b/src/command/cmd_funcs.h @@ -219,6 +219,7 @@ gboolean cmd_omemo_trust(ProfWin *window, const char *const command, gchar **arg gboolean cmd_omemo_untrust(ProfWin *window, const char *const command, gchar **args); gboolean cmd_omemo_policy(ProfWin *window, const char *const command, gchar **args); gboolean cmd_omemo_clear_device_list(ProfWin *window, const char *const command, gchar **args); +gboolean cmd_omemo_sendfile(ProfWin *window, const char *const command, gchar **args); gboolean cmd_save(ProfWin *window, const char *const command, gchar **args); gboolean cmd_reload(ProfWin *window, const char *const command, gchar **args); diff --git a/src/config/preferences.c b/src/config/preferences.c index dea6a529..8a503291 100644 --- a/src/config/preferences.c +++ b/src/config/preferences.c @@ -1800,6 +1800,7 @@ _get_group(preference_t pref) return PREF_GROUP_PLUGINS; case PREF_OMEMO_LOG: case PREF_OMEMO_POLICY: + case PREF_OMEMO_SENDFILE: return PREF_GROUP_OMEMO; default: return NULL; @@ -2037,6 +2038,8 @@ _get_key(preference_t pref) return "log"; case PREF_OMEMO_POLICY: return "policy"; + case PREF_OMEMO_SENDFILE: + return "sendfile"; case PREF_CORRECTION_ALLOW: return "correction.allow"; default: diff --git a/src/config/preferences.h b/src/config/preferences.h index 4c903272..a373a701 100644 --- a/src/config/preferences.h +++ b/src/config/preferences.h @@ -160,6 +160,7 @@ typedef enum { PREF_STATUSBAR_ROOM, PREF_OMEMO_LOG, PREF_OMEMO_POLICY, + PREF_OMEMO_SENDFILE, PREF_OCCUPANTS_WRAP, PREF_CORRECTION_ALLOW, } preference_t; diff --git a/src/ui/console.c b/src/ui/console.c index f7fa448d..6de8258f 100644 --- a/src/ui/console.c +++ b/src/ui/console.c @@ -2118,6 +2118,12 @@ cons_show_omemo_prefs(void) char ch = prefs_get_omemo_char(); cons_show("OMEMO char (/omemo char) : %c", ch); + if (prefs_get_boolean(PREF_OMEMO_SENDFILE)) { + cons_show("Allow sending unencrypted files in an OMEMO session via /sendfile (/omemo sendfile): ON"); + } else { + cons_show("Allow sending unencrypted files in an OMEMO session via /sendfile (/omemo sendfile): OFF"); + } + cons_alert(); } -- cgit 1.4.1-2-gfad0 From 86bcadcbe3806439ca2039b39af08afd4db70429 Mon Sep 17 00:00:00 2001 From: Michael Vetter Date: Mon, 17 Feb 2020 08:44:26 +0100 Subject: Make /sendfile in OTR session configurable `/otr sendfile on` allows unencrypted file transfer in an OMEMO session. Regards https://github.com/profanity-im/profanity/pull/1270 --- src/command/cmd_ac.c | 13 +++++++++++++ src/command/cmd_defs.c | 11 +++++++---- src/command/cmd_funcs.c | 18 ++++++++++++++++-- src/command/cmd_funcs.h | 1 + src/config/preferences.c | 3 +++ src/config/preferences.h | 1 + src/ui/console.c | 6 ++++++ 7 files changed, 47 insertions(+), 6 deletions(-) diff --git a/src/command/cmd_ac.c b/src/command/cmd_ac.c index 0e65c3fd..7d170d10 100644 --- a/src/command/cmd_ac.c +++ b/src/command/cmd_ac.c @@ -173,6 +173,7 @@ static Autocomplete bookmark_property_ac; static Autocomplete otr_ac; static Autocomplete otr_log_ac; static Autocomplete otr_policy_ac; +static Autocomplete otr_sendfile_ac; static Autocomplete omemo_ac; static Autocomplete omemo_log_ac; static Autocomplete omemo_policy_ac; @@ -605,6 +606,7 @@ cmd_ac_init(void) autocomplete_add(otr_ac, "question"); autocomplete_add(otr_ac, "answer"); autocomplete_add(otr_ac, "char"); + autocomplete_add(otr_ac, "sendfile"); otr_log_ac = autocomplete_new(); autocomplete_add(otr_log_ac, "on"); @@ -616,6 +618,10 @@ cmd_ac_init(void) autocomplete_add(otr_policy_ac, "opportunistic"); autocomplete_add(otr_policy_ac, "always"); + otr_sendfile_ac = autocomplete_new(); + autocomplete_add(otr_sendfile_ac, "on"); + autocomplete_add(otr_sendfile_ac, "off"); + omemo_ac = autocomplete_new(); autocomplete_add(omemo_ac, "gen"); autocomplete_add(omemo_ac, "log"); @@ -1190,6 +1196,7 @@ cmd_ac_reset(ProfWin *window) autocomplete_reset(otr_ac); autocomplete_reset(otr_log_ac); autocomplete_reset(otr_policy_ac); + autocomplete_reset(otr_sendfile_ac); autocomplete_reset(omemo_ac); autocomplete_reset(omemo_log_ac); autocomplete_reset(omemo_policy_ac); @@ -1335,6 +1342,7 @@ cmd_ac_uninit(void) autocomplete_free(otr_ac); autocomplete_free(otr_log_ac); autocomplete_free(otr_policy_ac); + autocomplete_free(otr_sendfile_ac); autocomplete_free(omemo_ac); autocomplete_free(omemo_log_ac); autocomplete_free(omemo_policy_ac); @@ -2234,6 +2242,11 @@ _otr_autocomplete(ProfWin *window, const char *const input, gboolean previous) return found; } + found = autocomplete_param_with_ac(input, "/otr sendfile", otr_sendfile_ac, TRUE, previous); + if (found) { + return found; + } + found = autocomplete_param_with_ac(input, "/otr", otr_ac, TRUE, previous); if (found) { return found; diff --git a/src/command/cmd_defs.c b/src/command/cmd_defs.c index 5d3d0067..3897efc1 100644 --- a/src/command/cmd_defs.c +++ b/src/command/cmd_defs.c @@ -1695,7 +1695,8 @@ static struct cmd_t command_defs[] = { "untrust", cmd_otr_untrust }, { "secret", cmd_otr_secret }, { "question", cmd_otr_question }, - { "answer", cmd_otr_answer }) + { "answer", cmd_otr_answer }, + { "sendfile", cmd_otr_sendfile }) CMD_NOMAINFUNC CMD_TAGS( CMD_TAG_CHAT, @@ -1712,7 +1713,8 @@ static struct cmd_t command_defs[] = "/otr answer ", "/otr policy manual|opportunistic|always []", "/otr log on|off|redact", - "/otr char ") + "/otr char ", + "/otr sendfile on|off") CMD_DESC( "Off The Record (OTR) commands to manage keys, and perform OTR encryption during chat sessions.") CMD_ARGS( @@ -1734,7 +1736,8 @@ static struct cmd_t command_defs[] = { "policy always ", "Set the OTR policy to always for a specific contact." }, { "log on|off", "Enable or disable plaintext logging of OTR encrypted messages." }, { "log redact", "Log OTR encrypted messages, but replace the contents with [redacted]. This is the default." }, - { "char ", "Set the character to be displayed next to OTR encrypted messages." }) + { "char ", "Set the character to be displayed next to OTR encrypted messages." }, + { "sendfile on|off", "Allow /sendfile to send unencrypted files while in an OTR session."}) CMD_EXAMPLES( "/otr log off", "/otr policy manual", @@ -2266,7 +2269,7 @@ static struct cmd_t command_defs[] = { "policy manual", "Set the global OMEMO policy to manual, OMEMO sessions must be started manually." }, { "policy automatic", "Set the global OMEMO policy to opportunistic, an OMEMO session will be attempted upon starting a conversation." }, { "policy always", "Set the global OMEMO policy to always, an error will be displayed if an OMEMO session cannot be initiated upon starting a conversation." }, - { "sendfile", "Allow /sendfile to send unencrypted files while in an OMEMO session."}, + { "sendfile on|off", "Allow /sendfile to send unencrypted files while in an OMEMO session."}, { "clear_device_list", "Clear your own device list on server side. Each client will reannounce itself when connected back."}) CMD_EXAMPLES( "/omemo gen", diff --git a/src/command/cmd_funcs.c b/src/command/cmd_funcs.c index e5c540c3..e93397cb 100644 --- a/src/command/cmd_funcs.c +++ b/src/command/cmd_funcs.c @@ -4819,7 +4819,7 @@ cmd_sendfile(ProfWin *window, const char *const command, gchar **args) if ((chatwin->is_omemo && !prefs_get_boolean(PREF_OMEMO_SENDFILE)) || (chatwin->pgp_send) - || (chatwin->is_otr)) { + || (chatwin->is_otr && !prefs_get_boolean(PREF_OTR_SENDFILE))) { cons_show_error("Uploading '%s' failed: Encrypted file uploads not yet implemented!", filename); win_println(window, THEME_ERROR, '-', "Sending encrypted files via http_upload is not possible yet."); free(filename); @@ -4829,7 +4829,8 @@ cmd_sendfile(ProfWin *window, const char *const command, gchar **args) } case WIN_PRIVATE: { - break; //we don't support encryption in private muc windows anyway + //we don't support encryption in private muc windows + break; } default: cons_show_error("Unsupported window for file transmission."); @@ -7809,6 +7810,19 @@ cmd_otr_answer(ProfWin *window, const char *const command, gchar **args) #endif } +gboolean +cmd_otr_sendfile(ProfWin *window, const char *const command, gchar **args) +{ +#ifdef HAVE_LIBOTR + _cmd_set_boolean_preference(args[1], command, "Sending unencrypted files in an OTR session via /sendfile", PREF_OTR_SENDFILE); + + return TRUE; +#else + cons_show("This version of Profanity has not been built with OTR support enabled"); + return TRUE; +#endif +} + gboolean cmd_command_list(ProfWin *window, const char *const command, gchar **args) { diff --git a/src/command/cmd_funcs.h b/src/command/cmd_funcs.h index 389c35de..58d99635 100644 --- a/src/command/cmd_funcs.h +++ b/src/command/cmd_funcs.h @@ -201,6 +201,7 @@ gboolean cmd_otr_untrust(ProfWin *window, const char *const command, gchar **arg gboolean cmd_otr_secret(ProfWin *window, const char *const command, gchar **args); gboolean cmd_otr_question(ProfWin *window, const char *const command, gchar **args); gboolean cmd_otr_answer(ProfWin *window, const char *const command, gchar **args); +gboolean cmd_otr_sendfile(ProfWin *window, const char *const command, gchar **args); gboolean cmd_wins(ProfWin *window, const char *const command, gchar **args); gboolean cmd_wins_unread(ProfWin *window, const char *const command, gchar **args); diff --git a/src/config/preferences.c b/src/config/preferences.c index 8a503291..085aa910 100644 --- a/src/config/preferences.c +++ b/src/config/preferences.c @@ -1790,6 +1790,7 @@ _get_group(preference_t pref) return PREF_GROUP_CONNECTION; case PREF_OTR_LOG: case PREF_OTR_POLICY: + case PREF_OTR_SENDFILE: return PREF_GROUP_OTR; case PREF_PGP_LOG: return PREF_GROUP_PGP; @@ -1916,6 +1917,8 @@ _get_key(preference_t pref) return "log"; case PREF_OTR_POLICY: return "policy"; + case PREF_OTR_SENDFILE: + return "sendfile"; case PREF_LOG_ROTATE: return "rotate"; case PREF_LOG_SHARED: diff --git a/src/config/preferences.h b/src/config/preferences.h index a373a701..d850df5c 100644 --- a/src/config/preferences.h +++ b/src/config/preferences.h @@ -135,6 +135,7 @@ typedef enum { PREF_LOG_SHARED, PREF_OTR_LOG, PREF_OTR_POLICY, + PREF_OTR_SENDFILE, PREF_RESOURCE_TITLE, PREF_RESOURCE_MESSAGE, PREF_INPBLOCK_DYNAMIC, diff --git a/src/ui/console.c b/src/ui/console.c index 6de8258f..4877725d 100644 --- a/src/ui/console.c +++ b/src/ui/console.c @@ -2070,6 +2070,12 @@ cons_show_otr_prefs(void) char ch = prefs_get_otr_char(); cons_show("OTR char (/otr char) : %c", ch); + if (prefs_get_boolean(PREF_OTR_SENDFILE)) { + cons_show("Allow sending unencrypted files in an OTR session via /sendfile (/otr sendfile): ON"); + } else { + cons_show("Allow sending unencrypted files in an OTR session via /sendfile (/otr sendfile): OFF"); + } + cons_alert(); } -- cgit 1.4.1-2-gfad0 From 7d596d8cef0c453ab2a4c57a7e5d51634e31af25 Mon Sep 17 00:00:00 2001 From: Michael Vetter Date: Mon, 17 Feb 2020 08:57:35 +0100 Subject: Make /sendfile in PGP session configurable `/pgp sendfile on` allows unencrypted file transfer in an PGP session. Regards https://github.com/profanity-im/profanity/pull/1270 --- src/command/cmd_ac.c | 13 +++++++++++++ src/command/cmd_defs.c | 6 ++++-- src/command/cmd_funcs.c | 7 ++++++- src/config/preferences.c | 3 +++ src/config/preferences.h | 1 + src/ui/console.c | 6 ++++++ 6 files changed, 33 insertions(+), 3 deletions(-) diff --git a/src/command/cmd_ac.c b/src/command/cmd_ac.c index 7d170d10..4d6c1d90 100644 --- a/src/command/cmd_ac.c +++ b/src/command/cmd_ac.c @@ -206,6 +206,7 @@ static Autocomplete inpblock_ac; static Autocomplete receipts_ac; static Autocomplete pgp_ac; static Autocomplete pgp_log_ac; +static Autocomplete pgp_sendfile_ac; static Autocomplete tls_ac; static Autocomplete titlebar_ac; static Autocomplete titlebar_show_ac; @@ -788,12 +789,17 @@ cmd_ac_init(void) autocomplete_add(pgp_ac, "end"); autocomplete_add(pgp_ac, "log"); autocomplete_add(pgp_ac, "char"); + autocomplete_add(pgp_ac, "sendfile"); pgp_log_ac = autocomplete_new(); autocomplete_add(pgp_log_ac, "on"); autocomplete_add(pgp_log_ac, "off"); autocomplete_add(pgp_log_ac, "redact"); + pgp_sendfile_ac = autocomplete_new(); + autocomplete_add(pgp_sendfile_ac, "on"); + autocomplete_add(pgp_sendfile_ac, "off"); + tls_ac = autocomplete_new(); autocomplete_add(tls_ac, "allow"); autocomplete_add(tls_ac, "always"); @@ -1229,6 +1235,7 @@ cmd_ac_reset(ProfWin *window) autocomplete_reset(receipts_ac); autocomplete_reset(pgp_ac); autocomplete_reset(pgp_log_ac); + autocomplete_reset(pgp_sendfile_ac); autocomplete_reset(tls_ac); autocomplete_reset(titlebar_ac); autocomplete_reset(titlebar_show_ac); @@ -1374,6 +1381,7 @@ cmd_ac_uninit(void) autocomplete_free(receipts_ac); autocomplete_free(pgp_ac); autocomplete_free(pgp_log_ac); + autocomplete_free(pgp_sendfile_ac); autocomplete_free(tls_ac); autocomplete_free(titlebar_ac); autocomplete_free(titlebar_show_ac); @@ -2274,6 +2282,11 @@ _pgp_autocomplete(ProfWin *window, const char *const input, gboolean previous) return found; } + found = autocomplete_param_with_ac(input, "/pgp sendfile", pgp_sendfile_ac, TRUE, previous); + if (found) { + return found; + } + #ifdef HAVE_LIBGPGME gboolean result; gchar **args = parse_args(input, 2, 3, &result); diff --git a/src/command/cmd_defs.c b/src/command/cmd_defs.c index 3897efc1..1e655a26 100644 --- a/src/command/cmd_defs.c +++ b/src/command/cmd_defs.c @@ -1657,7 +1657,8 @@ static struct cmd_t command_defs[] = "/pgp start []", "/pgp end", "/pgp log on|off|redact", - "/pgp char ") + "/pgp char ", + "/pgp sendfile on|off") CMD_DESC( "Open PGP commands to manage keys, and perform PGP encryption during chat sessions. " "See the /account command to set your own PGP key.") @@ -1670,7 +1671,8 @@ static struct cmd_t command_defs[] = { "end", "End PGP encrypted chat with the current recipient." }, { "log on|off", "Enable or disable plaintext logging of PGP encrypted messages." }, { "log redact", "Log PGP encrypted messages, but replace the contents with [redacted]. This is the default." }, - { "char ", "Set the character to be displayed next to PGP encrypted messages." }) + { "char ", "Set the character to be displayed next to PGP encrypted messages." }, + { "sendfile on|off", "Allow /sendfile to send unencrypted files while otherwise using PGP session."}) CMD_EXAMPLES( "/pgp log off", "/pgp setkey buddy@buddychat.org BA19CACE5A9592C5", diff --git a/src/command/cmd_funcs.c b/src/command/cmd_funcs.c index e93397cb..7bc8a027 100644 --- a/src/command/cmd_funcs.c +++ b/src/command/cmd_funcs.c @@ -4818,7 +4818,7 @@ cmd_sendfile(ProfWin *window, const char *const command, gchar **args) assert(chatwin->memcheck == PROFCHATWIN_MEMCHECK); if ((chatwin->is_omemo && !prefs_get_boolean(PREF_OMEMO_SENDFILE)) - || (chatwin->pgp_send) + || (chatwin->pgp_send && !prefs_get_boolean(PREF_PGP_SENDFILE)) || (chatwin->is_otr && !prefs_get_boolean(PREF_OTR_SENDFILE))) { cons_show_error("Uploading '%s' failed: Encrypted file uploads not yet implemented!", filename); win_println(window, THEME_ERROR, '-', "Sending encrypted files via http_upload is not possible yet."); @@ -7337,6 +7337,11 @@ cmd_pgp(ProfWin *window, const char *const command, gchar **args) return TRUE; } + if (g_strcmp0(args[0], "sendfile") == 0) { + _cmd_set_boolean_preference(args[1], command, "Sending unencrypted files using /sendfile while otherwise using PGP", PREF_PGP_SENDFILE); + return TRUE; + } + cons_bad_cmd_usage(command); return TRUE; #else diff --git a/src/config/preferences.c b/src/config/preferences.c index 085aa910..52ce5ca9 100644 --- a/src/config/preferences.c +++ b/src/config/preferences.c @@ -1793,6 +1793,7 @@ _get_group(preference_t pref) case PREF_OTR_SENDFILE: return PREF_GROUP_OTR; case PREF_PGP_LOG: + case PREF_PGP_SENDFILE: return PREF_GROUP_PGP; case PREF_BOOKMARK_INVITE: case PREF_ROOM_LIST_CACHE: @@ -2003,6 +2004,8 @@ _get_key(preference_t pref) return "titlebar.muc.title"; case PREF_PGP_LOG: return "log"; + case PREF_PGP_SENDFILE: + return "sendfile"; case PREF_TLS_CERTPATH: return "tls.certpath"; case PREF_TLS_SHOW: diff --git a/src/config/preferences.h b/src/config/preferences.h index d850df5c..4d04fd7d 100644 --- a/src/config/preferences.h +++ b/src/config/preferences.h @@ -142,6 +142,7 @@ typedef enum { PREF_ENC_WARN, PREF_TITLEBAR_MUC_TITLE, PREF_PGP_LOG, + PREF_PGP_SENDFILE, PREF_TLS_CERTPATH, PREF_TLS_SHOW, PREF_LASTACTIVITY, diff --git a/src/ui/console.c b/src/ui/console.c index 4877725d..c0abbc36 100644 --- a/src/ui/console.c +++ b/src/ui/console.c @@ -2098,6 +2098,12 @@ cons_show_pgp_prefs(void) char ch = prefs_get_pgp_char(); cons_show("PGP char (/pgp char) : %c", ch); + if (prefs_get_boolean(PREF_PGP_SENDFILE)) { + cons_show("Allow sending unencrypted files via /sendfile while otherwise using PGP (/pgp sendfile): ON"); + } else { + cons_show("Allow sending unencrypted files via /sendfile while otherwise using PGP (/pgp sendfile): OFF"); + } + cons_alert(); } -- cgit 1.4.1-2-gfad0 From 7955f4426281fb14523064f5359a2942ad5996e4 Mon Sep 17 00:00:00 2001 From: Michael Vetter Date: Mon, 17 Feb 2020 08:59:55 +0100 Subject: Mention how to enable unencrypted file transer Regards https://github.com/profanity-im/profanity/pull/1270 --- src/command/cmd_funcs.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/command/cmd_funcs.c b/src/command/cmd_funcs.c index 7bc8a027..4f617ffe 100644 --- a/src/command/cmd_funcs.c +++ b/src/command/cmd_funcs.c @@ -4805,7 +4805,7 @@ cmd_sendfile(ProfWin *window, const char *const command, gchar **args) // only omemo, no pgp/otr available in MUCs if (mucwin->is_omemo && !prefs_get_boolean(PREF_OMEMO_SENDFILE)) { - cons_show_error("Uploading '%s' failed: Encrypted file uploads not yet implemented!", filename); + cons_show_error("Uploading unencrypted files disabled. See /omemo sendfile, /otr sendfile, /pgp sendfile."); win_println(window, THEME_ERROR, '-', "Sending encrypted files via http_upload is not possible yet."); free(filename); return TRUE; @@ -4820,7 +4820,7 @@ cmd_sendfile(ProfWin *window, const char *const command, gchar **args) if ((chatwin->is_omemo && !prefs_get_boolean(PREF_OMEMO_SENDFILE)) || (chatwin->pgp_send && !prefs_get_boolean(PREF_PGP_SENDFILE)) || (chatwin->is_otr && !prefs_get_boolean(PREF_OTR_SENDFILE))) { - cons_show_error("Uploading '%s' failed: Encrypted file uploads not yet implemented!", filename); + cons_show_error("Uploading unencrypted files disabled. See /omemo sendfile, /otr sendfile, /pgp sendfile."); win_println(window, THEME_ERROR, '-', "Sending encrypted files via http_upload is not possible yet."); free(filename); return TRUE; -- cgit 1.4.1-2-gfad0