diff options
-rw-r--r-- | configure.ac | 2 | ||||
-rw-r--r-- | gnulib.modules | 1 | ||||
-rw-r--r-- | include/mailutils/mutil.h | 2 | ||||
-rw-r--r-- | include/mailutils/stream.h | 3 | ||||
-rw-r--r-- | include/mailutils/sys/file_stream.h | 4 | ||||
-rw-r--r-- | libmailutils/Makefile.am | 1 | ||||
-rw-r--r-- | libmailutils/file_stream.c | 94 | ||||
-rw-r--r-- | libmailutils/getpass.c | 59 | ||||
-rw-r--r-- | mu/mu.h | 2 | ||||
-rw-r--r-- | mu/pop.c | 35 | ||||
-rw-r--r-- | mu/shell.c | 28 | ||||
-rw-r--r-- | pop3d/popauth.c | 68 |
12 files changed, 236 insertions, 63 deletions
diff --git a/configure.ac b/configure.ac index 509a56991..796c4687a 100644 --- a/configure.ac +++ b/configure.ac | |||
@@ -515,7 +515,7 @@ extern char *strsignal (int); | |||
515 | ]) | 515 | ]) |
516 | 516 | ||
517 | AC_CHECK_FUNCS(mkstemp sigaction sysconf getdelim setreuid \ | 517 | AC_CHECK_FUNCS(mkstemp sigaction sysconf getdelim setreuid \ |
518 | setresuid seteuid setlocale vfork _exit) | 518 | setresuid seteuid setlocale vfork _exit tcgetattr tcsetattr) |
519 | 519 | ||
520 | AC_FUNC_FSEEKO | 520 | AC_FUNC_FSEEKO |
521 | AC_FUNC_SETVBUF_REVERSED | 521 | AC_FUNC_SETVBUF_REVERSED |
diff --git a/gnulib.modules b/gnulib.modules index 4368cf7c2..66399597e 100644 --- a/gnulib.modules +++ b/gnulib.modules | |||
@@ -8,7 +8,6 @@ autobuild | |||
8 | argp | 8 | argp |
9 | crypto/des | 9 | crypto/des |
10 | getline | 10 | getline |
11 | getpass-gnu | ||
12 | gettext | 11 | gettext |
13 | gitlog-to-changelog | 12 | gitlog-to-changelog |
14 | intprops | 13 | intprops |
diff --git a/include/mailutils/mutil.h b/include/mailutils/mutil.h index 7acc021cf..86d2243e7 100644 --- a/include/mailutils/mutil.h +++ b/include/mailutils/mutil.h | |||
@@ -157,6 +157,8 @@ extern int mu_stream_flags_to_mode (int flags, int isdir); | |||
157 | extern int mu_parse_stream_perm_string (int *pmode, const char *str, | 157 | extern int mu_parse_stream_perm_string (int *pmode, const char *str, |
158 | const char **endp); | 158 | const char **endp); |
159 | 159 | ||
160 | extern int mu_getpass (mu_stream_t in, mu_stream_t out, const char *prompt, | ||
161 | char **passptr); | ||
160 | 162 | ||
161 | #ifdef __cplusplus | 163 | #ifdef __cplusplus |
162 | } | 164 | } |
diff --git a/include/mailutils/stream.h b/include/mailutils/stream.h index c076ade11..d951f3425 100644 --- a/include/mailutils/stream.h +++ b/include/mailutils/stream.h | |||
@@ -74,6 +74,9 @@ enum mu_buffer_type | |||
74 | #define MU_IOCTL_GET_TRANSPORT_BUFFER 10 | 74 | #define MU_IOCTL_GET_TRANSPORT_BUFFER 10 |
75 | #define MU_IOCTL_SET_TRANSPORT_BUFFER 11 | 75 | #define MU_IOCTL_SET_TRANSPORT_BUFFER 11 |
76 | 76 | ||
77 | #define MU_IOCTL_GET_ECHO 12 | ||
78 | #define MU_IOCTL_SET_ECHO 13 | ||
79 | |||
77 | #define MU_TRANSPORT_INPUT 0 | 80 | #define MU_TRANSPORT_INPUT 0 |
78 | #define MU_TRANSPORT_OUTPUT 1 | 81 | #define MU_TRANSPORT_OUTPUT 1 |
79 | #define MU_TRANSPORT_VALID_TYPE(n) \ | 82 | #define MU_TRANSPORT_VALID_TYPE(n) \ |
diff --git a/include/mailutils/sys/file_stream.h b/include/mailutils/sys/file_stream.h index 70c576ab7..581d28941 100644 --- a/include/mailutils/sys/file_stream.h +++ b/include/mailutils/sys/file_stream.h | |||
@@ -21,7 +21,8 @@ | |||
21 | #include <mailutils/stream.h> | 21 | #include <mailutils/stream.h> |
22 | #include <mailutils/sys/stream.h> | 22 | #include <mailutils/sys/stream.h> |
23 | 23 | ||
24 | #define _MU_FILE_STREAM_TEMP 0x01 | 24 | #define _MU_FILE_STREAM_TEMP 0x01 |
25 | #define _MU_FILE_STREAM_ECHO_OFF 0x02 | ||
25 | 26 | ||
26 | struct _mu_file_stream | 27 | struct _mu_file_stream |
27 | { | 28 | { |
@@ -29,6 +30,7 @@ struct _mu_file_stream | |||
29 | int fd; | 30 | int fd; |
30 | int flags; | 31 | int flags; |
31 | char *filename; | 32 | char *filename; |
33 | void *echo_state; | ||
32 | }; | 34 | }; |
33 | 35 | ||
34 | int _mu_file_stream_create (struct _mu_file_stream **pstream, size_t size, | 36 | int _mu_file_stream_create (struct _mu_file_stream **pstream, size_t size, |
diff --git a/libmailutils/Makefile.am b/libmailutils/Makefile.am index e05edd883..3f083e01d 100644 --- a/libmailutils/Makefile.am +++ b/libmailutils/Makefile.am | |||
@@ -84,6 +84,7 @@ libmailutils_la_SOURCES = \ | |||
84 | folder.c\ | 84 | folder.c\ |
85 | freeitem.c\ | 85 | freeitem.c\ |
86 | gdebug.c\ | 86 | gdebug.c\ |
87 | getpass.c\ | ||
87 | gocs.c\ | 88 | gocs.c\ |
88 | hdritr.c\ | 89 | hdritr.c\ |
89 | header.c\ | 90 | header.c\ |
diff --git a/libmailutils/file_stream.c b/libmailutils/file_stream.c index 247768c25..578f4829e 100644 --- a/libmailutils/file_stream.c +++ b/libmailutils/file_stream.c | |||
@@ -23,6 +23,9 @@ | |||
23 | #include <unistd.h> | 23 | #include <unistd.h> |
24 | #include <fcntl.h> | 24 | #include <fcntl.h> |
25 | #include <sys/stat.h> | 25 | #include <sys/stat.h> |
26 | #if HAVE_TERMIOS_H | ||
27 | # include <termios.h> | ||
28 | #endif | ||
26 | 29 | ||
27 | #include <mailutils/types.h> | 30 | #include <mailutils/types.h> |
28 | #include <mailutils/alloc.h> | 31 | #include <mailutils/alloc.h> |
@@ -183,6 +186,8 @@ fd_done (struct _mu_stream *str) | |||
183 | fd_close (str); | 186 | fd_close (str); |
184 | if (fstr->filename) | 187 | if (fstr->filename) |
185 | free (fstr->filename); | 188 | free (fstr->filename); |
189 | if (fstr->echo_state) | ||
190 | free (fstr->echo_state); | ||
186 | } | 191 | } |
187 | 192 | ||
188 | const char * | 193 | const char * |
@@ -194,6 +199,10 @@ fd_error_string (struct _mu_stream *str, int rc) | |||
194 | return mu_strerror (rc); | 199 | return mu_strerror (rc); |
195 | } | 200 | } |
196 | 201 | ||
202 | #ifndef TCSASOFT | ||
203 | # define TCSASOFT 0 | ||
204 | #endif | ||
205 | |||
197 | static int | 206 | static int |
198 | fd_ioctl (struct _mu_stream *str, int code, void *ptr) | 207 | fd_ioctl (struct _mu_stream *str, int code, void *ptr) |
199 | { | 208 | { |
@@ -218,17 +227,86 @@ fd_ioctl (struct _mu_stream *str, int code, void *ptr) | |||
218 | break; | 227 | break; |
219 | 228 | ||
220 | case MU_IOCTL_GET_TRANSPORT_BUFFER: | 229 | case MU_IOCTL_GET_TRANSPORT_BUFFER: |
221 | { | 230 | if (!ptr) |
222 | struct mu_buffer_query *qp = ptr; | 231 | return EINVAL; |
223 | return mu_stream_get_buffer (str, qp); | 232 | else |
224 | } | 233 | { |
234 | struct mu_buffer_query *qp = ptr; | ||
235 | return mu_stream_get_buffer (str, qp); | ||
236 | } | ||
225 | 237 | ||
226 | case MU_IOCTL_SET_TRANSPORT_BUFFER: | 238 | case MU_IOCTL_SET_TRANSPORT_BUFFER: |
227 | { | 239 | if (!ptr) |
228 | struct mu_buffer_query *qp = ptr; | 240 | return EINVAL; |
229 | return mu_stream_set_buffer (str, qp->buftype, qp->bufsize); | 241 | else |
230 | } | 242 | { |
243 | struct mu_buffer_query *qp = ptr; | ||
244 | return mu_stream_set_buffer (str, qp->buftype, qp->bufsize); | ||
245 | } | ||
246 | |||
247 | case MU_IOCTL_SET_ECHO: | ||
248 | if (!ptr) | ||
249 | return EINVAL; | ||
250 | else | ||
251 | { | ||
252 | int status; | ||
253 | struct termios t; | ||
254 | int state = *(int*)ptr; | ||
255 | #if HAVE_TCGETATTR | ||
256 | if (state == 0) | ||
257 | { | ||
258 | if (fstr->flags & _MU_FILE_STREAM_ECHO_OFF) | ||
259 | return 0; | ||
260 | status = tcgetattr (fstr->fd, &t); | ||
261 | if (status == 0) | ||
262 | { | ||
263 | fstr->echo_state = malloc (sizeof (t)); | ||
264 | if (!fstr->echo_state) | ||
265 | return ENOMEM; | ||
266 | memcpy (fstr->echo_state, &t, sizeof (t)); | ||
267 | |||
268 | t.c_lflag &= ~(ECHO | ISIG); | ||
269 | status = tcsetattr (fstr->fd, TCSAFLUSH | TCSASOFT, &t); | ||
270 | if (status == 0) | ||
271 | fstr->flags |= _MU_FILE_STREAM_ECHO_OFF; | ||
272 | } | ||
273 | if (status) | ||
274 | { | ||
275 | status = errno; | ||
276 | if (fstr->echo_state) | ||
277 | { | ||
278 | free (fstr->echo_state); | ||
279 | fstr->echo_state = NULL; | ||
280 | } | ||
281 | } | ||
282 | } | ||
283 | else | ||
284 | { | ||
285 | if (!(fstr->flags & _MU_FILE_STREAM_ECHO_OFF)) | ||
286 | return 0; | ||
287 | if (tcsetattr (fstr->fd, TCSAFLUSH | TCSASOFT, fstr->echo_state)) | ||
288 | status = errno; | ||
289 | else | ||
290 | { | ||
291 | status = 0; | ||
292 | free (fstr->echo_state); | ||
293 | fstr->echo_state = NULL; | ||
294 | fstr->flags &= ~_MU_FILE_STREAM_ECHO_OFF; | ||
295 | } | ||
296 | } | ||
297 | return status; | ||
298 | #else | ||
299 | return ENOSYS; | ||
300 | #endif | ||
301 | } | ||
231 | 302 | ||
303 | case MU_IOCTL_GET_ECHO: | ||
304 | if (!ptr) | ||
305 | return EINVAL; | ||
306 | else | ||