Lines Matching refs:user
26 static void who_user_ip(const struct who_user *user, struct ip_addr *ip_r)
28 if (array_count(&user->ips) == 0)
31 const struct ip_addr *ip = array_idx(&user->ips, 0);
36 static unsigned int who_user_hash(const struct who_user *user)
39 unsigned int hash = str_hash(user->service);
41 if (user->username[0] != '\0')
42 hash += str_hash(user->username);
44 who_user_ip(user, &ip);
70 who_user_has_ip(const struct who_user *user, const struct ip_addr *ip)
74 array_foreach(&user->ips, ex_ip) {
112 static bool who_user_has_pid(struct who_user *user, pid_t pid)
116 array_foreach(&user->pids, ex_pid) {
126 struct who_user *user, lookup_user;
131 user = hash_table_lookup(ctx->users, &lookup_user);
132 if (user == NULL) {
133 user = p_new(ctx->pool, struct who_user, 1);
134 user->username = p_strdup(ctx->pool, line->username);
135 user->service = p_strdup(ctx->pool, line->service);
136 p_array_init(&user->ips, ctx->pool, 3);
137 p_array_init(&user->pids, ctx->pool, 8);
138 hash_table_insert(ctx->users, user, user);
140 user->connection_count += line->refcount;
142 if (line->ip.family != 0 && !who_user_has_ip(user, &line->ip))
143 array_append(&user->ips, &line->ip, 1);
145 if (!who_user_has_pid(user, line->pid))
146 array_append(&user->pids, &line->pid, 1);
209 static bool who_user_filter_match(const struct who_user *user,
213 if (!wildcard_match_icase(user->username, filter->username))
220 array_foreach(&user->ips, ip) {
233 static void who_print_user(const struct who_user *user)
239 doveadm_print(user->username);
240 doveadm_print(dec2str(user->connection_count));
241 doveadm_print(user->service);
244 array_foreach(&user->pids, pid)
253 array_foreach(&user->ips, ip)
264 struct who_user *user;
274 while (hash_table_iterate(iter, ctx->users, &user, &user)) {
275 if (who_user_filter_match(user, &ctx->filter)) T_BEGIN {
276 who_print_user(user);
355 .usage = "[-a <anvil socket path>] [-1] [<user mask>] [<ip/bits>]",