From: Timo Sirainen Date: Tue, 3 May 2016 17:20:28 +0000 (+0300) Subject: doveadm who: Fixed listing LMTP sessions X-Git-Tag: 2.3.0.rc1~3843 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=2fa41e3cd6393ce4b5f7e6f6048d7706aa93ac0d;p=thirdparty%2Fdovecot%2Fcore.git doveadm who: Fixed listing LMTP sessions --- 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; }