From 74644f82cbebd4aae8c21c29a4ddbe9e1d0e9e5a Mon Sep 17 00:00:00 2001 From: Nir Soffer Date: Tue, 17 Sep 2024 22:42:59 +0300 Subject: [PATCH] Fix incorrect getgrnam error handling getgrent(3) says: Note that programs must explicitly set errno to zero before calling any of these functions if they need to distinguish between a non-existent entry and an error. We didn't so we could log the wrong error based on previous failed call and confuse the user. Signed-off-by: Nir Soffer --- main.c | 1 + 1 file changed, 1 insertion(+) diff --git a/main.c b/main.c index 33b536b..a521cb3 100644 --- a/main.c +++ b/main.c @@ -348,6 +348,7 @@ static int socket_bindlisten(const char *socket_path, goto err; } if (socket_group != NULL) { + errno = 0; struct group *grp = getgrnam(socket_group); /* Do not free */ if (grp == NULL) { if (errno != 0)