1
0
mirror of https://github.com/profanity-im/profanity.git synced 2024-11-03 19:37:16 -05:00

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
This commit is contained in:
Michael Vetter 2020-02-17 08:57:35 +01:00
parent 86bcadcbe3
commit 7d596d8cef
6 changed files with 33 additions and 3 deletions

View File

@ -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);

View File

@ -1657,7 +1657,8 @@ static struct cmd_t command_defs[] =
"/pgp start [<contact>]",
"/pgp end",
"/pgp log on|off|redact",
"/pgp char <char>")
"/pgp char <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 <char>", "Set the character to be displayed next to PGP encrypted messages." })
{ "char <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",

View File

@ -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

View File

@ -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:

View File

@ -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,

View File

@ -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();
}