16 |
unsigned int options; /* Program options. */ |
unsigned int options; /* Program options. */ |
17 |
unsigned int capabilities; /* Capabilities of mail server. */ |
unsigned int capabilities; /* Capabilities of mail server. */ |
18 |
char logfile[PATH_MAX]; /* Log file. */ |
char logfile[PATH_MAX]; /* Log file. */ |
19 |
|
char *home = NULL; /* User's home directory. */ |
20 |
|
|
21 |
|
|
22 |
/* |
/* |
31 |
|
|
32 |
options = (OPTION_DETAILS_NORMAL | OPTION_NAMESPACE); |
options = (OPTION_DETAILS_NORMAL | OPTION_NAMESPACE); |
33 |
*logfile = 0; |
*logfile = 0; |
34 |
|
home = getenv("HOME"); |
35 |
|
|
36 |
|
#ifndef ENCRYPTED_PASSWORDS |
37 |
while ((c = getopt(argc, argv, "c:hl:qv")) != -1) { |
while ((c = getopt(argc, argv, "c:hl:qv")) != -1) { |
38 |
|
#else |
39 |
|
while ((c = getopt(argc, argv, "c:hl:pqv")) != -1) { |
40 |
|
#endif |
41 |
switch (c) { |
switch (c) { |
42 |
case 'c': |
case 'c': |
43 |
confile = optarg; |
confile = optarg; |
49 |
case 'l': |
case 'l': |
50 |
strncat(logfile, optarg, PATH_MAX - 1); |
strncat(logfile, optarg, PATH_MAX - 1); |
51 |
break; |
break; |
52 |
|
#ifdef ENCRYPTED_PASSWORDS |
53 |
|
case 'p': |
54 |
|
options |= OPTION_PASSWORD_EDITOR; |
55 |
|
break; |
56 |
|
#endif |
57 |
case 'q': |
case 'q': |
58 |
options &= OPTION_DETAILS_CLEAR; |
options &= OPTION_DETAILS_CLEAR; |
59 |
options |= OPTION_DETAILS_QUIET; |
options |= OPTION_DETAILS_QUIET; |
71 |
|
|
72 |
catch_signals(); |
catch_signals(); |
73 |
|
|
74 |
|
create_homedir(); |
75 |
|
|
76 |
read_config(confile); |
read_config(confile); |
77 |
open_logfile(); |
open_logfile(); |
78 |
|
|
79 |
|
#ifdef ENCRYPTED_PASSWORDS |
80 |
|
read_passwords(); |
81 |
|
|
82 |
|
if ((options & OPTION_PASSWORD_EDITOR)) |
83 |
|
password_editor(); |
84 |
|
#endif |
85 |
|
|
86 |
for (ca = accounts; ca; ca = ca->next) { |
for (ca = accounts; ca; ca = ca->next) { |
87 |
|
|
88 |
#ifndef SSL_TLS |
#ifndef SSL_TLS |
102 |
#endif |
#endif |
103 |
|
|
104 |
if (r != RESPONSE_PREAUTH) { |
if (r != RESPONSE_PREAUTH) { |
105 |
if (ca->nopassword) |
if (ca->passwdattr == PASSWORD_NONE) { |
106 |
get_password(ca->username, ca->server, ca->password); |
printf("Enter password for %s@%s: ", ca->username, ca->server); |
107 |
|
get_password(ca->password, PASSWORD_LEN); |
108 |
|
} |
109 |
if (login(ca->username, ca->password)) |
if (login(ca->username, ca->password)) |
110 |
continue; |
continue; |
111 |
} |
} |
|
|
|
112 |
check_namespace(); |
check_namespace(); |
113 |
|
|
114 |
for (cm = ca->mboxes; cm; cm = cm->next) |
for (cm = ca->mboxes; cm; cm = cm->next) |
136 |
*/ |
*/ |
137 |
void usage(void) |
void usage(void) |
138 |
{ |
{ |
139 |
|
#ifndef ENCRYPTED_PASSWORDS |
140 |
|
fprintf(stderr, |
141 |
|
"usage: imapfilter [-hpqv] [-c configfile] [-l logfile]\n"); |
142 |
|
#else |
143 |
fprintf(stderr, |
fprintf(stderr, |
144 |
"usage: imapfilter [-hqv] [-c configfile] [-l logfile]\n"); |
"usage: imapfilter [-hqv] [-c configfile] [-l logfile]\n"); |
145 |
|
#endif |
146 |
} |
} |