4 |
#include <string.h> |
#include <string.h> |
5 |
#include <limits.h> |
#include <limits.h> |
6 |
#include <errno.h> |
#include <errno.h> |
7 |
|
#include <setjmp.h> |
8 |
|
|
9 |
#include "config.h" |
#include "config.h" |
10 |
#include "imapfilter.h" |
#include "imapfilter.h" |
23 |
char logfile[PATH_MAX]; /* Log file. */ |
char logfile[PATH_MAX]; /* Log file. */ |
24 |
char *home = NULL; /* User's home directory. */ |
char *home = NULL; /* User's home directory. */ |
25 |
uid_t ruid, euid; /* Real and effective UID. */ |
uid_t ruid, euid; /* Real and effective UID. */ |
26 |
|
jmp_buf acctloop; |
27 |
|
|
28 |
|
|
29 |
/* |
/* |
120 |
|
|
121 |
init_vbuf(); |
init_vbuf(); |
122 |
|
|
|
|
|
123 |
if (options & OPTION_DAEMON_MODE) { |
if (options & OPTION_DAEMON_MODE) { |
124 |
f = 1; |
f = 1; |
125 |
options &= OPTION_DETAILS_CLEAR; |
options &= OPTION_DETAILS_CLEAR; |
128 |
do { |
do { |
129 |
for (ca = accounts; ca; ca = ca->next) { |
for (ca = accounts; ca; ca = ca->next) { |
130 |
|
|
131 |
|
if (setjmp(acctloop)) |
132 |
|
continue; |
133 |
|
|
134 |
if (init_connection(&sockpri, ca->server, ca->port, ca->ssl)) |
if (init_connection(&sockpri, ca->server, ca->port, ca->ssl)) |
135 |
continue; |
continue; |
136 |
|
|
137 |
r = greeting_response(&sockpri); |
r = greeting_response(&sockpri); |
138 |
|
|
139 |
if (r == RESPONSE_BYE || check_capabilities(&sockpri)) |
if (check_capabilities(&sockpri)) |
140 |
continue; |
continue; |
141 |
|
|
142 |
#ifdef DEBUG |
#ifdef DEBUG |
145 |
|
|
146 |
if (r != RESPONSE_PREAUTH) { |
if (r != RESPONSE_PREAUTH) { |
147 |
if (ca->passwdattr == PASSWORD_NONE) { |
if (ca->passwdattr == PASSWORD_NONE) { |
148 |
printf("Enter password for %s@%s: ", ca->username, ca->server); |
printf("Enter password for %s@%s: ", ca->username, |
149 |
|
ca->server); |
150 |
get_password(ca->password, PASSWORD_LEN); |
get_password(ca->password, PASSWORD_LEN); |
151 |
ca->passwdattr = PASSWORD_PLAIN; |
ca->passwdattr = PASSWORD_PLAIN; |
152 |
} |
} |
153 |
if (login(&sockpri, ca->username, ca->password) == RESPONSE_NO) { |
if (login(&sockpri, ca->username, ca->password) == |
154 |
error("imapfilter: username %s or password rejected at %s\n", |
RESPONSE_NO) { |
155 |
ca->username, ca->server); |
error("imapfilter: username %s or password rejected " |
156 |
|
"at %s\n", ca->username, ca->server); |
157 |
continue; |
continue; |
158 |
} |
} |
159 |
} |
} |