New options --login-delay, --stat-file
Showing
1 changed file
with
34 additions
and
1 deletions
... | @@ -41,6 +41,11 @@ int tls_done; | ... | @@ -41,6 +41,11 @@ int tls_done; |
41 | volatile size_t children; | 41 | volatile size_t children; |
42 | /* Should all the messages be undeleted on startup */ | 42 | /* Should all the messages be undeleted on startup */ |
43 | int undelete_on_startup; | 43 | int undelete_on_startup; |
44 | #ifdef ENABLE_LOGIN_DELAY | ||
45 | /* Minimum allowed delay between two successive logins */ | ||
46 | time_t login_delay = 0; | ||
47 | char *login_stat_file = LOGIN_STAT_FILE; | ||
48 | #endif | ||
44 | 49 | ||
45 | static int pop3d_mainloop __P ((int fd, FILE *, FILE *)); | 50 | static int pop3d_mainloop __P ((int fd, FILE *, FILE *)); |
46 | static void pop3d_daemon_init __P ((void)); | 51 | static void pop3d_daemon_init __P ((void)); |
... | @@ -52,9 +57,18 @@ static void pop3d_log_connection __P((int fd)); | ... | @@ -52,9 +57,18 @@ static void pop3d_log_connection __P((int fd)); |
52 | const char *program_version = "pop3d (" PACKAGE_STRING ")"; | 57 | const char *program_version = "pop3d (" PACKAGE_STRING ")"; |
53 | static char doc[] = N_("GNU pop3d -- the POP3 daemon"); | 58 | static char doc[] = N_("GNU pop3d -- the POP3 daemon"); |
54 | 59 | ||
60 | #define OPT_LOGIN_DELAY 257 | ||
61 | #define OPT_STAT_FILE 258 | ||
62 | |||
55 | static struct argp_option options[] = { | 63 | static struct argp_option options[] = { |
56 | {"undelete", 'u', NULL, 0, | 64 | {"undelete", 'u', NULL, 0, |
57 | N_("undelete all messages on startup"), 0}, | 65 | N_("Undelete all messages on startup"), 0}, |
66 | #ifdef ENABLE_LOGIN_DELAY | ||
67 | {"login-delay", OPT_LOGIN_DELAY, N_("SECONDS"), 0, | ||
68 | N_("Allowed delay between the two successive logins"), 0}, | ||
69 | {"stat-file", OPT_STAT_FILE, N_("FILENAME"), 0, | ||
70 | N_("Name of login statistics file"), 0}, | ||
71 | #endif | ||
58 | {NULL, 0, NULL, 0, NULL, 0} | 72 | {NULL, 0, NULL, 0, NULL, 0} |
59 | }; | 73 | }; |
60 | 74 | ||
... | @@ -83,6 +97,8 @@ static const char *pop3d_argp_capa[] = { | ... | @@ -83,6 +97,8 @@ static const char *pop3d_argp_capa[] = { |
83 | static error_t | 97 | static error_t |
84 | pop3d_parse_opt (int key, char *arg, struct argp_state *astate) | 98 | pop3d_parse_opt (int key, char *arg, struct argp_state *astate) |
85 | { | 99 | { |
100 | char *p; | ||
101 | |||
86 | switch (key) | 102 | switch (key) |
87 | { | 103 | { |
88 | case ARGP_KEY_INIT: | 104 | case ARGP_KEY_INIT: |
... | @@ -92,7 +108,22 @@ pop3d_parse_opt (int key, char *arg, struct argp_state *astate) | ... | @@ -92,7 +108,22 @@ pop3d_parse_opt (int key, char *arg, struct argp_state *astate) |
92 | case 'u': | 108 | case 'u': |
93 | undelete_on_startup = 1; | 109 | undelete_on_startup = 1; |
94 | break; | 110 | break; |
111 | |||
112 | #ifdef ENABLE_LOGIN_DELAY | ||
113 | case OPT_LOGIN_DELAY: | ||
114 | login_delay = strtoul (arg, &p, 10); | ||
115 | if (*p) | ||
116 | { | ||
117 | argp_error (state, _("Invalid number")); | ||
118 | exit (1); | ||
119 | } | ||
120 | break; | ||
121 | |||
122 | case OPT_STAT_FILE: | ||
123 | login_stat_file = arg; | ||
124 | break; | ||
95 | 125 | ||
126 | #endif | ||
96 | default: | 127 | default: |
97 | return ARGP_ERR_UNKNOWN; | 128 | return ARGP_ERR_UNKNOWN; |
98 | } | 129 | } |
... | @@ -394,6 +425,8 @@ pop3d_mainloop (int fd, FILE *infile, FILE *outfile) | ... | @@ -394,6 +425,8 @@ pop3d_mainloop (int fd, FILE *infile, FILE *outfile) |
394 | else if (status == ERR_TLS_ACTIVE) | 425 | else if (status == ERR_TLS_ACTIVE) |
395 | pop3d_outf ("-ERR " TLS_ACTIVE "\r\n"); | 426 | pop3d_outf ("-ERR " TLS_ACTIVE "\r\n"); |
396 | #endif /* WITH_TLS */ | 427 | #endif /* WITH_TLS */ |
428 | else if (status == ERR_LOGIN_DELAY) | ||
429 | pop3d_outf ("-ERR [LOGIN-DELAY] " LOGIN_DELAY "\r\n"); | ||
397 | else | 430 | else |
398 | pop3d_outf ("-ERR unknown error\r\n"); | 431 | pop3d_outf ("-ERR unknown error\r\n"); |
399 | 432 | ... | ... |
-
Please register or sign in to post a comment