1 |
#include <stdio.h> |
#include <stdio.h> |
2 |
#include <string.h> |
#include <string.h> |
3 |
|
#include <errno.h> |
4 |
#include <stdlib.h> |
#include <stdlib.h> |
5 |
#include <limits.h> |
#include <limits.h> |
6 |
|
#include <sys/types.h> |
7 |
|
#include <sys/stat.h> |
8 |
|
#include <fcntl.h> |
9 |
|
|
10 |
#include "config.h" |
#include "config.h" |
11 |
#include "imapfilter.h" |
#include "imapfilter.h" |
12 |
|
#include "pathnames.h" |
13 |
|
|
14 |
#ifdef ENCRYPTED_PASSWORDS |
#ifdef ENCRYPTED_PASSWORDS |
15 |
#include <openssl/evp.h> |
#include <openssl/evp.h> |
18 |
|
|
19 |
extern unsigned int flags; |
extern unsigned int flags; |
20 |
extern account_t *accounts; |
extern account_t *accounts; |
21 |
|
extern char *home; |
22 |
|
|
23 |
#ifdef ENCRYPTED_PASSWORDS |
#ifdef ENCRYPTED_PASSWORDS |
24 |
extern char *passphr; |
extern char *passphr; |
25 |
#endif |
#endif |
26 |
|
|
27 |
|
|
28 |
|
int store_passwords(account_t ** accts); |
29 |
|
|
30 |
|
|
31 |
/* |
/* |
32 |
* Get password from user interactively. |
* Get password from user interactively. |
33 |
*/ |
*/ |
218 |
} |
} |
219 |
|
|
220 |
|
|
221 |
|
/* |
222 |
|
* Store encrypted passwords to file. |
223 |
|
*/ |
224 |
|
int |
225 |
|
store_passwords(account_t ** accts) |
226 |
|
{ |
227 |
|
char pwfile[PATH_MAX]; |
228 |
|
FILE *fd; |
229 |
|
|
230 |
|
snprintf(pwfile, PATH_MAX, "%s/%s", home, PATHNAME_PASSWORD_FILE); |
231 |
|
|
232 |
|
create_file(pwfile, S_IRUSR | S_IWUSR); |
233 |
|
|
234 |
|
fd = fopen(pwfile, "w"); |
235 |
|
|
236 |
|
if (fd == NULL) |
237 |
|
fatal(ERROR_FILE_OPEN, "opening passwords file %s; %s\n", |
238 |
|
pwfile, strerror(errno)); |
239 |
|
|
240 |
|
encrypt_passwords(fd, accts); |
241 |
|
|
242 |
|
fclose(fd); |
243 |
|
|
244 |
|
return 0; |
245 |
|
} |
246 |
|
|
247 |
|
|
248 |
/* |
/* |
249 |
* Interactive encrypted passwords editor. |
* Interactive encrypted passwords editor. |
250 |
*/ |
*/ |