]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
doveadm who: Fixed listing LMTP sessions
authorTimo Sirainen <timo.sirainen@dovecot.fi>
Tue, 3 May 2016 17:20:28 +0000 (20:20 +0300)
committerTimo Sirainen <timo.sirainen@dovecot.fi>
Tue, 3 May 2016 17:20:28 +0000 (20:20 +0300)
src/doveadm/doveadm-who.c

index 0fd7d94c2d0a6366e4db824cd84b54a8839b95a9..3b75b9a9a69c824c8e90e9822a7a5ca761ce0cf8 100644 (file)
@@ -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;
 }