From: Stefan Sperling Subject: Re: [PATCH] privsep.c: ignore closefrom() return value To: Anna “CyberTailor” Cc: gameoftrees@openbsd.org Date: Mon, 6 Dec 2021 11:54:13 +0100 On Mon, Dec 06, 2021 at 03:19:04PM +0500, Anna “CyberTailor” wrote: > closefrom(2) is void on FreeBSD and libbsd, so its return value has to > be ignored. > > https://bugs.gentoo.org/828003 > --- > lib/privsep.c | 6 ++---- > 1 file changed, 2 insertions(+), 4 deletions(-) This patch should be applied to -portable only. On OpenBSD there are failure conditions: closefrom() will fail if: [EBADF] fd is greater than all open file descriptors. [EINTR] An interrupt was received. Especially EINTR seems important. It means closefrom was interrupted and could not complete its task. > diff --git a/lib/privsep.c b/lib/privsep.c > index ca518be1..8f233724 100644 > --- a/lib/privsep.c > +++ b/lib/privsep.c > @@ -2766,10 +2766,8 @@ got_privsep_exec_child(int imsg_fds[2], const char *path, const char *repo_path) > fprintf(stderr, "%s: %s\n", getprogname(), strerror(errno)); > _exit(1); > } > - if (closefrom(GOT_IMSG_FD_CHILD + 1) == -1) { > - fprintf(stderr, "%s: %s\n", getprogname(), strerror(errno)); > - _exit(1); > - } > + > + closefrom(GOT_IMSG_FD_CHILD + 1); > > if (execl(path, path, repo_path, (char *)NULL) == -1) { > fprintf(stderr, "%s: %s: %s\n", getprogname(), path, > -- > 2.34.1 > >