26 |
extern filter_t *filters; |
extern filter_t *filters; |
27 |
extern buffer_t ibuf, obuf; |
extern buffer_t ibuf, obuf; |
28 |
|
|
29 |
opts_t opts; /* Program opts. */ |
options_t opts; /* Program opts. */ |
30 |
unsigned int flags = 0; /* Program flags. */ |
unsigned int flags = 0; /* Program flags. */ |
31 |
|
|
32 |
conn_t connpri, connaux; /* Primary and auxiliary IMAP connection. */ |
connection_t connpri, connaux; /* Primary and auxiliary IMAP connection. */ |
33 |
|
|
34 |
char *home = NULL; /* User's home directory. */ |
char *home = NULL; /* User's home directory. */ |
35 |
|
|
149 |
|
|
150 |
log_start(); |
log_start(); |
151 |
|
|
152 |
init_buffer(&ibuf); |
buffer_init(&ibuf); |
153 |
init_buffer(&obuf); |
buffer_init(&obuf); |
154 |
|
|
155 |
if (opts.daemon) |
if (opts.daemon) |
156 |
opts.verbosity = -2; |
opts.verbosity = -2; |
165 |
ca->ssl)) |
ca->ssl)) |
166 |
continue; |
continue; |
167 |
|
|
168 |
r = greeting_response(&connpri); |
r = response_greeting(&connpri); |
169 |
|
|
170 |
if (opts.debug) |
if (opts.debug) |
171 |
test(&connpri); |
test(&connpri); |
175 |
|
|
176 |
#ifdef SSL_TLS |
#ifdef SSL_TLS |
177 |
if (ca->ssl == SSL_DISABLED && |
if (ca->ssl == SSL_DISABLED && |
178 |
connpri.caps & CAPABILITY_STARTTLS) |
connpri.caps & CAPS_STARTTLS) |
179 |
if (negotiate_tls(&connpri) == RESPONSE_OK) |
if (negotiate_tls(&connpri) == RESPONSE_OK) |
180 |
check_capabilities(&connpri); |
check_capabilities(&connpri); |
181 |
#endif |
#endif |
183 |
log_info(LOG_ACCOUNT, ca->key); |
log_info(LOG_ACCOUNT, ca->key); |
184 |
|
|
185 |
if (r != RESPONSE_PREAUTH) { |
if (r != RESPONSE_PREAUTH) { |
186 |
if (ca->passwdattr == PASSWORD_NONE) { |
if (ca->pass_attr == PASS_ATTR_NONE) { |
187 |
printf("Enter password for %s@%s: ", |
printf("Enter password for %s@%s: ", |
188 |
ca->username, ca->server); |
ca->user, ca->server); |
189 |
get_password(ca->password, PASSWORD_LEN); |
get_password(ca->pass, PASS_LEN); |
190 |
ca->passwdattr = PASSWORD_PLAIN; |
ca->pass_attr = PASS_ATTR_PLAIN; |
191 |
} |
} |
192 |
#ifdef CRAM_MD5 |
#ifdef CRAM_MD5 |
193 |
if (connpri.caps & CAPABILITY_AUTH_CRAM_MD5) |
if (connpri.caps & CAPS_CRAMMD5) |
194 |
r = auth_cram_md5(&connpri, |
r = auth_cram_md5(&connpri, |
195 |
ca->username, ca->password); |
ca->user, ca->pass); |
196 |
else |
else |
197 |
#endif |
#endif |
198 |
r = login(&connpri, ca->username, |
r = login(&connpri, ca->user, |
199 |
ca->password); |
ca->pass); |
200 |
|
|
201 |
if (r == RESPONSE_NO) { |
if (r == RESPONSE_NO) { |
202 |
error("username %s or password rejected " |
error("username %s or password rejected " |
203 |
"at %s\n", ca->username, ca->server); |
"at %s\n", ca->user, ca->server); |
204 |
continue; |
continue; |
205 |
} |
} |
206 |
} |
} |
219 |
} |
} |
220 |
|
|
221 |
/* Fork if in daemon mode. */ |
/* Fork if in daemon mode. */ |
222 |
if (opts.daemon && !(flags & FLAG_DAEMON_MODE)) { |
if (opts.daemon && !(flags & FLAG_DAEMON)) { |
223 |
switch (fork()) { |
switch (fork()) { |
224 |
case -1: |
case -1: |
225 |
fatal(ERROR_FORK, "forking; %s\n", |
fatal(ERROR_FORK, "forking; %s\n", |
264 |
lockfile_create(); |
lockfile_create(); |
265 |
corefile_disable(); |
corefile_disable(); |
266 |
|
|
267 |
flags |= FLAG_DAEMON_MODE; |
flags |= FLAG_DAEMON; |
268 |
} |
} |
269 |
if (opts.daemon && flags & FLAG_SIGUSR1_RECEIVED) { |
if (opts.daemon && flags & FLAG_SIGUSR1) { |
270 |
reread_config(cf); |
reread_config(cf); |
271 |
continue; |
continue; |
272 |
} |
} |