equal
deleted
inserted
replaced
36 #include "pop3d.h" |
36 #include "pop3d.h" |
37 |
37 |
38 #define MBOX_PATH "/var/mail/%u" |
38 #define MBOX_PATH "/var/mail/%u" |
39 #define MAILDIR_PATH "~/Maildir" |
39 #define MAILDIR_PATH "~/Maildir" |
40 #define POP3D_USER "_pop3d" |
40 #define POP3D_USER "_pop3d" |
|
41 #define CERTFILE "/etc/ssl/server.crt" |
|
42 #define KEYFILE "/etc/ssl/private/server.key" |
41 |
43 |
42 static void authenticate(struct imsgev *, struct imsg *); |
44 static void authenticate(struct imsgev *, struct imsg *); |
43 static void pop3e_imsgev(struct imsgev *, int , struct imsg *); |
45 static void pop3e_imsgev(struct imsgev *, int , struct imsg *); |
44 static void needfd(struct imsgev *); |
46 static void needfd(struct imsgev *); |
45 static void sig_handler(int, short, void *); |
47 static void sig_handler(int, short, void *); |
54 main(int argc, char *argv[]) |
56 main(int argc, char *argv[]) |
55 { |
57 { |
56 struct passwd *pw; |
58 struct passwd *pw; |
57 struct event ev_sigint, ev_sigterm, ev_sighup, ev_sigchld; |
59 struct event ev_sigint, ev_sigterm, ev_sighup, ev_sigchld; |
58 const char *path = NULL, *mtype_str = "mbox"; |
60 const char *path = NULL, *mtype_str = "mbox"; |
|
61 const char *cert = CERTFILE, *key = KEYFILE; |
59 int ch, d = 0, pair[2]; |
62 int ch, d = 0, pair[2]; |
60 |
63 |
61 while ((ch = getopt(argc, argv, "dp:t:")) != -1) { |
64 while ((ch = getopt(argc, argv, "c:dk:p:t:")) != -1) { |
62 switch (ch) { |
65 switch (ch) { |
|
66 case 'c': |
|
67 cert = optarg; |
|
68 break; |
63 case 'd': |
69 case 'd': |
64 d = 1; |
70 d = 1; |
|
71 break; |
|
72 case 'k': |
|
73 key = optarg; |
65 break; |
74 break; |
66 case 'p': |
75 case 'p': |
67 path = optarg; |
76 path = optarg; |
68 break; |
77 break; |
69 case 't': |
78 case 't': |
99 set_nonblocking(pair[0]); |
108 set_nonblocking(pair[0]); |
100 set_nonblocking(pair[1]); |
109 set_nonblocking(pair[1]); |
101 if ((pw = getpwnam(POP3D_USER)) == NULL) |
110 if ((pw = getpwnam(POP3D_USER)) == NULL) |
102 fatalx("main: getpwnam " POP3D_USER); |
111 fatalx("main: getpwnam " POP3D_USER); |
103 |
112 |
104 pop3_main(pair, pw); |
113 pop3_main(pair, pw, cert, key); |
105 close(pair[1]); |
114 close(pair[1]); |
106 setproctitle("[priv]"); |
115 setproctitle("[priv]"); |
107 logit(LOG_INFO, "pop3d ready; type:%s, path:%s", mtype_str, mpath); |
116 logit(LOG_INFO, "pop3d ready; type:%s, path:%s", mtype_str, mpath); |
108 event_init(); |
117 event_init(); |
109 signal_set(&ev_sigint, SIGINT, sig_handler, NULL); |
118 signal_set(&ev_sigint, SIGINT, sig_handler, NULL); |
231 static void |
240 static void |
232 usage(void) |
241 usage(void) |
233 { |
242 { |
234 extern char *__progname; |
243 extern char *__progname; |
235 |
244 |
236 fprintf(stderr, "usage: %s [-d] [-p path] [-t type]\n", __progname); |
245 fprintf(stderr, "usage: %s [-c certfile] [-d] " |
|
246 "[-k keyfile] [-p path] [-t type]\n", __progname); |
237 exit(EXIT_FAILURE); |
247 exit(EXIT_FAILURE); |
238 } |
248 } |
239 |
249 |