1
0
mirror of https://github.com/osmarks/ngircd.git synced 2024-10-27 20:36:18 +00:00

Don't abort startup when setgid/setuid() fails with EINVAL

Both setgid(2) as well as setuid(2) can fail with EINVAL in addition to
EPERM, their manual pages state "EINVAL: The user/group ID specified in
uid/gid is not valid in this user namespace ".

So not only treat EPERM as an "acceptable error" and continue with
logging the error, but do the same for EINVAL.

This was triggered by the Void Linux xbps-uunshare(1) tool used for
building "XBPS source packages" and reported by luca in #ngircd. Thanks!
This commit is contained in:
Alexander Barton 2024-04-13 19:43:54 +02:00
parent b77b9432c4
commit 90fb3cf0a2

View File

@ -722,7 +722,7 @@ NGIRCd_Init(bool NGIRCd_NoDaemon)
Log(LOG_ERR, "Can't change group ID to %s(%u): %s!", Log(LOG_ERR, "Can't change group ID to %s(%u): %s!",
grp ? grp->gr_name : "?", Conf_GID, grp ? grp->gr_name : "?", Conf_GID,
strerror(real_errno)); strerror(real_errno));
if (real_errno != EPERM) if (real_errno != EPERM && real_errno != EINVAL)
goto out; goto out;
} }
#ifdef HAVE_SETGROUPS #ifdef HAVE_SETGROUPS
@ -748,7 +748,7 @@ NGIRCd_Init(bool NGIRCd_NoDaemon)
Log(LOG_ERR, "Can't change user ID to %s(%u): %s!", Log(LOG_ERR, "Can't change user ID to %s(%u): %s!",
pwd ? pwd->pw_name : "?", Conf_UID, pwd ? pwd->pw_name : "?", Conf_UID,
strerror(real_errno)); strerror(real_errno));
if (real_errno != EPERM) if (real_errno != EPERM && real_errno != EINVAL)
goto out; goto out;
} }
} }