1 |
#include <stdio.h> |
#include <stdio.h> |
2 |
#include <stdlib.h> |
#include <stdlib.h> |
3 |
#include <string.h> |
#include <sys/types.h> |
4 |
#include <unistd.h> |
#include <unistd.h> |
5 |
|
#include <string.h> |
6 |
#include <errno.h> |
#include <errno.h> |
7 |
#include <limits.h> |
#include <limits.h> |
8 |
#include <setjmp.h> |
#include <setjmp.h> |
16 |
#include "buffer.h" |
#include "buffer.h" |
17 |
|
|
18 |
#if defined SSL_TLS || defined ENCRYPTED_PASSWORDS || defined CRAM_MD5 |
#if defined SSL_TLS || defined ENCRYPTED_PASSWORDS || defined CRAM_MD5 |
19 |
|
#include <openssl/opensslv.h> |
20 |
#include <openssl/crypto.h> |
#include <openssl/crypto.h> |
21 |
#endif |
#endif |
22 |
|
|
49 |
{ |
{ |
50 |
int c, r, f; |
int c, r, f; |
51 |
pid_t pid; |
pid_t pid; |
52 |
char *confile; /* Configuration file. */ |
char *conffile; /* Configuration file. */ |
53 |
account_t *ca; /* Current account. */ |
account_t *ca; /* Current account. */ |
54 |
mbox_t *cm; /* Current mailbox. */ |
mbox_t *cm; /* Current mailbox. */ |
55 |
|
|
57 |
|
|
58 |
f = 0; |
f = 0; |
59 |
home = getenv("HOME"); |
home = getenv("HOME"); |
60 |
options = (OPTION_DETAILS_NORMAL | OPTION_NAMESPACE); |
options = (OPTION_DETAILS_NORMAL | OPTION_NAMESPACE | OPTION_PEEK); |
61 |
*charset = 0; |
*charset = 0; |
62 |
*logfile = 0; |
*logfile = 0; |
63 |
confile = NULL; |
conffile = NULL; |
64 |
|
connpri.sock = connaux.sock = -1; |
65 |
|
|
66 |
while ((c = getopt(argc, argv, "c:d:hkl:" |
while ((c = getopt(argc, argv, "c:d:hkl:" |
67 |
#ifdef ENCRYPTED_PASSWORDS |
#ifdef ENCRYPTED_PASSWORDS |
70 |
"qvV")) != -1) { |
"qvV")) != -1) { |
71 |
switch (c) { |
switch (c) { |
72 |
case 'c': |
case 'c': |
73 |
confile = optarg; |
conffile = optarg; |
74 |
break; |
break; |
75 |
case 'd': |
case 'd': |
76 |
options |= OPTION_DAEMON_MODE; |
options |= OPTION_DAEMON_MODE; |
95 |
break; |
break; |
96 |
#endif |
#endif |
97 |
case 'q': |
case 'q': |
98 |
options &= OPTION_DETAILS_CLEAR; |
options &= ~(OPTION_DETAILS_QUIET | |
99 |
|
OPTION_DETAILS_NORMAL | OPTION_DETAILS_VERBOSE); |
100 |
options |= OPTION_DETAILS_QUIET; |
options |= OPTION_DETAILS_QUIET; |
101 |
break; |
break; |
102 |
case 'v': |
case 'v': |
103 |
options &= OPTION_DETAILS_CLEAR; |
options &= ~(OPTION_DETAILS_QUIET | |
104 |
|
OPTION_DETAILS_NORMAL | OPTION_DETAILS_VERBOSE); |
105 |
options |= OPTION_DETAILS_VERBOSE; |
options |= OPTION_DETAILS_VERBOSE; |
106 |
break; |
break; |
107 |
case 'V': |
case 'V': |
127 |
tty_store(); |
tty_store(); |
128 |
catch_signals(); |
catch_signals(); |
129 |
|
|
130 |
read_config(confile); |
read_config(conffile); |
131 |
|
|
132 |
#ifdef ENCRYPTED_PASSWORDS |
#ifdef ENCRYPTED_PASSWORDS |
133 |
read_passwords(); |
read_passwords(); |
149 |
|
|
150 |
if (options & OPTION_DAEMON_MODE) { |
if (options & OPTION_DAEMON_MODE) { |
151 |
f = 1; |
f = 1; |
152 |
options &= OPTION_DETAILS_CLEAR; |
options &= ~(OPTION_DETAILS_QUIET | |
153 |
|
OPTION_DETAILS_NORMAL | OPTION_DETAILS_VERBOSE); |
154 |
options |= OPTION_DETAILS_QUIET; |
options |= OPTION_DETAILS_QUIET; |
155 |
} |
} |
156 |
do { |
do { |
240 |
} |
} |
241 |
if (options & OPTION_DAEMON_MODE && |
if (options & OPTION_DAEMON_MODE && |
242 |
flags & FLAG_SIGUSR1_RECEIVED) { |
flags & FLAG_SIGUSR1_RECEIVED) { |
243 |
reread_config(confile); |
reread_config(conffile); |
244 |
continue; |
continue; |
245 |
} |
} |
246 |
if (interval) |
if (interval) |
252 |
|
|
253 |
lockfile_remove(); |
lockfile_remove(); |
254 |
|
|
255 |
return 0; |
exit(0); |
256 |
} |
} |
257 |
|
|
258 |
|
|