NeoMutt  2025-12-11-596-g7cc1dd
Teaching an old dog new tricks
DOXYGEN
Loading...
Searching...
No Matches
expando_smime.c
Go to the documentation of this file.
1
22
28
29#include <stdbool.h>
30#include <stdio.h>
31#include <sys/stat.h>
32#include "mutt/lib.h"
33#include "config/lib.h"
34#include "core/lib.h"
35#include "expando_smime.h"
36#include "expando/lib.h"
37#include "muttlib.h"
38#include "smime.h"
39
43static void smime_command_algorithm(const struct ExpandoNode *node, void *data,
44 MuttFormatFlags flags, struct Buffer *buf)
45{
46 const struct SmimeCommandContext *cctx = data;
47
48 const char *s = cctx->cryptalg;
49 buf_strcpy(buf, s);
50}
51
55static void smime_command_certificate_ids(const struct ExpandoNode *node, void *data,
56 MuttFormatFlags flags, struct Buffer *buf)
57{
58 const struct SmimeCommandContext *cctx = data;
59
60 const char *s = cctx->certificates;
61 buf_strcpy(buf, s);
62}
63
67static void smime_command_certificate_path(const struct ExpandoNode *node, void *data,
68 MuttFormatFlags flags, struct Buffer *buf)
69{
70 const char *const c_smime_ca_location = cs_subset_path(NeoMutt->sub, "smime_ca_location");
71
72 struct Buffer *path = buf_pool_get();
73 struct Buffer *quoted = buf_pool_get();
74 struct stat st = { 0 };
75
76 buf_strcpy(path, c_smime_ca_location);
77 expand_path(path, false);
78 buf_quote_filename(quoted, buf_string(path), true);
79
80 if ((stat(buf_string(path), &st) != 0) || !S_ISDIR(st.st_mode))
81 {
82 buf_printf(buf, "-CAfile %s", buf_string(quoted));
83 }
84 else
85 {
86 buf_printf(buf, "-CApath %s", buf_string(quoted));
87 }
88
89 buf_pool_release(&path);
90 buf_pool_release(&quoted);
91}
92
96static void smime_command_digest_algorithm(const struct ExpandoNode *node, void *data,
97 MuttFormatFlags flags, struct Buffer *buf)
98{
99 const struct SmimeCommandContext *cctx = data;
100
101 const char *s = cctx->digestalg;
102 buf_strcpy(buf, s);
103}
104
108static void smime_command_intermediate_ids(const struct ExpandoNode *node, void *data,
109 MuttFormatFlags flags, struct Buffer *buf)
110{
111 const struct SmimeCommandContext *cctx = data;
112
113 const char *s = cctx->intermediates;
114 buf_strcpy(buf, s);
115}
116
120static void smime_command_key(const struct ExpandoNode *node, void *data,
121 MuttFormatFlags flags, struct Buffer *buf)
122{
123 const struct SmimeCommandContext *cctx = data;
124
125 const char *s = cctx->key;
126 buf_strcpy(buf, s);
127}
128
132static void smime_command_message_file(const struct ExpandoNode *node, void *data,
133 MuttFormatFlags flags, struct Buffer *buf)
134{
135 const struct SmimeCommandContext *cctx = data;
136
137 const char *s = cctx->fname;
138 buf_strcpy(buf, s);
139}
140
144static void smime_command_signature_file(const struct ExpandoNode *node, void *data,
145 MuttFormatFlags flags, struct Buffer *buf)
146{
147 const struct SmimeCommandContext *cctx = data;
148
149 const char *s = cctx->sig_fname;
150 buf_strcpy(buf, s);
151}
152
int buf_printf(struct Buffer *buf, const char *fmt,...)
Format a string overwriting a Buffer.
Definition buffer.c:161
size_t buf_strcpy(struct Buffer *buf, const char *s)
Copy a string into a Buffer.
Definition buffer.c:395
static const char * buf_string(const struct Buffer *buf)
Convert a buffer to a const char * "string".
Definition buffer.h:96
const char * cs_subset_path(const struct ConfigSubset *sub, const char *name)
Get a path config item by name.
Definition helpers.c:168
Convenience wrapper for the config headers.
Convenience wrapper for the core headers.
@ ED_SMIME_CMD
Smime Command ED_SMI_ ExpandoDataSmimeCmd.
Definition domain.h:56
Parse Expando string.
const struct ExpandoRenderCallback SmimeCommandRenderCallbacks[]
Callbacks for Smime Command Expandos.
Ncrypt Smime Expando definitions.
void buf_quote_filename(struct Buffer *buf, const char *filename, bool add_outer)
Quote a filename to survive the shell's quoting rules.
Definition file.c:807
static void smime_command_message_file(const struct ExpandoNode *node, void *data, MuttFormatFlags flags, struct Buffer *buf)
Smime Command: Filename of message - Implements get_string_t -.
static void smime_command_signature_file(const struct ExpandoNode *node, void *data, MuttFormatFlags flags, struct Buffer *buf)
Smime Command: Filename of signature - Implements get_string_t -.
static void smime_command_certificate_ids(const struct ExpandoNode *node, void *data, MuttFormatFlags flags, struct Buffer *buf)
Smime Command: certificate IDs - Implements get_string_t -.
static void smime_command_key(const struct ExpandoNode *node, void *data, MuttFormatFlags flags, struct Buffer *buf)
Smime Command: Key-pair - Implements get_string_t -.
static void smime_command_intermediate_ids(const struct ExpandoNode *node, void *data, MuttFormatFlags flags, struct Buffer *buf)
Smime Command: Intermediate certificates - Implements get_string_t -.
static void smime_command_digest_algorithm(const struct ExpandoNode *node, void *data, MuttFormatFlags flags, struct Buffer *buf)
Smime Command: Message digest algorithm - Implements get_string_t -.
static void smime_command_certificate_path(const struct ExpandoNode *node, void *data, MuttFormatFlags flags, struct Buffer *buf)
Smime Command: CA location - Implements get_string_t -.
static void smime_command_algorithm(const struct ExpandoNode *node, void *data, MuttFormatFlags flags, struct Buffer *buf)
Smime Command: algorithm - Implements get_string_t -.
Convenience wrapper for the library headers.
void expand_path(struct Buffer *buf, bool regex)
Create the canonical path.
Definition muttlib.c:121
Some miscellaneous functions.
struct Buffer * buf_pool_get(void)
Get a Buffer from the pool.
Definition pool.c:91
void buf_pool_release(struct Buffer **ptr)
Return a Buffer to the pool.
Definition pool.c:111
uint8_t MuttFormatFlags
Flags for expando_render(), e.g. MUTT_FORMAT_FORCESUBJ.
Definition render.h:32
SMIME helper routines.
@ ED_SMI_MESSAGE_FILE
SmimeCommandContext.fname.
Definition smime.h:80
@ ED_SMI_ALGORITHM
SmimeCommandContext.cryptalg.
Definition smime.h:74
@ ED_SMI_SIGNATURE_FILE
SmimeCommandContext.sig_fname.
Definition smime.h:81
@ ED_SMI_DIGEST_ALGORITHM
SmimeCommandContext.digestalg.
Definition smime.h:77
@ ED_SMI_CERTIFICATE_IDS
SmimeCommandContext.certificates.
Definition smime.h:75
@ ED_SMI_KEY
SmimeCommandContext.key.
Definition smime.h:79
@ ED_SMI_INTERMEDIATE_IDS
SmimeCommandContext.intermediates.
Definition smime.h:78
@ ED_SMI_CERTIFICATE_PATH
Path of Smime certificates.
Definition smime.h:76
String manipulation buffer.
Definition buffer.h:36
Basic Expando Node.
Definition node.h:67
Container for Accounts, Notifications.
Definition neomutt.h:41
struct ConfigSubset * sub
Inherited config items.
Definition neomutt.h:49
Data for a SIME command.
Definition smime.h:57
const char * sig_fname
s
Definition smime.h:62
const char * intermediates
i
Definition smime.h:64
const char * digestalg
d
Definition smime.h:60
const char * cryptalg
a
Definition smime.h:59
const char * key
k
Definition smime.h:58
const char * fname
f
Definition smime.h:61
const char * certificates
c
Definition smime.h:63