NeoMutt  2020-06-26-250-g349c94
Teaching an old dog new tricks
DOXYGEN
config.c
Go to the documentation of this file.
1 
29 #include "config.h"
30 #include <stddef.h>
31 #include <config/lib.h>
32 #include <stdbool.h>
33 #include "private.h"
34 #include "init.h"
35 
36 // clang-format off
37 #ifdef CRYPT_BACKEND_GPGME
39 #endif
52 char * C_PgpSignAs;
55 char * C_SmimeSignAs;
60 unsigned char C_PgpEncryptSelf;
61 unsigned char C_PgpMimeAuto;
65 unsigned char C_SmimeEncryptSelf;
67 #ifdef CRYPT_BACKEND_GPGME
69 #endif
73 struct Regex * C_PgpGoodSign;
100 char * C_SmimeKeys;
108 unsigned char C_CryptVerifySig;
109 // clang-format on
110 
111 struct ConfigDef NcryptVars[] = {
112  // clang-format off
113  { "crypt_confirmhook", DT_BOOL, &C_CryptConfirmhook, true, 0, NULL,
114  "Prompt the user to confirm keys before use"
115  },
116  { "crypt_opportunistic_encrypt", DT_BOOL, &C_CryptOpportunisticEncrypt, false, 0, NULL,
117  "Enable encryption when the recipient's key is available"
118  },
119  { "crypt_opportunistic_encrypt_strong_keys", DT_BOOL, &C_CryptOpportunisticEncryptStrongKeys, false, 0, NULL,
120  "Enable encryption only when strong a key is available"
121  },
122  { "crypt_protected_headers_read", DT_BOOL, &C_CryptProtectedHeadersRead, true, 0, NULL,
123  "Display protected headers (Memory Hole) in the pager"
124  },
125  { "crypt_protected_headers_subject", DT_STRING, &C_CryptProtectedHeadersSubject, IP "...", 0, NULL,
126  "Use this as the subject for encrypted emails"
127  },
128  { "crypt_protected_headers_write", DT_BOOL, &C_CryptProtectedHeadersWrite, false, 0, NULL,
129  "Generate protected header (Memory Hole) for signed and encrypted emails"
130  },
131  { "crypt_timestamp", DT_BOOL, &C_CryptTimestamp, true, 0, NULL,
132  "Add a timestamp to PGP or SMIME output to prevent spoofing"
133  },
134 #ifdef CRYPT_BACKEND_GPGME
135  { "crypt_use_gpgme", DT_BOOL, &C_CryptUseGpgme, true, 0, NULL,
136  "Use GPGME crypto backend"
137  },
138  { "crypt_use_pka", DT_BOOL, &C_CryptUsePka, false, 0, NULL,
139  "Use GPGME to use PKA (lookup PGP keys using DNS)"
140  },
141 #endif
142  { "envelope_from_address", DT_ADDRESS, &C_EnvelopeFromAddress, 0, 0, NULL,
143  "Manually set the sender for outgoing messages"
144  },
145  { "pgp_autoinline", DT_BOOL, &C_PgpAutoinline, false, 0, NULL,
146  "Use old-style inline PGP messages (not recommended)"
147  },
148 #ifdef CRYPT_BACKEND_CLASSIC_PGP
149  { "pgp_check_exit", DT_BOOL, &C_PgpCheckExit, true, 0, NULL,
150  "Check the exit code of PGP subprocess"
151  },
152  { "pgp_check_gpg_decrypt_status_fd", DT_BOOL, &C_PgpCheckGpgDecryptStatusFd, true, 0, NULL,
153  "File descriptor used for status info"
154  },
155  { "pgp_clearsign_command", DT_STRING|DT_COMMAND, &C_PgpClearsignCommand, 0, 0, NULL,
156  "(pgp) External command to inline-sign a message"
157  },
158  { "pgp_decode_command", DT_STRING|DT_COMMAND, &C_PgpDecodeCommand, 0, 0, NULL,
159  "(pgp) External command to decode a PGP attachment"
160  },
161  { "pgp_decrypt_command", DT_STRING|DT_COMMAND, &C_PgpDecryptCommand, 0, 0, NULL,
162  "(pgp) External command to decrypt a PGP message"
163  },
164  { "pgp_decryption_okay", DT_REGEX, &C_PgpDecryptionOkay, 0, 0, NULL,
165  "Text indicating a successful decryption"
166  },
167 #endif
168  { "pgp_default_key", DT_STRING, &C_PgpDefaultKey, 0, 0, NULL,
169  "Default key to use for PGP operations"
170  },
171 #ifdef CRYPT_BACKEND_CLASSIC_PGP
172  { "pgp_encrypt_only_command", DT_STRING|DT_COMMAND, &C_PgpEncryptOnlyCommand, 0, 0, NULL,
173  "(pgp) External command to encrypt, but not sign a message"
174  },
175  { "pgp_encrypt_sign_command", DT_STRING|DT_COMMAND, &C_PgpEncryptSignCommand, 0, 0, NULL,
176  "(pgp) External command to encrypt and sign a message"
177  },
178 #endif
179  { "pgp_entry_format", DT_STRING|DT_NOT_EMPTY, &C_PgpEntryFormat, IP "%4n %t%f %4l/0x%k %-4a %2c %u", 0, NULL,
180  "printf-like format string for the PGP key selection menu"
181  },
182 #ifdef CRYPT_BACKEND_CLASSIC_PGP
183  { "pgp_export_command", DT_STRING|DT_COMMAND, &C_PgpExportCommand, 0, 0, NULL,
184  "(pgp) External command to export a public key from the user's keyring"
185  },
186  { "pgp_getkeys_command", DT_STRING|DT_COMMAND, &C_PgpGetkeysCommand, 0, 0, NULL,
187  "(pgp) External command to download a key for an email address"
188  },
189  { "pgp_good_sign", DT_REGEX, &C_PgpGoodSign, 0, 0, NULL,
190  "Text indicating a good signature"
191  },
192 #endif
193  { "pgp_ignore_subkeys", DT_BOOL, &C_PgpIgnoreSubkeys, true, 0, NULL,
194  "Only use the principal PGP key"
195  },
196 #ifdef CRYPT_BACKEND_CLASSIC_PGP
197  { "pgp_import_command", DT_STRING|DT_COMMAND, &C_PgpImportCommand, 0, 0, NULL,
198  "(pgp) External command to import a key into the user's keyring"
199  },
200  { "pgp_list_pubring_command", DT_STRING|DT_COMMAND, &C_PgpListPubringCommand, 0, 0, NULL,
201  "(pgp) External command to list the public keys in a user's keyring"
202  },
203  { "pgp_list_secring_command", DT_STRING|DT_COMMAND, &C_PgpListSecringCommand, 0, 0, NULL,
204  "(pgp) External command to list the private keys in a user's keyring"
205  },
206 #endif
207  { "pgp_long_ids", DT_BOOL, &C_PgpLongIds, true, 0, NULL,
208  "Display long PGP key IDs to the user"
209  },
210  { "pgp_mime_auto", DT_QUAD, &C_PgpMimeAuto, MUTT_ASKYES, 0, NULL,
211  "Prompt the user to use MIME if inline PGP fails"
212  },
213  { "pgp_retainable_sigs", DT_BOOL, &C_PgpRetainableSigs, false, 0, NULL,
214  "Create nested multipart/signed or encrypted messages"
215  },
216  { "pgp_self_encrypt", DT_BOOL, &C_PgpSelfEncrypt, true, 0, NULL,
217  "Encrypted messages will also be encrypted to C_PgpDefaultKey too"
218  },
219  { "pgp_show_unusable", DT_BOOL, &C_PgpShowUnusable, true, 0, NULL,
220  "Show non-usable keys in the key selection"
221  },
222  { "pgp_sign_as", DT_STRING, &C_PgpSignAs, 0, 0, NULL,
223  "Use this alternative key for signing messages"
224  },
225 #ifdef CRYPT_BACKEND_CLASSIC_PGP
226  { "pgp_sign_command", DT_STRING|DT_COMMAND, &C_PgpSignCommand, 0, 0, NULL,
227  "(pgp) External command to create a detached PGP signature"
228  },
229 #endif
230  { "pgp_sort_keys", DT_SORT|DT_SORT_KEYS, &C_PgpSortKeys, SORT_ADDRESS, 0, NULL,
231  "Sort order for PGP keys"
232  },
233  { "pgp_strict_enc", DT_BOOL, &C_PgpStrictEnc, true, 0, NULL,
234  "Encode PGP signed messages with quoted-printable (don't unset)"
235  },
236 #ifdef CRYPT_BACKEND_CLASSIC_PGP
237  { "pgp_timeout", DT_LONG|DT_NOT_NEGATIVE, &C_PgpTimeout, 300, 0, NULL,
238  "Time in seconds to cache a passphrase"
239  },
240  { "pgp_use_gpg_agent", DT_BOOL, &C_PgpUseGpgAgent, true, 0, NULL,
241  "Use a PGP agent for caching passwords"
242  },
243  { "pgp_verify_command", DT_STRING|DT_COMMAND, &C_PgpVerifyCommand, 0, 0, NULL,
244  "(pgp) External command to verify PGP signatures"
245  },
246  { "pgp_verify_key_command", DT_STRING|DT_COMMAND, &C_PgpVerifyKeyCommand, 0, 0, NULL,
247  "(pgp) External command to verify key information"
248  },
249 #endif
250 #ifdef CRYPT_BACKEND_CLASSIC_SMIME
251  { "smime_ask_cert_label", DT_BOOL, &C_SmimeAskCertLabel, true, 0, NULL,
252  "Prompt the user for a label for SMIME certificates"
253  },
254  { "smime_ca_location", DT_PATH|DT_PATH_FILE, &C_SmimeCaLocation, 0, 0, NULL,
255  "File containing trusted certificates"
256  },
257  { "smime_certificates", DT_PATH|DT_PATH_DIR, &C_SmimeCertificates, 0, 0, NULL,
258  "File containing user's public certificates"
259  },
260  { "smime_decrypt_command", DT_STRING|DT_COMMAND, &C_SmimeDecryptCommand, 0, 0, NULL,
261  "(smime) External command to decrypt an SMIME message"
262  },
263  { "smime_decrypt_use_default_key", DT_BOOL, &C_SmimeDecryptUseDefaultKey, true, 0, NULL,
264  "Use the default key for decryption"
265  },
266 #endif
267  { "smime_default_key", DT_STRING, &C_SmimeDefaultKey, 0, 0, NULL,
268  "Default key for SMIME operations"
269  },
270 #ifdef CRYPT_BACKEND_CLASSIC_SMIME
271  { "smime_encrypt_command", DT_STRING|DT_COMMAND, &C_SmimeEncryptCommand, 0, 0, NULL,
272  "(smime) External command to encrypt a message"
273  },
274 #endif
275  { "smime_encrypt_with", DT_STRING, &C_SmimeEncryptWith, IP "aes256", 0, NULL,
276  "Algorithm for encryption"
277  },
278 #ifdef CRYPT_BACKEND_CLASSIC_SMIME
279  { "smime_get_cert_command", DT_STRING|DT_COMMAND, &C_SmimeGetCertCommand, 0, 0, NULL,
280  "(smime) External command to extract a certificate from a message"
281  },
282  { "smime_get_cert_email_command", DT_STRING|DT_COMMAND, &C_SmimeGetCertEmailCommand, 0, 0, NULL,
283  "(smime) External command to get a certificate for an email"
284  },
285  { "smime_get_signer_cert_command", DT_STRING|DT_COMMAND, &C_SmimeGetSignerCertCommand, 0, 0, NULL,
286  "(smime) External command to extract a certificate from an email"
287  },
288  { "smime_import_cert_command", DT_STRING|DT_COMMAND, &C_SmimeImportCertCommand, 0, 0, NULL,
289  "(smime) External command to import a certificate"
290  },
291 #endif
292 #ifdef CRYPT_BACKEND_CLASSIC_SMIME
293  { "smime_keys", DT_PATH|DT_PATH_DIR, &C_SmimeKeys, 0, 0, NULL,
294  "File containing user's private certificates"
295  },
296  { "smime_pk7out_command", DT_STRING|DT_COMMAND, &C_SmimePk7outCommand, 0, 0, NULL,
297  "(smime) External command to extract a public certificate"
298  },
299 #endif
300  { "smime_self_encrypt", DT_BOOL, &C_SmimeSelfEncrypt, true, 0, NULL,
301  "Encrypted messages will also be encrypt to C_SmimeDefaultKey too"
302  },
303  { "smime_sign_as", DT_STRING, &C_SmimeSignAs, 0, 0, NULL,
304  "Use this alternative key for signing messages"
305  },
306 #ifdef CRYPT_BACKEND_CLASSIC_SMIME
307  { "smime_sign_command", DT_STRING|DT_COMMAND, &C_SmimeSignCommand, 0, 0, NULL,
308  "(smime) External command to sign a message"
309  },
310  { "smime_sign_digest_alg", DT_STRING, &C_SmimeSignDigestAlg, IP "sha256", 0, NULL,
311  "Digest algorithm"
312  },
313  { "smime_timeout", DT_NUMBER|DT_NOT_NEGATIVE, &C_SmimeTimeout, 300, 0, NULL,
314  "Time in seconds to cache a passphrase"
315  },
316  { "smime_verify_command", DT_STRING|DT_COMMAND, &C_SmimeVerifyCommand, 0, 0, NULL,
317  "(smime) External command to verify a signed message"
318  },
319  { "smime_verify_opaque_command", DT_STRING|DT_COMMAND, &C_SmimeVerifyOpaqueCommand, 0, 0, NULL,
320  "(smime) External command to verify a signature"
321  },
322 #endif
323  { "smime_is_default", DT_BOOL, &C_SmimeIsDefault, false, 0, NULL,
324  "Use SMIME rather than PGP by default"
325  },
326  { "pgp_auto_decode", DT_BOOL, &C_PgpAutoDecode, false, 0, NULL,
327  "Automatically decrypt PGP messages"
328  },
329  { "crypt_verify_sig", DT_QUAD, &C_CryptVerifySig, MUTT_YES, 0, NULL,
330  "Verify PGP or SMIME signatures"
331  },
332  { "crypt_protected_headers_save", DT_BOOL, &C_CryptProtectedHeadersSave, false, 0, NULL,
333  "Save the cleartext Subject with the headers"
334  },
335 
336  { "pgp_create_traditional", DT_SYNONYM, NULL, IP "pgp_autoinline", },
337  { "pgp_self_encrypt_as", DT_SYNONYM, NULL, IP "pgp_default_key", },
338  { "pgp_verify_sig", DT_SYNONYM, NULL, IP "crypt_verify_sig", },
339  { "smime_self_encrypt_as", DT_SYNONYM, NULL, IP "smime_default_key", },
340 
341  { "pgp_encrypt_self", DT_DEPRECATED|DT_QUAD, &C_PgpEncryptSelf, MUTT_NO },
342  { "smime_encrypt_self", DT_DEPRECATED|DT_QUAD, &C_SmimeEncryptSelf, MUTT_NO },
343 
344  { NULL, 0, NULL, 0, 0, NULL, NULL },
345  // clang-format on
346 };
347 
352 {
353  return cs_register_variables(cs, NcryptVars, 0);
354 }
char * C_SmimeVerifyOpaqueCommand
Config: (smime) External command to verify a signature.
Definition: config.c:106
bool C_PgpUseGpgAgent
Config: Use a PGP agent for caching passwords.
Definition: config.c:75
char * C_SmimeEncryptCommand
Config: (smime) External command to encrypt a message.
Definition: config.c:95
Container for lots of config items.
Definition: set.h:227
unsigned char C_CryptVerifySig
Config: Verify PGP or SMIME signatures.
Definition: config.c:108
#define DT_LONG
a number (long)
Definition: types.h:33
#define DT_NOT_EMPTY
Empty strings are not allowed.
Definition: types.h:46
Config/command parsing.
char * C_SmimeDecryptCommand
Config: (smime) External command to decrypt an SMIME message.
Definition: config.c:93
char * C_SmimePk7outCommand
Config: (smime) External command to extract a public certificate.
Definition: config.c:101
User answered &#39;Yes&#39;, or assume &#39;Yes&#39;.
Definition: quad.h:40
#define DT_REGEX
regular expressions
Definition: types.h:38
char * C_SmimeGetSignerCertCommand
Config: (smime) External command to extract a certificate from an email.
Definition: config.c:98
bool C_CryptProtectedHeadersRead
Config: Display protected headers (Memory Hole) in the pager.
Definition: config.c:43
#define DT_SORT
sorting methods
Definition: types.h:40
Sort by email address.
Definition: sort2.h:61
An email address.
Definition: address.h:34
#define DT_NOT_NEGATIVE
Negative numbers are not allowed.
Definition: types.h:47
char * C_PgpGetkeysCommand
Config: (pgp) External command to download a key for an email address.
Definition: config.c:82
long C_SmimeTimeout
Config: Time in seconds to cache a passphrase.
Definition: config.c:104
unsigned char C_PgpMimeAuto
Config: Prompt the user to use MIME if inline PGP fails.
Definition: config.c:61
bool C_CryptUseGpgme
Config: Use GPGME crypto backend.
Definition: config.c:68
bool C_CryptOpportunisticEncryptStrongKeys
Config: Enable encryption only when strong a key is available.
Definition: config.c:42
Config item definition.
Definition: set.h:61
Shared constants/structs that are private to libconn.
unsigned char C_SmimeEncryptSelf
Definition: config.c:65
#define DT_QUAD
quad-option (no/yes/ask-no/ask-yes)
Definition: types.h:37
char * C_PgpDecodeCommand
Config: (pgp) External command to decode a PGP attachment.
Definition: config.c:77
Convenience wrapper for the config headers.
#define DT_PATH_DIR
Path is a directory.
Definition: types.h:53
char * C_SmimeVerifyCommand
Config: (smime) External command to verify a signed message.
Definition: config.c:105
char * C_SmimeKeys
Config: File containing user&#39;s private certificates.
Definition: config.c:100
Ask the user, defaulting to &#39;Yes&#39;.
Definition: quad.h:42
char * C_PgpEncryptSignCommand
Config: (pgp) External command to encrypt and sign a message.
Definition: config.c:80
bool C_CryptOpportunisticEncrypt
Config: Enable encryption when the recipient&#39;s key is available.
Definition: config.c:41
char * C_PgpEncryptOnlyCommand
Config: (pgp) External command to encrypt, but not sign a message.
Definition: config.c:79
char * C_PgpSignAs
Config: Use this alternative key for signing messages.
Definition: config.c:52
bool C_CryptTimestamp
Config: Add a timestamp to PGP or SMIME output to prevent spoofing.
Definition: config.c:59
bool C_PgpAutoDecode
Config: Automatically decrypt PGP messages.
Definition: config.c:107
char * C_PgpDefaultKey
Config: Default key to use for PGP operations.
Definition: config.c:51
bool C_SmimeSelfEncrypt
Config: Encrypted messages will also be encrypt to C_SmimeDefaultKey too.
Definition: config.c:66
bool C_PgpShowUnusable
Config: Show non-usable keys in the key selection.
Definition: config.c:49
char * C_PgpClearsignCommand
Config: (pgp) External command to inline-sign a message.
Definition: config.c:76
#define DT_PATH_FILE
Path is a file.
Definition: types.h:54
char * C_PgpDecryptCommand
Config: (pgp) External command to decrypt a PGP message.
Definition: config.c:78
bool C_CryptUsePka
Config: Use GPGME to use PKA (lookup PGP keys using DNS)
Definition: config.c:38
#define DT_ADDRESS
e-mail address
Definition: types.h:29
#define DT_STRING
a string
Definition: types.h:41
bool C_SmimeIsDefault
Config: Use SMIME rather than PGP by default.
Definition: config.c:46
#define DT_PATH
a path to a file/directory
Definition: types.h:36
char * C_SmimeEncryptWith
Config: Algorithm for encryption.
Definition: config.c:56
User answered &#39;No&#39;, or assume &#39;No&#39;.
Definition: quad.h:39
#define DT_DEPRECATED
Config item shouldn&#39;t be used any more.
Definition: types.h:79
bool C_SmimeAskCertLabel
Config: Prompt the user for a label for SMIME certificates.
Definition: config.c:90
char * C_SmimeCertificates
Config: File containing user&#39;s public certificates.
Definition: config.c:92
char * C_SmimeImportCertCommand
Config: (smime) External command to import a certificate.
Definition: config.c:99
char * C_SmimeCaLocation
Config: File containing trusted certificates.
Definition: config.c:91
#define DT_COMMAND
A command.
Definition: types.h:50
char * C_PgpSignCommand
Config: (pgp) External command to create a detached PGP signature.
Definition: config.c:86
bool C_PgpLongIds
Config: Display long PGP key IDs to the user.
Definition: config.c:48
bool C_PgpRetainableSigs
Config: Create nested multipart/signed or encrypted messages.
Definition: config.c:62
bool config_init_ncrypt(struct ConfigSet *cs)
Register ncrypt config variables.
Definition: config.c:351
bool C_PgpStrictEnc
Config: Encode PGP signed messages with quoted-printable (don&#39;t unset)
Definition: config.c:64
char * C_SmimeDefaultKey
Config: Default key for SMIME operations.
Definition: config.c:54
short C_PgpSortKeys
Config: Sort order for PGP keys.
Definition: config.c:89
char * C_SmimeSignAs
Config: Use this alternative key for signing messages.
Definition: config.c:55
char * C_PgpListPubringCommand
Config: (pgp) External command to list the public keys in a user&#39;s keyring.
Definition: config.c:84
char * C_SmimeGetCertCommand
Config: (smime) External command to extract a certificate from a message.
Definition: config.c:96
#define DT_SYNONYM
synonym for another variable
Definition: types.h:42
char * C_PgpEntryFormat
Config: printf-like format string for the PGP key selection menu.
Definition: config.c:53
unsigned char C_PgpEncryptSelf
Definition: config.c:60
Cached regular expression.
Definition: regex3.h:88
bool C_PgpCheckExit
Config: Check the exit code of PGP subprocess.
Definition: config.c:70
bool C_PgpAutoinline
Config: Use old-style inline PGP messages (not recommended)
Definition: config.c:50
char * C_SmimeSignDigestAlg
Config: Digest algorithm.
Definition: config.c:103
bool C_CryptConfirmhook
Config: Prompt the user to confirm keys before use.
Definition: config.c:40
char * C_SmimeGetCertEmailCommand
Config: (smime) External command to get a certificate for an email.
Definition: config.c:97
#define IP
Definition: set.h:54
long C_PgpTimeout
Config: Time in seconds to cache a passphrase.
Definition: config.c:74
bool C_PgpSelfEncrypt
Config: Encrypted messages will also be encrypted to C_PgpDefaultKey too.
Definition: config.c:63
char * C_PgpExportCommand
Config: (pgp) External command to export a public key from the user&#39;s keyring.
Definition: config.c:81
char * C_SmimeSignCommand
Config: (smime) External command to sign a message.
Definition: config.c:102
bool cs_register_variables(const struct ConfigSet *cs, struct ConfigDef vars[], int flags)
Register a set of config items.
Definition: set.c:287
struct Regex * C_PgpGoodSign
Config: Text indicating a good signature.
Definition: config.c:73
bool C_PgpIgnoreSubkeys
Config: Only use the principal PGP key.
Definition: config.c:47
struct Regex * C_PgpDecryptionOkay
Config: Text indicating a successful decryption.
Definition: config.c:72
bool C_CryptProtectedHeadersSave
Config: Save the cleartext Subject with the headers.
Definition: config.c:44
char * C_PgpImportCommand
Config: (pgp) External command to import a key into the user&#39;s keyring.
Definition: config.c:83
bool C_SmimeDecryptUseDefaultKey
Config: Use the default key for decryption.
Definition: config.c:94
char * C_PgpListSecringCommand
Config: (pgp) External command to list the private keys in a user&#39;s keyring.
Definition: config.c:85
#define DT_NUMBER
a number
Definition: types.h:35
#define DT_BOOL
boolean option
Definition: types.h:30
char * C_PgpVerifyKeyCommand
Config: (pgp) External command to verify key information.
Definition: config.c:88
bool C_PgpCheckGpgDecryptStatusFd
Config: File descriptor used for status info.
Definition: config.c:71
struct Address * C_EnvelopeFromAddress
Config: Manually set the sender for outgoing messages.
Definition: config.c:58
char * C_CryptProtectedHeadersSubject
Config: Use this as the subject for encrypted emails.
Definition: config.c:57
char * C_PgpVerifyCommand
Config: (pgp) External command to verify PGP signatures.
Definition: config.c:87
bool C_CryptProtectedHeadersWrite
Config: Generate protected header (Memory Hole) for signed and encrypted emails.
Definition: config.c:45
#define DT_SORT_KEYS
Sort id for SortKeyMethods.
Definition: sort2.h:41