changeset 20138:f35ab39bb50e

doveadm who: Fixed listing LMTP sessions
author Timo Sirainen <timo.sirainen@dovecot.fi>
date Tue, 03 May 2016 20:20:28 +0300
parents ef8a1db52ada
children 9290f0453eb9
files src/doveadm/doveadm-who.c
diffstat 1 files changed, 9 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/src/doveadm/doveadm-who.c	Mon May 02 23:43:15 2016 +0300
+++ b/src/doveadm/doveadm-who.c	Tue May 03 20:20:28 2016 +0300
@@ -59,6 +59,8 @@
 
 	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 @@
 		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;
 }