diff options
author | Sergey Poznyakoff <gray@gnu.org> | 2019-09-03 17:47:14 +0300 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org> | 2019-09-03 17:50:54 +0300 |
commit | 016c4a978a69cc8990b5aab6c88cbac6fda57203 (patch) | |
tree | f451622ce35a0b64e52522aeef82bd3064faef06 | |
parent | ddfa689bff19d877170add6fed3381f3d5b79a8e (diff) | |
download | mailutils-016c4a978a69cc8990b5aab6c88cbac6fda57203.tar.gz mailutils-016c4a978a69cc8990b5aab6c88cbac6fda57203.tar.bz2 |
comsatd: optional argument to the --test option supplies the name of the tty to use
* NEWS: Document changes.
* comsat/action.c (open_default_tty): Remove.
(open_tty): Examine the tty device (or file) and construct a suitable
filter chain.
Use append mode when opening it.
* comsat/comsat.c: The --test option takes optional argument.
* comsat/tests/testsuite.at: Use local file instead of the tty.
* doc/texinfo/programs/comsatd.texi: Document changes.
-rw-r--r-- | NEWS | 7 | ||||
-rw-r--r-- | comsat/action.c | 156 | ||||
-rw-r--r-- | comsat/comsat.c | 32 | ||||
-rw-r--r-- | comsat/tests/testsuite.at | 62 | ||||
-rw-r--r-- | doc/texinfo/programs/comsatd.texi | 28 |
5 files changed, 153 insertions, 132 deletions
@@ -1,37 +1,42 @@ | |||
1 | GNU mailutils NEWS -- history of user-visible changes. 2019-08-29 | 1 | GNU mailutils NEWS -- history of user-visible changes. 2019-09-03 |
2 | Copyright (C) 2002-2019 Free Software Foundation, Inc. | 2 | Copyright (C) 2002-2019 Free Software Foundation, Inc. |
3 | See the end of file for copying conditions. | 3 | See the end of file for copying conditions. |
4 | 4 | ||
5 | Please send mailutils bug reports to <bug-mailutils@gnu.org>. | 5 | Please send mailutils bug reports to <bug-mailutils@gnu.org>. |
6 | 6 | ||
7 | Version 3.7.90 (git) | 7 | Version 3.7.90 (git) |
8 | 8 | ||
9 | * Use of TLS in pop3d run from inetd | 9 | * Use of TLS in pop3d run from inetd |
10 | 10 | ||
11 | New global configuration statement "tls-mode" configures the TLS for | 11 | New global configuration statement "tls-mode" configures the TLS for |
12 | use in inetd mode. | 12 | use in inetd mode. |
13 | 13 | ||
14 | The certificate and key files are configured by the global "tls" | 14 | The certificate and key files are configured by the global "tls" |
15 | compound statement. | 15 | compound statement. |
16 | 16 | ||
17 | Example configuration (pop3s server): | 17 | Example configuration (pop3s server): |
18 | 18 | ||
19 | mode inetd; | 19 | mode inetd; |
20 | tls-mode connection; | 20 | tls-mode connection; |
21 | tls { | 21 | tls { |
22 | ssl-key-file /etc/ssl/key.pem; | 22 | ssl-key-file /etc/ssl/key.pem; |
23 | ssl-certificate-file /etc/ssl/cert.pem; | 23 | ssl-certificate-file /etc/ssl/cert.pem; |
24 | } | 24 | } |
25 | 25 | ||
26 | * comsatd --test | ||
27 | |||
28 | The --test option takes optional argument: name of the tty or file to | ||
29 | use for reporting. | ||
30 | |||
26 | 31 | ||
27 | Version 3.7 - 2019-06-21 | 32 | Version 3.7 - 2019-06-21 |
28 | 33 | ||
29 | * Support for the new mailbox format - dotmail | 34 | * Support for the new mailbox format - dotmail |
30 | 35 | ||
31 | Dotmail is a replacement for traditional mbox format, proposed by | 36 | Dotmail is a replacement for traditional mbox format, proposed by |
32 | Kurt Hackenberg. A dotmail mailbox is a single disk file, where | 37 | Kurt Hackenberg. A dotmail mailbox is a single disk file, where |
33 | messages are stored sequentially. Each message ends with a single | 38 | messages are stored sequentially. Each message ends with a single |
34 | dot (similar to the format used in the SMTP DATA command). Any dot | 39 | dot (similar to the format used in the SMTP DATA command). Any dot |
35 | appearing at the start of the line is doubled, to prevent it from | 40 | appearing at the start of the line is doubled, to prevent it from |
36 | being interpreted as end of message marker. | 41 | being interpreted as end of message marker. |
37 | 42 | ||
diff --git a/comsat/action.c b/comsat/action.c index c9703f28e..b6799c481 100644 --- a/comsat/action.c +++ b/comsat/action.c | |||
@@ -167,138 +167,148 @@ expand_line (const char *str, mu_message_t msg) | |||
167 | } | 167 | } |
168 | } | 168 | } |
169 | mu_opool_append_char (pool, 0); | 169 | mu_opool_append_char (pool, 0); |
170 | str = strdup (mu_opool_finish (pool, NULL)); | 170 | str = strdup (mu_opool_finish (pool, NULL)); |
171 | mu_opool_destroy (&pool); | 171 | mu_opool_destroy (&pool); |
172 | return (char *)str; | 172 | return (char *)str; |
173 | } | 173 | } |
174 | 174 | ||
175 | const char *default_action = | 175 | const char *default_action = |
176 | #include "biff.rc.h" | 176 | #include "biff.rc.h" |
177 | ; | 177 | ; |
178 | 178 | ||
179 | /* Examine the tty to determine which filters to apply when printing | ||
180 | to it. On entry, STR is the opened stream, FLT points to an array | ||
181 | of char* with at least 3 slots, and NFLT to an integer number. | ||
182 | On success, populates FLT with the necessary filter chain, and stores | ||
183 | to *NFLT the number of used slots. On error, issues error message and | ||
184 | returns -1. | ||
185 | FLT and NFLT can be used as input to mu_filter_chain_create. | ||
186 | */ | ||
179 | static int | 187 | static int |
180 | need_crlf (mu_stream_t str) | 188 | study_tty (mu_stream_t str, char *flt[], int *nflt) |
181 | { | 189 | { |
182 | #if defined(OPOST) && defined(ONLCR) | ||
183 | mu_transport_t trans[2]; | 190 | mu_transport_t trans[2]; |
184 | struct termios tbuf; | 191 | int fd; |
192 | struct stat st; | ||
193 | int rc; | ||
185 | 194 | ||
186 | if (mu_stream_ioctl (str, MU_IOCTL_TRANSPORT, MU_IOCTL_OP_GET, trans)) | 195 | rc = mu_stream_ioctl (str, MU_IOCTL_TRANSPORT, MU_IOCTL_OP_GET, trans); |
187 | return 1; /* suppose we do need it */ | 196 | if (rc) |
188 | if (tcgetattr ((int) (intptr_t) trans[0], &tbuf) == 0 && | 197 | { |
189 | (tbuf.c_oflag & OPOST) && (tbuf.c_oflag & ONLCR)) | 198 | mu_diag_funcall (MU_DIAG_ERROR, "mu_stream_ioctl", NULL, rc); |
190 | return 0; | 199 | return rc; |
191 | else | 200 | } |
192 | return 1; | 201 | |
202 | *nflt = 0; | ||
203 | fd = (int) (intptr_t) trans[0]; | ||
204 | if (fstat (fd, &st) == 0) | ||
205 | { | ||
206 | switch (st.st_mode & S_IFMT) | ||
207 | { | ||
208 | case S_IFREG: | ||
209 | return 0; | ||
210 | |||
211 | case S_IFCHR: | ||
212 | flt[(*nflt)++] = "7BIT"; | ||
213 | #if defined(OPOST) && defined(ONLCR) | ||
214 | { | ||
215 | struct termios tbuf; | ||
216 | |||
217 | if (!(tcgetattr (fd, &tbuf) == 0 | ||
218 | && (tbuf.c_oflag & OPOST) && (tbuf.c_oflag & ONLCR))) | ||
219 | { | ||
220 | flt[(*nflt)++] = "+"; | ||
221 | flt[(*nflt)++] = "CRLF"; | ||
222 | } | ||
223 | } | ||
193 | #else | 224 | #else |
194 | return 1; /* Just in case */ | 225 | /* Just in case */ |
226 | flt[(*nflt)++] = "+"; | ||
227 | flt[(*nflt)++] = "CRLF"; | ||
195 | #endif | 228 | #endif |
229 | break; | ||
230 | |||
231 | case S_IFSOCK: | ||
232 | return 0; | ||
233 | |||
234 | default: | ||
235 | /* FIXME: Perhaps an error? */ | ||
236 | return 0; | ||
237 | } | ||
238 | } | ||
239 | |||
240 | return 0; | ||
196 | } | 241 | } |
197 | 242 | ||
198 | static mu_stream_t | 243 | static mu_stream_t |
199 | _open_tty (const char *device, int argc, char **argv) | 244 | _open_tty (const char *device, int argc, char **argv) |
200 | { | 245 | { |
201 | mu_stream_t dev, base_dev, prev_stream; | 246 | mu_stream_t dev; |
202 | int status; | 247 | int status; |
248 | char *dfl_argv[4]; | ||
203 | 249 | ||
204 | status = mu_file_stream_create (&dev, device, MU_STREAM_WRITE); | 250 | status = mu_file_stream_create (&dev, device, MU_STREAM_APPEND|MU_STREAM_CREAT); |
205 | if (status) | 251 | if (status) |
206 | { | 252 | { |
207 | mu_error (_("cannot open device %s: %s"), | 253 | mu_error (_("cannot open device %s: %s"), |
208 | device, mu_strerror (status)); | 254 | device, mu_strerror (status)); |
209 | return NULL; | 255 | return NULL; |
210 | } | 256 | } |
211 | mu_stream_set_buffer (dev, mu_buffer_line, 0); | 257 | mu_stream_set_buffer (dev, mu_buffer_line, 0); |
212 | 258 | ||
213 | prev_stream = base_dev = dev; | 259 | if (argc == 0) |
214 | while (argc) | ||
215 | { | 260 | { |
216 | int i; | 261 | status = study_tty (dev, dfl_argv, &argc); |
217 | int mode; | 262 | if (status) |
218 | int qmark; | 263 | return NULL; |
219 | char *fltname; | 264 | argv = dfl_argv; |
220 | 265 | } | |
221 | fltname = argv[0]; | 266 | |
222 | if (fltname[0] == '?') | 267 | if (argc) |
223 | { | 268 | { |
224 | qmark = 1; | 269 | mu_stream_t str; |
225 | fltname++; | 270 | status = mu_filter_chain_create (&str, dev, |
226 | } | 271 | MU_FILTER_ENCODE, MU_STREAM_WRITE, |
227 | else | 272 | argc, argv); |
228 | qmark = 0; | 273 | mu_stream_unref (dev); |
229 | 274 | if (status) | |
230 | if (fltname[0] == '~') | ||
231 | { | ||
232 | mode = MU_FILTER_DECODE; | ||
233 | fltname++; | ||
234 | } | ||
235 | else | ||
236 | { | ||
237 | mode = MU_FILTER_ENCODE; | ||
238 | } | ||
239 | |||
240 | for (i = 1; i < argc; i++) | ||
241 | if (strcmp (argv[i], "+") == 0) | ||
242 | break; | ||
243 | |||
244 | if (qmark == 0 || need_crlf (base_dev)) | ||
245 | { | ||
246 | status = mu_filter_create_args (&dev, prev_stream, fltname, | ||
247 | i, (const char **)argv, | ||
248 | mode, MU_STREAM_WRITE); | ||
249 | mu_stream_unref (prev_stream); | ||
250 | if (status) | ||
251 | { | ||
252 | mu_error (_("cannot open filter stream: %s"), | ||
253 | mu_strerror (status)); | ||
254 |