From nobody Tue Oct 11 18:49:13 2022 X-Original-To: dev-commits-ports-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4Mn4ZK2YM8z4fB3c; Tue, 11 Oct 2022 18:49:13 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Mn4ZK22wvz3KN6; Tue, 11 Oct 2022 18:49:13 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1665514153; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=T+th2xyerZbPTresAr90At4lra2vw/soKWR32jx/YWE=; b=qM0eXHUzXZ/7k90aoT8Vs5g7WS2rvQREe/bexblXDR3wiqcLW49eNX/a/SCgm8/8nauN8p u1v6BGzwJLH6d+SHY5+qGhP+HZuaLC/ezzigj6x4rUTE1NUg4PFGh58cKtgEXKlbjEIWK2 Mg/3DNYjZrt7Ig0xBHix3A4O5xzfTH5QvtKL13H16bX9zILbi09ArcohM/KLHl7IL00oB3 uuVLawiX9ugYrxi5ENmLI95w0CM0ZBI7tlmqYOiAylg0kGHL8M7WyAeMxCcL7Xr88WWphm 6Fd1XDgkgxg8oWs+EWC2ZjBXM/8686ZiZAfSEHcHl9cBM2fnMlbBOCMVAuQUqQ== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4Mn4ZK15Vpz13RB; Tue, 11 Oct 2022 18:49:13 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 29BInDhj062198; Tue, 11 Oct 2022 18:49:13 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 29BInDuI062197; Tue, 11 Oct 2022 18:49:13 GMT (envelope-from git) Date: Tue, 11 Oct 2022 18:49:13 GMT Message-Id: <202210111849.29BInDuI062197@gitrepo.freebsd.org> To: ports-committers@FreeBSD.org, dev-commits-ports-all@FreeBSD.org, dev-commits-ports-main@FreeBSD.org From: Alan Somers Subject: git: fe4dc1fd7105 - main - net/nss-pam-ldapd: use closefrom in nslcd List-Id: Commits to the main branch of the FreeBSD ports repository List-Archive: https://lists.freebsd.org/archives/dev-commits-ports-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-ports-main@freebsd.org X-BeenThere: dev-commits-ports-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: asomers X-Git-Repository: ports X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: fe4dc1fd7105b8d28031f9fab5b1260fbd0bbcaa Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1665514153; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=T+th2xyerZbPTresAr90At4lra2vw/soKWR32jx/YWE=; b=WBbEfeWRzyPU9ZGson429OZp2iGsZJ2St25yAOfMXkGOxiYhrGO7+ibJDvjuY6W1JvxvmL mKxKO9R8Wc/0kKZOqPKm9dA5pHXeTZPYgNs1cSjF9AZEyn0qBTrmnfrURF6wG+9bSspSz8 /JBUaFAs919YKhyYs2w4Ea9YLcxCzTKc8MV09Ipqji8HnFnbHdHAfTq8XS+CeETOZrA70y j6aO0QEuyuCkLYu5qgeGH4CRJ5Q+oEfoelr2BLsldxPq9n66iXz1Wnf7EPQZflGKK+AdCQ C/J3owcjXfe4fLlUsh3HdXr0nSZaL1/JeF4GS8Em0RIEoeB2aXZfvvOZYAhf8A== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1665514153; a=rsa-sha256; cv=none; b=jnOQ+xa6j5/QJI3Vul+QCZGAlhUCQIBF1ZpkUhp06xX/bStBZ0zT0arlohFh7ljE7YcgSl xLpBB5bQx8O/0EZwisyzyTmc3c99Q6HAmBw52A7q0n1EafH+tb60CiDrtI1zTnpjuNfgwG JBCgmDlcU88h9bT7S1NYwWOE0iS2+i0SLULHpieeZuda5J4PZ4cmMF3nMDOIWfhDQXLG25 Xc0e39wc4UNx7IhOBd4NXSfa6cJppYq9nvIwHUmZgfaDw5Bt7AS7hxFYNeRi+TeP2gjVRN vzKLwobu5ENb5ZQXC81eQEHvYWHEd4cYxTdUYQCQ4TGFZd77OU01UAEQMaH6Qw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by asomers (src committer): URL: https://cgit.FreeBSD.org/ports/commit/?id=fe4dc1fd7105b8d28031f9fab5b1260fbd0bbcaa commit fe4dc1fd7105b8d28031f9fab5b1260fbd0bbcaa Author: Alan Somers AuthorDate: 2022-10-11 18:44:51 +0000 Commit: Alan Somers CommitDate: 2022-10-11 18:48:50 +0000 net/nss-pam-ldapd: use closefrom in nslcd nslcd tries to close all file descriptors on startup. It does that by calling close() in a loop, running down from _SC_OPEN_MAX to 0. Since _SC_OPEN_MAX autoscales with available RAM, this can take more than a minute on large servers. The solution is to use closefrom. Upstream has already made that change in the master branch, but due to its slow release cadence we're applying it here as well. PR: 266970 Approved by: zi (maintainer) Sponsored by: Axcient --- net/nss-pam-ldapd/Makefile | 1 + net/nss-pam-ldapd/files/patch-config.h.in | 12 +++++++++ net/nss-pam-ldapd/files/patch-configure | 16 +++++++++++ net/nss-pam-ldapd/files/patch-nslcd_daemonize.c | 33 +++++++++++++++++++++++ net/nss-pam-ldapd/files/patch-nslcd_invalidator.c | 29 ++++++++++++++++++++ 5 files changed, 91 insertions(+) diff --git a/net/nss-pam-ldapd/Makefile b/net/nss-pam-ldapd/Makefile index 28d6cdc1f8fd..149d5edfd438 100644 --- a/net/nss-pam-ldapd/Makefile +++ b/net/nss-pam-ldapd/Makefile @@ -1,5 +1,6 @@ PORTNAME= nss-pam-ldapd PORTVERSION= 0.9.12 +PORTREVISION= 1 CATEGORIES= net MASTER_SITES= http://arthurdejong.org/nss-pam-ldapd/ \ ZI diff --git a/net/nss-pam-ldapd/files/patch-config.h.in b/net/nss-pam-ldapd/files/patch-config.h.in new file mode 100644 index 000000000000..e9ab0c2bf48b --- /dev/null +++ b/net/nss-pam-ldapd/files/patch-config.h.in @@ -0,0 +1,12 @@ +--- config.h.in.orig 2022-10-10 21:16:40 UTC ++++ config.h.in +@@ -30,6 +30,9 @@ + /* Define to 1 if you have the `clearenv' function. */ + #undef HAVE_CLEARENV + ++/* Define to 1 if you have the `closefrom' function. */ ++#undef HAVE_CLOSEFROM ++ + /* Define to 1 if you have the header file. */ + #undef HAVE_CTYPE_H + diff --git a/net/nss-pam-ldapd/files/patch-configure b/net/nss-pam-ldapd/files/patch-configure new file mode 100644 index 000000000000..d97e0366b1af --- /dev/null +++ b/net/nss-pam-ldapd/files/patch-configure @@ -0,0 +1,16 @@ +--- configure.orig 2021-11-20 13:07:41 UTC ++++ configure +@@ -9684,6 +9684,13 @@ then : + + fi + ++ ac_fn_c_check_func "$LINENO" "closefrom" "ac_cv_func_closefrom" ++if test "x$ac_cv_func_closefrom" = xyes ++then : ++ printf "%s\n" "#define HAVE_CLOSEFROM 1" >>confdefs.h ++ ++fi ++ + + # replace some functions if they are not on the system + ac_fn_c_check_func "$LINENO" "getopt_long" "ac_cv_func_getopt_long" diff --git a/net/nss-pam-ldapd/files/patch-nslcd_daemonize.c b/net/nss-pam-ldapd/files/patch-nslcd_daemonize.c new file mode 100644 index 000000000000..8a8901baaa80 --- /dev/null +++ b/net/nss-pam-ldapd/files/patch-nslcd_daemonize.c @@ -0,0 +1,33 @@ +--- nslcd/daemonize.c.orig 2022-10-11 18:31:44 UTC ++++ nslcd/daemonize.c +@@ -1,7 +1,7 @@ + /* + daemoninze.c - functions for properly daemonising an application + +- Copyright (C) 2014-2015 Arthur de Jong ++ Copyright (C) 2014-2022 Arthur de Jong + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public +@@ -43,15 +43,19 @@ void daemonize_closefds(void) + + void daemonize_closefds(void) + { +- int i; + /* close all file descriptors (except stdin/out/err) */ ++#ifdef HAVE_CLOSEFROM ++ closefrom(3); ++#else ++ int i; + i = sysconf(_SC_OPEN_MAX) - 1; + /* if the system does not have OPEN_MAX just close the first 32 and + hope we closed enough */ + if (i < 0) + i = 32; +- for (; i > 3; i--) ++ for (; i > 2; i--) + close(i); ++#endif + } + + void daemonize_redirect_stdio(void) diff --git a/net/nss-pam-ldapd/files/patch-nslcd_invalidator.c b/net/nss-pam-ldapd/files/patch-nslcd_invalidator.c new file mode 100644 index 000000000000..c4bfe8ffe3e7 --- /dev/null +++ b/net/nss-pam-ldapd/files/patch-nslcd_invalidator.c @@ -0,0 +1,29 @@ +--- nslcd/invalidator.c.orig 2021-11-15 19:40:49 UTC ++++ nslcd/invalidator.c +@@ -1,7 +1,7 @@ + /* + invalidator.c - functions for invalidating external caches + +- Copyright (C) 2013-2014 Arthur de Jong ++ Copyright (C) 2013-2022 Arthur de Jong + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public +@@ -97,6 +97,9 @@ static void exec_invalidate(const char *db) + { + case 0: /* we are the child */ + /* close all file descriptors */ ++#ifdef HAVE_CLOSEFROM ++ closefrom(0); ++#else + i = sysconf(_SC_OPEN_MAX) - 1; + /* if the system does not have OPEN_MAX just close the first 32 and + hope we have closed enough */ +@@ -104,6 +107,7 @@ static void exec_invalidate(const char *db) + i = 32; + for (; i >= 0; i--) + close(i); ++#endif + /* execute command */ + #ifdef HAVE_EXECVPE + execvpe(argv[0], argv, newenviron);