dovecot-2.2: Earlier in_port_t fix created problems with service...
dovecot at dovecot.org
dovecot at dovecot.org
Sat Aug 29 21:47:40 UTC 2015
details: http://hg.dovecot.org/dovecot-2.2/rev/c53ccafc4a8e
changeset: 19041:c53ccafc4a8e
user: Stephan Bosch <stephan at rename-it.nl>
date: Sun Aug 30 00:46:32 2015 +0300
description:
Earlier in_port_t fix created problems with service listener configuration.
Listeners are disabled with port=0, which was not allowed anymore.
diffstat:
src/config/config-request.c | 4 +++-
src/lib-settings/settings-parser.c | 22 +++++++++++++++++++++-
src/lib-settings/settings-parser.h | 1 +
src/lib/net.c | 13 +++++++++++++
src/lib/net.h | 2 ++
src/master/master-settings.c | 2 +-
6 files changed, 41 insertions(+), 3 deletions(-)
diffs (146 lines):
diff -r 512a4792d9f5 -r c53ccafc4a8e src/config/config-request.c
--- a/src/config/config-request.c Sun Aug 30 00:42:16 2015 +0300
+++ b/src/config/config-request.c Sun Aug 30 00:46:32 2015 +0300
@@ -116,7 +116,8 @@
}
break;
}
- case SET_IN_PORT: {
+ case SET_IN_PORT:
+ case SET_IN_PORT_ZERO: {
const in_port_t *val = value, *dval = default_value;
if (dump_default || dval == NULL || *val != *dval)
@@ -253,6 +254,7 @@
case SET_UINT_OCT:
case SET_TIME:
case SET_IN_PORT:
+ case SET_IN_PORT_ZERO:
case SET_STR_VARS:
case SET_STR:
case SET_ENUM:
diff -r 512a4792d9f5 -r c53ccafc4a8e src/lib-settings/settings-parser.c
--- a/src/lib-settings/settings-parser.c Sun Aug 30 00:42:16 2015 +0300
+++ b/src/lib-settings/settings-parser.c Sun Aug 30 00:46:32 2015 +0300
@@ -595,6 +595,18 @@
}
static int
+get_in_port_zero(struct setting_parser_context *ctx, const char *value,
+ in_port_t *result_r)
+{
+ if (net_str2port(value, result_r) < 0) {
+ ctx->error = p_strdup_printf(ctx->parser_pool,
+ "Invalid port number %s", value);
+ return -1;
+ }
+ return 0;
+}
+
+static int
settings_parse(struct setting_parser_context *ctx, struct setting_link *link,
const struct setting_define *def,
const char *key, const char *value)
@@ -646,6 +658,10 @@
if (get_in_port(ctx, value, (in_port_t *)ptr) < 0)
return -1;
break;
+ case SET_IN_PORT_ZERO:
+ if (get_in_port_zero(ctx, value, (in_port_t *)ptr) < 0)
+ return -1;
+ break;
case SET_STR:
*((char **)ptr) = p_strdup(ctx->set_pool, value);
break;
@@ -1248,6 +1264,7 @@
case SET_TIME:
case SET_SIZE:
case SET_IN_PORT:
+ case SET_IN_PORT_ZERO:
case SET_STR:
case SET_ENUM:
case SET_STRLIST:
@@ -1344,6 +1361,7 @@
case SET_TIME:
case SET_SIZE:
case SET_IN_PORT:
+ case SET_IN_PORT_ZERO:
case SET_STR:
case SET_ENUM:
case SET_STRLIST:
@@ -1428,7 +1446,8 @@
*dest_size = *src_size;
break;
}
- case SET_IN_PORT: {
+ case SET_IN_PORT:
+ case SET_IN_PORT_ZERO: {
const in_port_t *src_size = src;
in_port_t *dest_size = dest;
@@ -1549,6 +1568,7 @@
case SET_TIME:
case SET_SIZE:
case SET_IN_PORT:
+ case SET_IN_PORT_ZERO:
case SET_STR_VARS:
case SET_STR:
case SET_ENUM:
diff -r 512a4792d9f5 -r c53ccafc4a8e src/lib-settings/settings-parser.h
--- a/src/lib-settings/settings-parser.h Sun Aug 30 00:42:16 2015 +0300
+++ b/src/lib-settings/settings-parser.h Sun Aug 30 00:46:32 2015 +0300
@@ -24,6 +24,7 @@
SET_TIME,
SET_SIZE,
SET_IN_PORT, /* internet port */
+ SET_IN_PORT_ZERO, /* internet port */
SET_STR,
SET_STR_VARS, /* string with %variables */
SET_ENUM,
diff -r 512a4792d9f5 -r c53ccafc4a8e src/lib/net.c
--- a/src/lib/net.c Sun Aug 30 00:42:16 2015 +0300
+++ b/src/lib/net.c Sun Aug 30 00:46:32 2015 +0300
@@ -957,6 +957,19 @@
return 0;
}
+int net_str2port_zero(const char *str, in_port_t *port_r)
+{
+ uintmax_t l;
+
+ if (str_to_uintmax(str, &l) < 0)
+ return -1;
+
+ if (l > (in_port_t)-1)
+ return -1;
+ *port_r = (in_port_t)l;
+ return 0;
+}
+
int net_ipv6_mapped_ipv4_convert(const struct ip_addr *src,
struct ip_addr *dest)
{
diff -r 512a4792d9f5 -r c53ccafc4a8e src/lib/net.h
--- a/src/lib/net.h Sun Aug 30 00:42:16 2015 +0300
+++ b/src/lib/net.h Sun Aug 30 00:46:32 2015 +0300
@@ -150,6 +150,8 @@
int net_addr2ip(const char *addr, struct ip_addr *ip);
/* char* -> net_port_t translation */
int net_str2port(const char *str, in_port_t *port_r);
+/* char* -> net_port_t translation (allows port zero) */
+int net_str2port_zero(const char *str, in_port_t *port_r);
/* Convert IPv6 mapped IPv4 address to an actual IPv4 address. Returns 0 if
successful, -1 if the source address isn't IPv6 mapped IPv4 address. */
diff -r 512a4792d9f5 -r c53ccafc4a8e src/master/master-settings.c
--- a/src/master/master-settings.c Sun Aug 30 00:42:16 2015 +0300
+++ b/src/master/master-settings.c Sun Aug 30 00:46:32 2015 +0300
@@ -62,7 +62,7 @@
static const struct setting_define inet_listener_setting_defines[] = {
DEF(SET_STR, name),
DEF(SET_STR, address),
- DEF(SET_IN_PORT, port),
+ DEF(SET_IN_PORT_ZERO, port),
DEF(SET_BOOL, ssl),
DEF(SET_BOOL, reuse_port),
DEF(SET_BOOL, haproxy),
More information about the dovecot-cvs
mailing list