ui: add PGP settings in configuration
parent
c44056a9ff
commit
ef338f353d
24
meli.conf.5
24
meli.conf.5
|
@ -41,7 +41,7 @@ Newline means LF (0x0A) or CRLF (0x0D 0x0A).
|
|||
.Pp
|
||||
Refer to TOML documentation for valid TOML syntax.
|
||||
.Sh SECTIONS
|
||||
The top level sections of the config are accounts, shortcuts, notifications, pager, mailer.
|
||||
The top level sections of the config are accounts, shortcuts, notifications, pager, mailer, pgp.
|
||||
.Pp
|
||||
.Sy example configuration
|
||||
.Bd -literal
|
||||
|
@ -50,7 +50,8 @@ The top level sections of the config are accounts, shortcuts, notifications, pag
|
|||
root_folder = "/path/to/root/folder"
|
||||
format = "Maildir"
|
||||
index_style = "Compact"
|
||||
identity="Name <email@address.tld>"
|
||||
identity="email@address.tld"
|
||||
subscribed_folders = ["folder", "folder/Sent"]
|
||||
display_name = "Name"
|
||||
|
||||
# Set folder-specific settings
|
||||
|
@ -274,6 +275,25 @@ enable freedesktop-spec notifications. this is usually what you want
|
|||
.\" default value
|
||||
.Pq Em none
|
||||
.El
|
||||
.Sh PGP
|
||||
.Bl -tag -width "danger_accept_invalid_certs boolean" -offset -indent
|
||||
.It Cm auto_verify_signatures Ar boolean
|
||||
auto verify signed e-mail according to RFC3156
|
||||
.\" default value
|
||||
.Pq Em true
|
||||
.It Cm auto_sign Ar boolean
|
||||
(optional) always sign sent messages
|
||||
.\" default value
|
||||
.Pq Em false
|
||||
.It Cm key Ar String
|
||||
(optional) key to be used when signing/encrypting (not functional yet)
|
||||
.\" default value
|
||||
.Pq Em none
|
||||
.It Cm gpg_binary Ar String
|
||||
(optional) gpg binary name or file location to use
|
||||
.\" default value
|
||||
.Pq Em "gpg2"
|
||||
.El
|
||||
.Sh SEE ALSO
|
||||
.Xr meli 1
|
||||
.Sh CONFORMING TO
|
||||
|
|
|
@ -195,11 +195,20 @@ impl MailView {
|
|||
}
|
||||
} else if a.is_signed() {
|
||||
v.clear();
|
||||
if context.settings.pgp.auto_verify_signatures {
|
||||
match melib::signatures::verify_signature(a) {
|
||||
Ok((bytes, sig)) => {
|
||||
let bytes_file = create_temp_file(&bytes, None, None, true);
|
||||
let signature_file = create_temp_file(sig, None, None, true);
|
||||
if let Ok(gpg) = Command::new("gpg2")
|
||||
if let Ok(gpg) = Command::new(
|
||||
context
|
||||
.settings
|
||||
.pgp
|
||||
.gpg_binary
|
||||
.as_ref()
|
||||
.map(String::as_str)
|
||||
.unwrap_or("gpg2"),
|
||||
)
|
||||
.args(&[
|
||||
"--output",
|
||||
"-",
|
||||
|
@ -214,11 +223,18 @@ impl MailView {
|
|||
v.extend(gpg.wait_with_output().unwrap().stderr);
|
||||
} else {
|
||||
context.replies.push_back(UIEvent::Notification(
|
||||
Some(
|
||||
"Failed to find an application to verify PGP signature"
|
||||
Some(format!(
|
||||
"Failed to launch {} to verify PGP signature",
|
||||
context
|
||||
.settings
|
||||
.pgp
|
||||
.gpg_binary
|
||||
.as_ref()
|
||||
.map(String::as_str)
|
||||
.unwrap_or("gpg2"),
|
||||
)),
|
||||
"see meli.conf(5) for configuration setting pgp.gpg_binary"
|
||||
.to_string(),
|
||||
),
|
||||
String::new(),
|
||||
Some(NotificationType::ERROR),
|
||||
));
|
||||
return;
|
||||
|
@ -233,6 +249,7 @@ impl MailView {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
})),
|
||||
))
|
||||
.into_owned();
|
||||
|
|
|
@ -27,11 +27,13 @@ extern crate xdg;
|
|||
pub mod mailer;
|
||||
pub mod notifications;
|
||||
pub mod pager;
|
||||
pub mod pgp;
|
||||
pub mod shortcuts;
|
||||
|
||||
pub mod accounts;
|
||||
pub use self::accounts::Account;
|
||||
pub use self::mailer::*;
|
||||
pub use self::pgp::*;
|
||||
pub use self::shortcuts::*;
|
||||
|
||||
use self::default_vals::*;
|
||||
|
@ -272,6 +274,8 @@ struct FileSettings {
|
|||
#[serde(default)]
|
||||
shortcuts: Shortcuts,
|
||||
mailer: MailerSettings,
|
||||
#[serde(default)]
|
||||
pgp: PGPSettings,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Default)]
|
||||
|
@ -300,6 +304,7 @@ pub struct Settings {
|
|||
pub notifications: NotificationsSettings,
|
||||
pub shortcuts: Shortcuts,
|
||||
pub mailer: MailerSettings,
|
||||
pub pgp: PGPSettings,
|
||||
}
|
||||
|
||||
impl FileSettings {
|
||||
|
@ -387,6 +392,7 @@ impl Settings {
|
|||
notifications: fs.notifications,
|
||||
shortcuts: fs.shortcuts,
|
||||
mailer: fs.mailer,
|
||||
pgp: fs.pgp,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,53 @@
|
|||
/*
|
||||
* meli - configuration module.
|
||||
*
|
||||
* Copyright 2019 Manos Pitsidianakis
|
||||
*
|
||||
* This file is part of meli.
|
||||
*
|
||||
* meli is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* meli is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with meli. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
use super::default_vals::*;
|
||||
|
||||
/// Settings for digital signing and encryption
|
||||
#[derive(Debug, Deserialize, Clone, Serialize)]
|
||||
pub struct PGPSettings {
|
||||
/// auto verify signed e-mail according to RFC3156
|
||||
#[serde(default = "true_val")]
|
||||
pub auto_verify_signatures: bool,
|
||||
|
||||
/// always sign sent messages
|
||||
#[serde(default = "false_val")]
|
||||
pub auto_sign: bool,
|
||||
|
||||
// https://tools.ietf.org/html/rfc4880#section-12.2
|
||||
#[serde(default = "none")]
|
||||
pub key: Option<String>,
|
||||
|
||||
/// gpg binary name or file location to use
|
||||
#[serde(default)]
|
||||
pub gpg_binary: Option<String>,
|
||||
}
|
||||
|
||||
impl Default for PGPSettings {
|
||||
fn default() -> Self {
|
||||
PGPSettings {
|
||||
auto_verify_signatures: true,
|
||||
auto_sign: false,
|
||||
key: None,
|
||||
gpg_binary: None,
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue