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
|
.Pp
|
||||||
Refer to TOML documentation for valid TOML syntax.
|
Refer to TOML documentation for valid TOML syntax.
|
||||||
.Sh SECTIONS
|
.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
|
.Pp
|
||||||
.Sy example configuration
|
.Sy example configuration
|
||||||
.Bd -literal
|
.Bd -literal
|
||||||
|
@ -50,7 +50,8 @@ The top level sections of the config are accounts, shortcuts, notifications, pag
|
||||||
root_folder = "/path/to/root/folder"
|
root_folder = "/path/to/root/folder"
|
||||||
format = "Maildir"
|
format = "Maildir"
|
||||||
index_style = "Compact"
|
index_style = "Compact"
|
||||||
identity="Name <email@address.tld>"
|
identity="email@address.tld"
|
||||||
|
subscribed_folders = ["folder", "folder/Sent"]
|
||||||
display_name = "Name"
|
display_name = "Name"
|
||||||
|
|
||||||
# Set folder-specific settings
|
# Set folder-specific settings
|
||||||
|
@ -274,6 +275,25 @@ enable freedesktop-spec notifications. this is usually what you want
|
||||||
.\" default value
|
.\" default value
|
||||||
.Pq Em none
|
.Pq Em none
|
||||||
.El
|
.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
|
.Sh SEE ALSO
|
||||||
.Xr meli 1
|
.Xr meli 1
|
||||||
.Sh CONFORMING TO
|
.Sh CONFORMING TO
|
||||||
|
|
|
@ -195,11 +195,20 @@ impl MailView {
|
||||||
}
|
}
|
||||||
} else if a.is_signed() {
|
} else if a.is_signed() {
|
||||||
v.clear();
|
v.clear();
|
||||||
match melib::signatures::verify_signature(a) {
|
if context.settings.pgp.auto_verify_signatures {
|
||||||
Ok((bytes, sig)) => {
|
match melib::signatures::verify_signature(a) {
|
||||||
let bytes_file = create_temp_file(&bytes, None, None, true);
|
Ok((bytes, sig)) => {
|
||||||
let signature_file = create_temp_file(sig, None, None, true);
|
let bytes_file = create_temp_file(&bytes, None, None, true);
|
||||||
if let Ok(gpg) = Command::new("gpg2")
|
let signature_file = create_temp_file(sig, None, None, true);
|
||||||
|
if let Ok(gpg) = Command::new(
|
||||||
|
context
|
||||||
|
.settings
|
||||||
|
.pgp
|
||||||
|
.gpg_binary
|
||||||
|
.as_ref()
|
||||||
|
.map(String::as_str)
|
||||||
|
.unwrap_or("gpg2"),
|
||||||
|
)
|
||||||
.args(&[
|
.args(&[
|
||||||
"--output",
|
"--output",
|
||||||
"-",
|
"-",
|
||||||
|
@ -210,27 +219,35 @@ impl MailView {
|
||||||
.stdin(Stdio::piped())
|
.stdin(Stdio::piped())
|
||||||
.stderr(Stdio::piped())
|
.stderr(Stdio::piped())
|
||||||
.spawn()
|
.spawn()
|
||||||
{
|
{
|
||||||
v.extend(gpg.wait_with_output().unwrap().stderr);
|
v.extend(gpg.wait_with_output().unwrap().stderr);
|
||||||
} else {
|
} else {
|
||||||
context.replies.push_back(UIEvent::Notification(
|
context.replies.push_back(UIEvent::Notification(
|
||||||
Some(
|
Some(format!(
|
||||||
"Failed to find an application to verify PGP signature"
|
"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(),
|
.to_string(),
|
||||||
),
|
Some(NotificationType::ERROR),
|
||||||
|
));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Err(e) => {
|
||||||
|
context.replies.push_back(UIEvent::Notification(
|
||||||
|
Some(e.to_string()),
|
||||||
String::new(),
|
String::new(),
|
||||||
Some(NotificationType::ERROR),
|
Some(NotificationType::ERROR),
|
||||||
));
|
));
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Err(e) => {
|
|
||||||
context.replies.push_back(UIEvent::Notification(
|
|
||||||
Some(e.to_string()),
|
|
||||||
String::new(),
|
|
||||||
Some(NotificationType::ERROR),
|
|
||||||
));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})),
|
})),
|
||||||
|
|
|
@ -27,11 +27,13 @@ extern crate xdg;
|
||||||
pub mod mailer;
|
pub mod mailer;
|
||||||
pub mod notifications;
|
pub mod notifications;
|
||||||
pub mod pager;
|
pub mod pager;
|
||||||
|
pub mod pgp;
|
||||||
pub mod shortcuts;
|
pub mod shortcuts;
|
||||||
|
|
||||||
pub mod accounts;
|
pub mod accounts;
|
||||||
pub use self::accounts::Account;
|
pub use self::accounts::Account;
|
||||||
pub use self::mailer::*;
|
pub use self::mailer::*;
|
||||||
|
pub use self::pgp::*;
|
||||||
pub use self::shortcuts::*;
|
pub use self::shortcuts::*;
|
||||||
|
|
||||||
use self::default_vals::*;
|
use self::default_vals::*;
|
||||||
|
@ -272,6 +274,8 @@ struct FileSettings {
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
shortcuts: Shortcuts,
|
shortcuts: Shortcuts,
|
||||||
mailer: MailerSettings,
|
mailer: MailerSettings,
|
||||||
|
#[serde(default)]
|
||||||
|
pgp: PGPSettings,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Default)]
|
#[derive(Debug, Clone, Default)]
|
||||||
|
@ -300,6 +304,7 @@ pub struct Settings {
|
||||||
pub notifications: NotificationsSettings,
|
pub notifications: NotificationsSettings,
|
||||||
pub shortcuts: Shortcuts,
|
pub shortcuts: Shortcuts,
|
||||||
pub mailer: MailerSettings,
|
pub mailer: MailerSettings,
|
||||||
|
pub pgp: PGPSettings,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl FileSettings {
|
impl FileSettings {
|
||||||
|
@ -387,6 +392,7 @@ impl Settings {
|
||||||
notifications: fs.notifications,
|
notifications: fs.notifications,
|
||||||
shortcuts: fs.shortcuts,
|
shortcuts: fs.shortcuts,
|
||||||
mailer: fs.mailer,
|
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