diff options
Diffstat (limited to 'contrib/blocklist/bin/blacklistd.c')
| -rw-r--r-- | contrib/blocklist/bin/blacklistd.c | 22 | 
1 files changed, 10 insertions, 12 deletions
diff --git a/contrib/blocklist/bin/blacklistd.c b/contrib/blocklist/bin/blacklistd.c index ded3075ed707..cb6ce6578d9c 100644 --- a/contrib/blocklist/bin/blacklistd.c +++ b/contrib/blocklist/bin/blacklistd.c @@ -1,4 +1,4 @@ -/*	$NetBSD: blocklistd.c,v 1.10 2025/03/26 17:09:35 christos Exp $	*/ +/*	$NetBSD: blocklistd.c,v 1.12 2025/10/25 18:43:51 christos Exp $	*/  /*-   * Copyright (c) 2015 The NetBSD Foundation, Inc. @@ -35,7 +35,7 @@  #ifdef HAVE_SYS_CDEFS_H  #include <sys/cdefs.h>  #endif -__RCSID("$NetBSD: blocklistd.c,v 1.10 2025/03/26 17:09:35 christos Exp $"); +__RCSID("$NetBSD: blocklistd.c,v 1.12 2025/10/25 18:43:51 christos Exp $");  #include <sys/types.h>  #include <sys/socket.h> @@ -191,12 +191,12 @@ process(bl_t bl)  	}  	if (getremoteaddress(bi, &rss, &rsl) == -1) -		goto out; +		return;  	if (debug || bi->bi_msg[0]) {  		sockaddr_snprintf(rbuf, sizeof(rbuf), "%a:%p", (void *)&rss);  		(*lfun)(bi->bi_msg[0] ? LOG_INFO : LOG_DEBUG, -		    "processing type=%d fd=%d remote=%s msg=%s uid=%lu gid=%lu", +		    "processing type=%d fd=%d remote=%s msg=\"%s\" uid=%lu gid=%lu",  		    bi->bi_type, bi->bi_fd, rbuf,  		    bi->bi_msg, (unsigned long)bi->bi_uid,  		    (unsigned long)bi->bi_gid); @@ -204,12 +204,12 @@ process(bl_t bl)  	if (conf_find(bi->bi_fd, bi->bi_uid, &rss, &c) == NULL) {  		(*lfun)(LOG_DEBUG, "no rule matched"); -		goto out; +		return;  	}  	if (state_get(state, &c, &dbi) == -1) -		goto out; +		return;  	if (debug) {  		char b1[128], b2[128]; @@ -226,7 +226,7 @@ process(bl_t bl)  		 * set the number of fails to be one less than the  		 * configured limit.  Fallthrough to the normal BL_ADD  		 * processing, which will increment the failure count -		 * to the threshhold, and block the abusive address. +		 * to the threshold, and block the abusive address.  		 */  		if (c.c_nfail != -1)  			dbi.count = c.c_nfail - 1; @@ -269,8 +269,6 @@ process(bl_t bl)  	state_put(state, &c, &dbi);  out: -	close(bi->bi_fd); -  	if (debug) {  		char b1[128], b2[128];  		(*lfun)(LOG_DEBUG, "%s: final db state for %s: count=%d/%d " @@ -331,8 +329,8 @@ again:  			(*lfun)(LOG_INFO, "released %s/%d:%d after %d seconds",  			    buf, c.c_lmask, c.c_port, c.c_duration);  		} -		state_del(state, &c); -		goto again; +		if (state_del(state, &c) == 0) +			goto again;  	}  } @@ -565,7 +563,7 @@ main(int argc, char *argv[])  			conf_parse(configfile);  		}  		ret = poll(pfd, (nfds_t)nfd, tout); -		if (debug) +		if (debug && ret != 0)  			(*lfun)(LOG_DEBUG, "received %d from poll()", ret);  		switch (ret) {  		case -1:  | 
