dovecot-2.0-sslstream: doveadm who -1: Fixed filtering.

dovecot at dovecot.org dovecot at dovecot.org
Sat Feb 13 02:55:29 EET 2010


details:   http://hg.dovecot.org/dovecot-2.0-sslstream/rev/508f5536a0a7
changeset: 10152:508f5536a0a7
user:      Timo Sirainen <tss at iki.fi>
date:      Thu Oct 22 21:18:09 2009 -0400
description:
doveadm who -1: Fixed filtering.

diffstat:

1 file changed, 22 insertions(+), 4 deletions(-)
src/doveadm/doveadm-who.c |   26 ++++++++++++++++++++++----

diffs (53 lines):

diff -r 257bb6f74138 -r 508f5536a0a7 src/doveadm/doveadm-who.c
--- a/src/doveadm/doveadm-who.c	Thu Oct 22 21:15:37 2009 -0400
+++ b/src/doveadm/doveadm-who.c	Thu Oct 22 21:18:09 2009 -0400
@@ -156,8 +156,8 @@ static void who_lookup(struct who_contex
 	i_stream_destroy(&input);
 }
 
-static bool who_filter_match(const struct who_user *user,
-			     const struct who_filter *filter)
+static bool who_user_filter_match(const struct who_user *user,
+				  const struct who_filter *filter)
 {
 	if (filter->username != NULL) {
 		if (strstr(user->username, filter->username) == NULL)
@@ -194,7 +194,7 @@ static void who_print(struct who_context
 		const pid_t *pid;
 		bool first = TRUE;
 
-		if (!who_filter_match(user, &ctx->filter))
+		if (!who_user_filter_match(user, &ctx->filter))
 			continue;
 
 		printf("%-30s %2u %-5s ", user->username,
@@ -222,10 +222,28 @@ static void who_print(struct who_context
 	hash_table_iterate_deinit(&iter);
 }
 
-static void who_print_line(struct who_context *ctx ATTR_UNUSED,
+static bool who_line_filter_match(const struct who_line *line,
+				  const struct who_filter *filter)
+{
+	if (filter->username != NULL) {
+		if (strstr(line->username, filter->username) == NULL)
+			return FALSE;
+	}
+	if (filter->net_bits > 0) {
+		if (!net_is_in_network(&line->ip, &filter->net_ip,
+				       filter->net_bits))
+			return FALSE;
+	}
+	return TRUE;
+}
+
+static void who_print_line(struct who_context *ctx,
 			   const struct who_line *line)
 {
 	unsigned int i;
+
+	if (!who_line_filter_match(line, &ctx->filter))
+		return;
 
 	for (i = 0; i < line->refcount; i++) T_BEGIN {
 		printf("%-30s %-15s %-5s %ld\n", line->username,


More information about the dovecot-cvs mailing list