From 2fa41e3cd6393ce4b5f7e6f6048d7706aa93ac0d Mon Sep 17 00:00:00 2001 From: Timo Sirainen Date: Tue, 3 May 2016 20:20:28 +0300 Subject: [PATCH] doveadm who: Fixed listing LMTP sessions --- src/doveadm/doveadm-who.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/doveadm/doveadm-who.c b/src/doveadm/doveadm-who.c index 0fd7d94c2d..3b75b9a9a6 100644 --- a/src/doveadm/doveadm-who.c +++ b/src/doveadm/doveadm-who.c @@ -59,6 +59,8 @@ static int who_parse_line(const char *line, struct who_line *line_r) memset(line_r, 0, sizeof(*line_r)); + /* ident = service/ip/username (imap, pop3) + or service/username (lmtp) */ p = strchr(ident, '/'); if (p == NULL) return -1; @@ -66,12 +68,15 @@ static int who_parse_line(const char *line, struct who_line *line_r) return -1; line_r->service = t_strdup_until(ident, p++); line_r->username = strchr(p, '/'); - if (line_r->username == NULL) - return -1; + if (line_r->username == NULL) { + /* no IP */ + line_r->username = p; + } else { + ip_str = t_strdup_until(p, line_r->username++); + (void)net_addr2ip(ip_str, &line_r->ip); + } if (str_to_uint(refcount_str, &line_r->refcount) < 0) return -1; - ip_str = t_strdup_until(p, line_r->username++); - (void)net_addr2ip(ip_str, &line_r->ip); return 0; } -- 2.47.3