Mercurial > dovecot > core-2.2
annotate src/pop3/main.c @ 9219:97cdfeb57129 HEAD
Renamed headers to prevent collision if they were flattened on an install.
author | Mark Washenberger |
---|---|
date | Tue, 05 May 2009 11:57:04 -0400 |
parents | e4cc93190ec3 |
children | f41ce5378722 |
rev | line source |
---|---|
8590
b9faf4db2a9f
Updated copyright notices to include year 2009.
Timo Sirainen <tss@iki.fi>
parents:
8467
diff
changeset
|
1 /* Copyright (c) 2002-2009 Dovecot authors, see the included COPYING file */ |
1043
cacabd33c68a
Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
2 |
9219
97cdfeb57129
Renamed headers to prevent collision if they were flattened on an install.
Mark Washenberger
parents:
9177
diff
changeset
|
3 #include "pop3-common.h" |
1043
cacabd33c68a
Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
4 #include "ioloop.h" |
9080
e560b92ed763
imap and pop3 now use mail-storage-service API.
Timo Sirainen <tss@iki.fi>
parents:
9059
diff
changeset
|
5 #include "istream.h" |
e560b92ed763
imap and pop3 now use mail-storage-service API.
Timo Sirainen <tss@iki.fi>
parents:
9059
diff
changeset
|
6 #include "buffer.h" |
e560b92ed763
imap and pop3 now use mail-storage-service API.
Timo Sirainen <tss@iki.fi>
parents:
9059
diff
changeset
|
7 #include "base64.h" |
1043
cacabd33c68a
Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
8 #include "restrict-access.h" |
cacabd33c68a
Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
9 #include "fd-close-on-exec.h" |
cacabd33c68a
Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
10 #include "process-title.h" |
9080
e560b92ed763
imap and pop3 now use mail-storage-service API.
Timo Sirainen <tss@iki.fi>
parents:
9059
diff
changeset
|
11 #include "master-service.h" |
2976
96a4ab34c8f1
Added pop3_uidl_format setting.
Timo Sirainen <tss@iki.fi>
parents:
2952
diff
changeset
|
12 #include "var-expand.h" |
9080
e560b92ed763
imap and pop3 now use mail-storage-service API.
Timo Sirainen <tss@iki.fi>
parents:
9059
diff
changeset
|
13 #include "mail-storage-service.h" |
1043
cacabd33c68a
Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
14 |
2873
72f28a4b964d
Make sure imap or pop3 processes cannot be started from inetd.
Timo Sirainen <tss@iki.fi>
parents:
2719
diff
changeset
|
15 #include <stdio.h> |
1043
cacabd33c68a
Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
16 #include <stdlib.h> |
2873
72f28a4b964d
Make sure imap or pop3 processes cannot be started from inetd.
Timo Sirainen <tss@iki.fi>
parents:
2719
diff
changeset
|
17 #include <unistd.h> |
1043
cacabd33c68a
Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
18 |
cacabd33c68a
Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
19 #define IS_STANDALONE() \ |
cacabd33c68a
Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
20 (getenv("LOGGED_IN") == NULL) |
cacabd33c68a
Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
21 |
9080
e560b92ed763
imap and pop3 now use mail-storage-service API.
Timo Sirainen <tss@iki.fi>
parents:
9059
diff
changeset
|
22 struct master_service *service; |
1646 | 23 void (*hook_client_created)(struct client **client) = NULL; |
24 | |
4149
b10fa8ba01ca
When master dies (by closing log file descriptor), kill ourself also.
Timo Sirainen <tss@iki.fi>
parents:
4074
diff
changeset
|
25 static struct io *log_io = NULL; |
b10fa8ba01ca
When master dies (by closing log file descriptor), kill ourself also.
Timo Sirainen <tss@iki.fi>
parents:
4074
diff
changeset
|
26 |
6411
6a64e64fa3a3
Renamed __attr_*__ to ATTR_*. Renamed __attrs_used__ to ATTRS_DEFINED.
Timo Sirainen <tss@iki.fi>
parents:
6019
diff
changeset
|
27 static void log_error_callback(void *context ATTR_UNUSED) |
4149
b10fa8ba01ca
When master dies (by closing log file descriptor), kill ourself also.
Timo Sirainen <tss@iki.fi>
parents:
4074
diff
changeset
|
28 { |
8741
d74fdb84ab8b
pop3/imap: When master closes our log fd, don't die when trying to log disconnect reason.
Timo Sirainen <tss@iki.fi>
parents:
8590
diff
changeset
|
29 /* the log fd is closed, don't die when trying to log later */ |
d74fdb84ab8b
pop3/imap: When master closes our log fd, don't die when trying to log disconnect reason.
Timo Sirainen <tss@iki.fi>
parents:
8590
diff
changeset
|
30 i_set_failure_ignore_errors(TRUE); |
d74fdb84ab8b
pop3/imap: When master closes our log fd, don't die when trying to log disconnect reason.
Timo Sirainen <tss@iki.fi>
parents:
8590
diff
changeset
|
31 |
9080
e560b92ed763
imap and pop3 now use mail-storage-service API.
Timo Sirainen <tss@iki.fi>
parents:
9059
diff
changeset
|
32 master_service_stop(service); |
4149
b10fa8ba01ca
When master dies (by closing log file descriptor), kill ourself also.
Timo Sirainen <tss@iki.fi>
parents:
4074
diff
changeset
|
33 } |
b10fa8ba01ca
When master dies (by closing log file descriptor), kill ourself also.
Timo Sirainen <tss@iki.fi>
parents:
4074
diff
changeset
|
34 |
9080
e560b92ed763
imap and pop3 now use mail-storage-service API.
Timo Sirainen <tss@iki.fi>
parents:
9059
diff
changeset
|
35 static bool main_init(const struct pop3_settings *set, struct mail_user *user) |
1043
cacabd33c68a
Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
36 { |
7927
2351a81ce699
If commands are pipelined after the login command, pass them to the
Timo Sirainen <tss@iki.fi>
parents:
7109
diff
changeset
|
37 struct client *client; |
9080
e560b92ed763
imap and pop3 now use mail-storage-service API.
Timo Sirainen <tss@iki.fi>
parents:
9059
diff
changeset
|
38 const char *str; |
7927
2351a81ce699
If commands are pipelined after the login command, pass them to the
Timo Sirainen <tss@iki.fi>
parents:
7109
diff
changeset
|
39 bool ret = TRUE; |
1043
cacabd33c68a
Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
40 |
9002
9d0037a997f4
Initial commit for config rewrite.
Timo Sirainen <tss@iki.fi>
parents:
8590
diff
changeset
|
41 if (set->shutdown_clients) { |
4149
b10fa8ba01ca
When master dies (by closing log file descriptor), kill ourself also.
Timo Sirainen <tss@iki.fi>
parents:
4074
diff
changeset
|
42 /* If master dies, the log fd gets closed and we'll quit */ |
b10fa8ba01ca
When master dies (by closing log file descriptor), kill ourself also.
Timo Sirainen <tss@iki.fi>
parents:
4074
diff
changeset
|
43 log_io = io_add(STDERR_FILENO, IO_ERROR, |
b10fa8ba01ca
When master dies (by closing log file descriptor), kill ourself also.
Timo Sirainen <tss@iki.fi>
parents:
4074
diff
changeset
|
44 log_error_callback, NULL); |
b10fa8ba01ca
When master dies (by closing log file descriptor), kill ourself also.
Timo Sirainen <tss@iki.fi>
parents:
4074
diff
changeset
|
45 } |
b10fa8ba01ca
When master dies (by closing log file descriptor), kill ourself also.
Timo Sirainen <tss@iki.fi>
parents:
4074
diff
changeset
|
46 |
1043
cacabd33c68a
Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
47 clients_init(); |
cacabd33c68a
Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
48 |
9002
9d0037a997f4
Initial commit for config rewrite.
Timo Sirainen <tss@iki.fi>
parents:
8590
diff
changeset
|
49 client = client_create(0, 1, user, set); |
9d0037a997f4
Initial commit for config rewrite.
Timo Sirainen <tss@iki.fi>
parents:
8590
diff
changeset
|
50 if (client == NULL) |
9d0037a997f4
Initial commit for config rewrite.
Timo Sirainen <tss@iki.fi>
parents:
8590
diff
changeset
|
51 return FALSE; |
7927
2351a81ce699
If commands are pipelined after the login command, pass them to the
Timo Sirainen <tss@iki.fi>
parents:
7109
diff
changeset
|
52 |
7928
9e226056a208
Send login command OK reply in IMAP/POP3 process.
Timo Sirainen <tss@iki.fi>
parents:
7927
diff
changeset
|
53 if (!IS_STANDALONE()) |
9e226056a208
Send login command OK reply in IMAP/POP3 process.
Timo Sirainen <tss@iki.fi>
parents:
7927
diff
changeset
|
54 client_send_line(client, "+OK Logged in."); |
9e226056a208
Send login command OK reply in IMAP/POP3 process.
Timo Sirainen <tss@iki.fi>
parents:
7927
diff
changeset
|
55 |
7927
2351a81ce699
If commands are pipelined after the login command, pass them to the
Timo Sirainen <tss@iki.fi>
parents:
7109
diff
changeset
|
56 str = getenv("CLIENT_INPUT"); |
2351a81ce699
If commands are pipelined after the login command, pass them to the
Timo Sirainen <tss@iki.fi>
parents:
7109
diff
changeset
|
57 if (str != NULL) T_BEGIN { |
2351a81ce699
If commands are pipelined after the login command, pass them to the
Timo Sirainen <tss@iki.fi>
parents:
7109
diff
changeset
|
58 buffer_t *buf = t_base64_decode_str(str); |
2351a81ce699
If commands are pipelined after the login command, pass them to the
Timo Sirainen <tss@iki.fi>
parents:
7109
diff
changeset
|
59 if (buf->used > 0) { |
2351a81ce699
If commands are pipelined after the login command, pass them to the
Timo Sirainen <tss@iki.fi>
parents:
7109
diff
changeset
|
60 if (!i_stream_add_data(client->input, buf->data, |
2351a81ce699
If commands are pipelined after the login command, pass them to the
Timo Sirainen <tss@iki.fi>
parents:
7109
diff
changeset
|
61 buf->used)) |
2351a81ce699
If commands are pipelined after the login command, pass them to the
Timo Sirainen <tss@iki.fi>
parents:
7109
diff
changeset
|
62 i_panic("Couldn't add client input to stream"); |
2351a81ce699
If commands are pipelined after the login command, pass them to the
Timo Sirainen <tss@iki.fi>
parents:
7109
diff
changeset
|
63 ret = client_handle_input(client); |
2351a81ce699
If commands are pipelined after the login command, pass them to the
Timo Sirainen <tss@iki.fi>
parents:
7109
diff
changeset
|
64 } |
2351a81ce699
If commands are pipelined after the login command, pass them to the
Timo Sirainen <tss@iki.fi>
parents:
7109
diff
changeset
|
65 } T_END; |
2351a81ce699
If commands are pipelined after the login command, pass them to the
Timo Sirainen <tss@iki.fi>
parents:
7109
diff
changeset
|
66 return ret; |
1043
cacabd33c68a
Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
67 } |
cacabd33c68a
Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
68 |
cacabd33c68a
Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
69 static void main_deinit(void) |
cacabd33c68a
Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
70 { |
4149
b10fa8ba01ca
When master dies (by closing log file descriptor), kill ourself also.
Timo Sirainen <tss@iki.fi>
parents:
4074
diff
changeset
|
71 if (log_io != NULL) |
b10fa8ba01ca
When master dies (by closing log file descriptor), kill ourself also.
Timo Sirainen <tss@iki.fi>
parents:
4074
diff
changeset
|
72 io_remove(&log_io); |
4183
32b5045f8d80
Destroy client connection at deinit before unloading modules.
Timo Sirainen <tss@iki.fi>
parents:
4165
diff
changeset
|
73 clients_deinit(); |
1043
cacabd33c68a
Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
74 } |
cacabd33c68a
Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
75 |
9159
6324a79d3ee1
Initial commit for v2.0 master rewrite. Several features are still missing.
Timo Sirainen <tss@iki.fi>
parents:
9147
diff
changeset
|
76 static void client_connected(const struct master_service_connection *conn) |
6324a79d3ee1
Initial commit for v2.0 master rewrite. Several features are still missing.
Timo Sirainen <tss@iki.fi>
parents:
9147
diff
changeset
|
77 { |
6324a79d3ee1
Initial commit for v2.0 master rewrite. Several features are still missing.
Timo Sirainen <tss@iki.fi>
parents:
9147
diff
changeset
|
78 /* we can't handle this yet */ |
6324a79d3ee1
Initial commit for v2.0 master rewrite. Several features are still missing.
Timo Sirainen <tss@iki.fi>
parents:
9147
diff
changeset
|
79 (void)close(conn->fd); |
6324a79d3ee1
Initial commit for v2.0 master rewrite. Several features are still missing.
Timo Sirainen <tss@iki.fi>
parents:
9147
diff
changeset
|
80 } |
6324a79d3ee1
Initial commit for v2.0 master rewrite. Several features are still missing.
Timo Sirainen <tss@iki.fi>
parents:
9147
diff
changeset
|
81 |
9080
e560b92ed763
imap and pop3 now use mail-storage-service API.
Timo Sirainen <tss@iki.fi>
parents:
9059
diff
changeset
|
82 int main(int argc, char *argv[], char *envp[]) |
1043
cacabd33c68a
Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
83 { |
9106
fce3926fe910
mail_storage_service_init*() can now take multiple set_roots.
Timo Sirainen <tss@iki.fi>
parents:
9080
diff
changeset
|
84 const struct setting_parser_info *set_roots[] = { |
fce3926fe910
mail_storage_service_init*() can now take multiple set_roots.
Timo Sirainen <tss@iki.fi>
parents:
9080
diff
changeset
|
85 &pop3_setting_parser_info, |
fce3926fe910
mail_storage_service_init*() can now take multiple set_roots.
Timo Sirainen <tss@iki.fi>
parents:
9080
diff
changeset
|
86 NULL |
fce3926fe910
mail_storage_service_init*() can now take multiple set_roots.
Timo Sirainen <tss@iki.fi>
parents:
9080
diff
changeset
|
87 }; |
9080
e560b92ed763
imap and pop3 now use mail-storage-service API.
Timo Sirainen <tss@iki.fi>
parents:
9059
diff
changeset
|
88 enum master_service_flags service_flags = 0; |
e560b92ed763
imap and pop3 now use mail-storage-service API.
Timo Sirainen <tss@iki.fi>
parents:
9059
diff
changeset
|
89 enum mail_storage_service_flags storage_service_flags = |
e560b92ed763
imap and pop3 now use mail-storage-service API.
Timo Sirainen <tss@iki.fi>
parents:
9059
diff
changeset
|
90 MAIL_STORAGE_SERVICE_FLAG_DISALLOW_ROOT; |
9147
bf448752f6c4
Pass remote/local IPs to mail_users. Standalone mail programs now log with mail_log_prefix.
Timo Sirainen <tss@iki.fi>
parents:
9106
diff
changeset
|
91 struct mail_storage_service_input input; |
9080
e560b92ed763
imap and pop3 now use mail-storage-service API.
Timo Sirainen <tss@iki.fi>
parents:
9059
diff
changeset
|
92 struct mail_user *mail_user; |
9002
9d0037a997f4
Initial commit for config rewrite.
Timo Sirainen <tss@iki.fi>
parents:
8590
diff
changeset
|
93 const struct pop3_settings *set; |
9147
bf448752f6c4
Pass remote/local IPs to mail_users. Standalone mail programs now log with mail_log_prefix.
Timo Sirainen <tss@iki.fi>
parents:
9106
diff
changeset
|
94 const char *value; |
9080
e560b92ed763
imap and pop3 now use mail-storage-service API.
Timo Sirainen <tss@iki.fi>
parents:
9059
diff
changeset
|
95 int c; |
9002
9d0037a997f4
Initial commit for config rewrite.
Timo Sirainen <tss@iki.fi>
parents:
8590
diff
changeset
|
96 |
1043
cacabd33c68a
Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
97 #ifdef DEBUG |
9002
9d0037a997f4
Initial commit for config rewrite.
Timo Sirainen <tss@iki.fi>
parents:
8590
diff
changeset
|
98 if (!IS_STANDALONE() && getenv("GDB") == NULL) |
1043
cacabd33c68a
Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
99 fd_debug_verify_leaks(3, 1024); |
cacabd33c68a
Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
100 #endif |
2873
72f28a4b964d
Make sure imap or pop3 processes cannot be started from inetd.
Timo Sirainen <tss@iki.fi>
parents:
2719
diff
changeset
|
101 if (IS_STANDALONE() && getuid() == 0 && |
72f28a4b964d
Make sure imap or pop3 processes cannot be started from inetd.
Timo Sirainen <tss@iki.fi>
parents:
2719
diff
changeset
|
102 net_getpeername(1, NULL, NULL) == 0) { |
72f28a4b964d
Make sure imap or pop3 processes cannot be started from inetd.
Timo Sirainen <tss@iki.fi>
parents:
2719
diff
changeset
|
103 printf("-ERR pop3 binary must not be started from " |
72f28a4b964d
Make sure imap or pop3 processes cannot be started from inetd.
Timo Sirainen <tss@iki.fi>
parents:
2719
diff
changeset
|
104 "inetd, use pop3-login instead.\n"); |
72f28a4b964d
Make sure imap or pop3 processes cannot be started from inetd.
Timo Sirainen <tss@iki.fi>
parents:
2719
diff
changeset
|
105 return 1; |
72f28a4b964d
Make sure imap or pop3 processes cannot be started from inetd.
Timo Sirainen <tss@iki.fi>
parents:
2719
diff
changeset
|
106 } |
72f28a4b964d
Make sure imap or pop3 processes cannot be started from inetd.
Timo Sirainen <tss@iki.fi>
parents:
2719
diff
changeset
|
107 |
9080
e560b92ed763
imap and pop3 now use mail-storage-service API.
Timo Sirainen <tss@iki.fi>
parents:
9059
diff
changeset
|
108 if (IS_STANDALONE()) |
e560b92ed763
imap and pop3 now use mail-storage-service API.
Timo Sirainen <tss@iki.fi>
parents:
9059
diff
changeset
|
109 service_flags |= MASTER_SERVICE_FLAG_STANDALONE; |
e560b92ed763
imap and pop3 now use mail-storage-service API.
Timo Sirainen <tss@iki.fi>
parents:
9059
diff
changeset
|
110 else |
e560b92ed763
imap and pop3 now use mail-storage-service API.
Timo Sirainen <tss@iki.fi>
parents:
9059
diff
changeset
|
111 service_flags |= MAIL_STORAGE_SERVICE_FLAG_DISALLOW_ROOT; |
e560b92ed763
imap and pop3 now use mail-storage-service API.
Timo Sirainen <tss@iki.fi>
parents:
9059
diff
changeset
|
112 |
e560b92ed763
imap and pop3 now use mail-storage-service API.
Timo Sirainen <tss@iki.fi>
parents:
9059
diff
changeset
|
113 service = master_service_init("pop3", service_flags, argc, argv); |
e560b92ed763
imap and pop3 now use mail-storage-service API.
Timo Sirainen <tss@iki.fi>
parents:
9059
diff
changeset
|
114 while ((c = getopt(argc, argv, master_service_getopt_string())) > 0) { |
e560b92ed763
imap and pop3 now use mail-storage-service API.
Timo Sirainen <tss@iki.fi>
parents:
9059
diff
changeset
|
115 if (!master_service_parse_option(service, c, optarg)) |
9159
6324a79d3ee1
Initial commit for v2.0 master rewrite. Several features are still missing.
Timo Sirainen <tss@iki.fi>
parents:
9147
diff
changeset
|
116 exit(FATAL_DEFAULT); |
9080
e560b92ed763
imap and pop3 now use mail-storage-service API.
Timo Sirainen <tss@iki.fi>
parents:
9059
diff
changeset
|
117 } |
9147
bf448752f6c4
Pass remote/local IPs to mail_users. Standalone mail programs now log with mail_log_prefix.
Timo Sirainen <tss@iki.fi>
parents:
9106
diff
changeset
|
118 |
bf448752f6c4
Pass remote/local IPs to mail_users. Standalone mail programs now log with mail_log_prefix.
Timo Sirainen <tss@iki.fi>
parents:
9106
diff
changeset
|
119 memset(&input, 0, sizeof(input)); |
bf448752f6c4
Pass remote/local IPs to mail_users. Standalone mail programs now log with mail_log_prefix.
Timo Sirainen <tss@iki.fi>
parents:
9106
diff
changeset
|
120 input.username = getenv("USER"); |
bf448752f6c4
Pass remote/local IPs to mail_users. Standalone mail programs now log with mail_log_prefix.
Timo Sirainen <tss@iki.fi>
parents:
9106
diff
changeset
|
121 if (input.username == NULL) { |
9080
e560b92ed763
imap and pop3 now use mail-storage-service API.
Timo Sirainen <tss@iki.fi>
parents:
9059
diff
changeset
|
122 if (IS_STANDALONE()) |
9147
bf448752f6c4
Pass remote/local IPs to mail_users. Standalone mail programs now log with mail_log_prefix.
Timo Sirainen <tss@iki.fi>
parents:
9106
diff
changeset
|
123 input.username = getlogin(); |
bf448752f6c4
Pass remote/local IPs to mail_users. Standalone mail programs now log with mail_log_prefix.
Timo Sirainen <tss@iki.fi>
parents:
9106
diff
changeset
|
124 if (input.username == NULL) |
9080
e560b92ed763
imap and pop3 now use mail-storage-service API.
Timo Sirainen <tss@iki.fi>
parents:
9059
diff
changeset
|
125 i_fatal("USER environment missing"); |
e560b92ed763
imap and pop3 now use mail-storage-service API.
Timo Sirainen <tss@iki.fi>
parents:
9059
diff
changeset
|
126 } |
9147
bf448752f6c4
Pass remote/local IPs to mail_users. Standalone mail programs now log with mail_log_prefix.
Timo Sirainen <tss@iki.fi>
parents:
9106
diff
changeset
|
127 if ((value = getenv("IP")) != NULL) |
bf448752f6c4
Pass remote/local IPs to mail_users. Standalone mail programs now log with mail_log_prefix.
Timo Sirainen <tss@iki.fi>
parents:
9106
diff
changeset
|
128 net_addr2ip(value, &input.remote_ip); |
bf448752f6c4
Pass remote/local IPs to mail_users. Standalone mail programs now log with mail_log_prefix.
Timo Sirainen <tss@iki.fi>
parents:
9106
diff
changeset
|
129 if ((value = getenv("LOCAL_IP")) != NULL) |
bf448752f6c4
Pass remote/local IPs to mail_users. Standalone mail programs now log with mail_log_prefix.
Timo Sirainen <tss@iki.fi>
parents:
9106
diff
changeset
|
130 net_addr2ip(value, &input.local_ip); |
9080
e560b92ed763
imap and pop3 now use mail-storage-service API.
Timo Sirainen <tss@iki.fi>
parents:
9059
diff
changeset
|
131 |
9147
bf448752f6c4
Pass remote/local IPs to mail_users. Standalone mail programs now log with mail_log_prefix.
Timo Sirainen <tss@iki.fi>
parents:
9106
diff
changeset
|
132 mail_user = mail_storage_service_init_user(service, &input, set_roots, |
9080
e560b92ed763
imap and pop3 now use mail-storage-service API.
Timo Sirainen <tss@iki.fi>
parents:
9059
diff
changeset
|
133 storage_service_flags); |
e560b92ed763
imap and pop3 now use mail-storage-service API.
Timo Sirainen <tss@iki.fi>
parents:
9059
diff
changeset
|
134 set = mail_storage_service_get_settings(service); |
e560b92ed763
imap and pop3 now use mail-storage-service API.
Timo Sirainen <tss@iki.fi>
parents:
9059
diff
changeset
|
135 restrict_access_allow_coredumps(TRUE); |
1043
cacabd33c68a
Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
136 |
cacabd33c68a
Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
137 process_title_init(argv, envp); |
cacabd33c68a
Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
138 |
9080
e560b92ed763
imap and pop3 now use mail-storage-service API.
Timo Sirainen <tss@iki.fi>
parents:
9059
diff
changeset
|
139 /* fake that we're running, so we know if client was destroyed |
e560b92ed763
imap and pop3 now use mail-storage-service API.
Timo Sirainen <tss@iki.fi>
parents:
9059
diff
changeset
|
140 while initializing */ |
e560b92ed763
imap and pop3 now use mail-storage-service API.
Timo Sirainen <tss@iki.fi>
parents:
9059
diff
changeset
|
141 io_loop_set_running(current_ioloop); |
e560b92ed763
imap and pop3 now use mail-storage-service API.
Timo Sirainen <tss@iki.fi>
parents:
9059
diff
changeset
|
142 |
e560b92ed763
imap and pop3 now use mail-storage-service API.
Timo Sirainen <tss@iki.fi>
parents:
9059
diff
changeset
|
143 if (main_init(set, mail_user)) |
9159
6324a79d3ee1
Initial commit for v2.0 master rewrite. Several features are still missing.
Timo Sirainen <tss@iki.fi>
parents:
9147
diff
changeset
|
144 master_service_run(service, client_connected); |
9080
e560b92ed763
imap and pop3 now use mail-storage-service API.
Timo Sirainen <tss@iki.fi>
parents:
9059
diff
changeset
|
145 |
1043
cacabd33c68a
Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
146 main_deinit(); |
9080
e560b92ed763
imap and pop3 now use mail-storage-service API.
Timo Sirainen <tss@iki.fi>
parents:
9059
diff
changeset
|
147 mail_storage_service_deinit_user(); |
e560b92ed763
imap and pop3 now use mail-storage-service API.
Timo Sirainen <tss@iki.fi>
parents:
9059
diff
changeset
|
148 master_service_deinit(&service); |
1043
cacabd33c68a
Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
149 return 0; |
cacabd33c68a
Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
150 } |