Commit 1103d9e6 1103d9e6e6eed5a15522a7fad0f6fd160394c7bf by Sergey Poznyakoff

New option --tls-required: do not allow

authentication until TLS negotiation succeeds.
New option --delete-expired: delete expired messages before
closing the mailbox.
1 parent 969a33e1
...@@ -38,8 +38,10 @@ int tls_available; ...@@ -38,8 +38,10 @@ int tls_available;
38 int tls_done; 38 int tls_done;
39 #endif /* WITH_TLS */ 39 #endif /* WITH_TLS */
40 40
41 int initial_state = AUTHORIZATION;
42
41 /* Number of child processes. */ 43 /* Number of child processes. */
42 volatile size_t children; 44 size_t children;
43 /* Should all the messages be undeleted on startup */ 45 /* Should all the messages be undeleted on startup */
44 int undelete_on_startup; 46 int undelete_on_startup;
45 #ifdef ENABLE_LOGIN_DELAY 47 #ifdef ENABLE_LOGIN_DELAY
...@@ -48,8 +50,8 @@ time_t login_delay = 0; ...@@ -48,8 +50,8 @@ time_t login_delay = 0;
48 char *login_stat_file = LOGIN_STAT_FILE; 50 char *login_stat_file = LOGIN_STAT_FILE;
49 #endif 51 #endif
50 52
51 /* Minimum advertise retention times of messages. */ 53 time_t expire = EXPIRE_NEVER; /* Expire messages after this number of days */
52 int expire = -1; 54 int expire_on_exit = 0; /* Delete expired messages on exit */
53 55
54 static int pop3d_mainloop __P ((int fd, FILE *, FILE *)); 56 static int pop3d_mainloop __P ((int fd, FILE *, FILE *));
55 static void pop3d_daemon_init __P ((void)); 57 static void pop3d_daemon_init __P ((void));
...@@ -61,9 +63,11 @@ static void pop3d_log_connection __P((int fd)); ...@@ -61,9 +63,11 @@ static void pop3d_log_connection __P((int fd));
61 const char *program_version = "pop3d (" PACKAGE_STRING ")"; 63 const char *program_version = "pop3d (" PACKAGE_STRING ")";
62 static char doc[] = N_("GNU pop3d -- the POP3 daemon"); 64 static char doc[] = N_("GNU pop3d -- the POP3 daemon");
63 65
64 #define OPT_LOGIN_DELAY 257 66 #define OPT_LOGIN_DELAY 257
65 #define OPT_STAT_FILE 258 67 #define OPT_STAT_FILE 258
66 #define OPT_EXPIRE 259 68 #define OPT_EXPIRE 259
69 #define OPT_EXPIRE_ON_EXIT 260
70 #define OPT_TLS_REQUIRED 261
67 71
68 static struct argp_option options[] = { 72 static struct argp_option options[] = {
69 {"undelete", 'u', NULL, 0, 73 {"undelete", 'u', NULL, 0,
...@@ -75,7 +79,13 @@ static struct argp_option options[] = { ...@@ -75,7 +79,13 @@ static struct argp_option options[] = {
75 N_("Name of login statistics file"), 0}, 79 N_("Name of login statistics file"), 0},
76 #endif 80 #endif
77 {"expire", OPT_EXPIRE, N_("DAYS"), 0, 81 {"expire", OPT_EXPIRE, N_("DAYS"), 0,
78 N_("Maximum retention period for messages in the maildrop, default -1 means NEVER"), 0}, 82 N_("Expire read messages after the given number of days"), 0},
83 {"delete-expired", OPT_EXPIRE_ON_EXIT, NULL, 0,
84 N_("Delete expired messages upon closing the mailbox"), 0},
85 #ifdef WITH_TLS
86 {"tls-required", OPT_TLS_REQUIRED, NULL, 0,
87 N_("Always require STLS before entering authentication phase")},
88 #endif
79 {NULL, 0, NULL, 0, NULL, 0} 89 {NULL, 0, NULL, 0, NULL, 0}
80 }; 90 };
81 91
...@@ -139,6 +149,16 @@ pop3d_parse_opt (int key, char *arg, struct argp_state *astate) ...@@ -139,6 +149,16 @@ pop3d_parse_opt (int key, char *arg, struct argp_state *astate)
139 exit (1); 149 exit (1);
140 } 150 }
141 break; 151 break;
152
153 case OPT_EXPIRE_ON_EXIT:
154 expire_on_exit = 1;
155 break;
156
157 #ifdef WITH_TLS
158 case OPT_TLS_REQUIRED:
159 initial_state = INITIAL;
160 break;
161 #endif
142 162
143 default: 163 default:
144 return ARGP_ERR_UNKNOWN; 164 return ARGP_ERR_UNKNOWN;
...@@ -165,7 +185,7 @@ main (int argc, char **argv) ...@@ -165,7 +185,7 @@ main (int argc, char **argv)
165 185
166 #ifdef USE_LIBPAM 186 #ifdef USE_LIBPAM
167 if (!pam_service) 187 if (!pam_service)
168 pam_service = (char *)"gnu-pop3d"; 188 pam_service = "gnu-pop3d";
169 #endif 189 #endif
170 190
171 if (daemon_param.mode == MODE_INTERACTIVE && isatty (0)) 191 if (daemon_param.mode == MODE_INTERACTIVE && isatty (0))
...@@ -313,7 +333,7 @@ pop3d_mainloop (int fd, FILE *infile, FILE *outfile) ...@@ -313,7 +333,7 @@ pop3d_mainloop (int fd, FILE *infile, FILE *outfile)
313 333
314 pop3d_setio (infile, outfile); 334 pop3d_setio (infile, outfile);
315 335
316 state = AUTHORIZATION; 336 state = initial_state;
317 337
318 pop3d_log_connection (fd); 338 pop3d_log_connection (fd);
319 339
......