From nobody Sun Jan 12 21:01:21 2025 X-Original-To: dev-commits-ports-all@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 4YWSVT2C0yz5jp3D; Sun, 12 Jan 2025 21:01:21 +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 "R11" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4YWSVT1bZgz4YQC; Sun, 12 Jan 2025 21:01:21 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1736715681; 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=VdLXArcZ6sSi26FYkvNk2LKvB1MHPLFIt1JqqCcsWgY=; b=v16c48Yzpr5N6OSAHnivHCwKjbWEXInE/+4FOfrx7lK/u/HMBy/18LG852wdsAxA9+leVy /0G02Yl8iay9xS4q6Ct0d+3kPLL4jHY5CWp4bEhhqMb7gNWaIop5kXEnB+8dih2JzRwMp+ q1t85H1edJ8hloTvpPgmUppUoXizdYK1DJQ9M8Cnhhvso98dCTnx5o+Qg1t+/SvdVi/GNi KWQ6OD6iyIuYgHgQKfFQVwWhVTWSd7i/rklw4fpfXBCUrGBCRkl4cemtEdumMMB/nX6I2s ve9piW4rW2IgJRtMLxNuLXFENnDKFsWDerNAcgPdmuBPScGEUFOPZrO/1MgKtw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1736715681; 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=VdLXArcZ6sSi26FYkvNk2LKvB1MHPLFIt1JqqCcsWgY=; b=joclY0wRAAMtNzol0Nsl56xDxZdjc1qKf+W8LuD/m7DlI9Los+WM36b9qvOlSzmUeBBCP/ NluDLfCGd/azL1yIgxOLAPTNZKKLm01Lx16OEL6QXtTCWQCa7ySs3Jv7p/PbWaeZWKxj9R s40ULNIQL75BR0NQLCVUq7wnimfRUiWEl3mR0BkqM8m/M2CYBfkEIZeBF2GUvJwFStR0KV vUOUHHj0FlGWCKgDu6amiRzO9Yof0DnQI29cjTrUykNDdMFkOjFUEy2lO9P0W/Vh48x0ug 5peIkVOesmHJdq0nQzpGgVEORZjeE+37Kqwi5uQ80z9DemdyHAizcgNwydlyKw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1736715681; a=rsa-sha256; cv=none; b=HyUsHef8oMOWQbHwTlhgvX65odXgf6mYvgVKjN09z8qS6RSYVJ7sPwMAT3Iyyzq8C+AOBY +mLa/gvRHZ1UgzBs5zI4J1TrDFRJAb3IQxIllhapYAZrfS5z2CsO/QiPmixzy3VmEC35Rm Y9sp/vxVfatH2RmKgzz3+vjox5+a1hW6DXhzmQ16a7NtFPG2y0IlsD2cDqTVznr+oVWFPN wvFwNoRedm6DhcnhN2qdnznSvYyZrVl2CfU4DBd0Zs/0GW1hvCnWhzQkBCkRk9dZujnbAP 9S3s3pd/JPUaHs4uM0Yrs+DWuazphih8DbxHymA3w0EdSlrOWMLqXttcKcM5aw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none 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 4YWSVT1B9wz10RM; Sun, 12 Jan 2025 21:01:21 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 50CL1LWK014643; Sun, 12 Jan 2025 21:01:21 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 50CL1LlA014640; Sun, 12 Jan 2025 21:01:21 GMT (envelope-from git) Date: Sun, 12 Jan 2025 21:01:21 GMT Message-Id: <202501122101.50CL1LlA014640@gitrepo.freebsd.org> To: ports-committers@FreeBSD.org, dev-commits-ports-all@FreeBSD.org, dev-commits-ports-main@FreeBSD.org From: Michael Osipov Subject: git: f3ab3f3b2b71 - main - net/samba419: Dynamically calculate FreeBSD proc_fd_pattern List-Id: Commit messages for all branches of the ports repository List-Archive: https://lists.freebsd.org/archives/dev-commits-ports-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-ports-all@freebsd.org Sender: owner-dev-commits-ports-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: michaelo X-Git-Repository: ports X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: f3ab3f3b2b7166cc33007f454b744123382c4b8a Auto-Submitted: auto-generated The branch main has been updated by michaelo: URL: https://cgit.FreeBSD.org/ports/commit/?id=f3ab3f3b2b7166cc33007f454b744123382c4b8a commit f3ab3f3b2b7166cc33007f454b744123382c4b8a Author: Timur I. Bakeyev AuthorDate: 2025-01-09 18:15:40 +0000 Commit: Michael Osipov CommitDate: 2025-01-12 21:00:34 +0000 net/samba419: Dynamically calculate FreeBSD proc_fd_pattern Port timur's patch for dynamic calcuation of the proc fd (fdescfs) pattern mounted by the samba_server RC script from net/samba416. Tested by: michaelo Approved by: jrm (mentor), mikael, timur MFH: 2025Q1 Differential Revision: https://reviews.freebsd.org/D48416 --- net/samba419/Makefile | 3 +- ...s3-lib-system-add-FreeBSD-proc_fd_pattern.patch | 149 +++++++++++++++++++++ ...0-Fix-pathref-handling-for-FreeBSD-13plus.patch | 11 -- 3 files changed, 151 insertions(+), 12 deletions(-) diff --git a/net/samba419/Makefile b/net/samba419/Makefile index 54b0614a6d81..7849996e83c0 100644 --- a/net/samba419/Makefile +++ b/net/samba419/Makefile @@ -1,6 +1,6 @@ PORTNAME= ${SAMBA4_BASENAME}419 PORTVERSION= ${SAMBA4_VERSION} -PORTREVISION= 3 +PORTREVISION= 4 CATEGORIES?= net MASTER_SITES= SAMBA/samba/stable SAMBA/samba/rc DISTNAME= ${SAMBA4_DISTNAME} @@ -45,6 +45,7 @@ EXTRA_PATCHES= \ ${PATCHDIR}/0026-vfs-add-a-compatibility-option-to-the-vfs_streams_xa.patch:-p1 \ ${PATCHDIR}/0027-Add-VFS-module-vfs_freebsd-that-implements-FreeBSD-s.patch:-p1 \ ${PATCHDIR}/0028-Fix-rl_completion_func_t.patch:-p1 \ + ${PATCHDIR}/0028-s3-lib-system-add-FreeBSD-proc_fd_pattern.patch:-p1 \ ${PATCHDIR}/0100-Fix-pathref-handling-for-FreeBSD-13plus.patch SAMBA4_BASENAME= samba diff --git a/net/samba419/files/0028-s3-lib-system-add-FreeBSD-proc_fd_pattern.patch b/net/samba419/files/0028-s3-lib-system-add-FreeBSD-proc_fd_pattern.patch new file mode 100644 index 000000000000..be1aedaa4473 --- /dev/null +++ b/net/samba419/files/0028-s3-lib-system-add-FreeBSD-proc_fd_pattern.patch @@ -0,0 +1,149 @@ +From 584c69e77abb537a7345222648a397a9963c01b7 Mon Sep 17 00:00:00 2001 +From: "Timur I. Bakeyev" +Date: Sat, 15 Oct 2022 04:02:43 +0200 +Subject: [PATCH 28/28] s3:lib:system - add FreeBSD proc_fd_pattern + +Add support for FreeBSD equivalent of /proc/self/fd through a special +fdescfs mount with option "nodup". This filesystem should be mounted +either to the private $PIDDIR/fd/ directory or to /dev/fd in order to +provide security and performance characteristics similar to Linux. + +Signed-off-by: Timur I. Bakeyev +--- + source3/lib/system.c | 108 ++++++++++++++++++++++++++++++++++--------- + 1 file changed, 87 insertions(+), 21 deletions(-) + +diff --git a/source3/lib/system.c b/source3/lib/system.c +index 00d31692e00..d22ec08361c 100644 +--- a/source3/lib/system.c ++++ b/source3/lib/system.c +@@ -1094,39 +1094,105 @@ int sys_get_number_of_cores(void) + } + #endif + +-static struct proc_fd_pattern { +- const char *pattern; +- const char *test_path; +-} proc_fd_patterns[] = { +- /* Linux */ +- { "/proc/self/fd/%d", "/proc/self/fd/0" }, +- { NULL, NULL }, ++static bool freebsd_fdesc_check(const char *pattern) ++{ ++ char fdesc_path[PATH_MAX]; ++ int fd, fd2; ++ ++ fd = open(lp_pid_directory(), O_DIRECTORY); ++ if (fd == -1) { ++ DBG_ERR("%s: failed to open pid directory: %s\n", ++ lp_pid_directory(), strerror(errno)); ++ return false; ++ } ++ ++ snprintf(fdesc_path, sizeof(fdesc_path), pattern, fd); ++ ++ fd2 = open(fdesc_path, O_DIRECTORY); ++ if (fd2 == -1) { ++ /* ++ * Setting O_DIRECTORY on open of fdescfs mount ++ * without 'nodup' option will fail with ENOTDIR. ++ */ ++ if (errno == ENOTDIR) { ++ DBG_ERR("%s: fdescfs filesystem is not mounted with " ++ "'nodup' option. This specific mount option is " ++ "required in order to enable race-free handling " ++ "of paths.\n" ++ "See documentation for Samba's New VFS' " ++ "for more details. The 'nodup' mount option was " ++ "introduced in FreeBSD 13.\n", fdesc_path); ++ close(fd); ++ return false; ++ } ++ DBG_ERR("%s: failed to open fdescfs path: %s\n", ++ fdesc_path, strerror(errno)); ++ close(fd); ++ return false; ++ } ++ close(fd); ++ close(fd2); ++ ++ return true; ++} ++ ++static char* linux_pattern(char *buf, size_t bufsize) ++{ ++ char proc_fd_path[PATH_MAX]; ++ const char *pattern = "/proc/self/fd/%lu"; ++ struct stat sb; ++ ++ snprintf(proc_fd_path, sizeof(proc_fd_path), pattern, 0); ++ if(stat(proc_fd_path, &sb) == 0) { ++ snprintf(buf, bufsize, "%s", pattern); ++ return buf; ++ } ++ return NULL; ++} ++ ++static char* freebsd_pattern(char *buf, size_t bufsize) { ++ const char** base; ++ const char* base_dir[] = { ++ lp_pid_directory(), /* This is a preferred location */ ++ "/dev", ++ NULL ++ }; ++ ++ for(base = &base_dir[0]; *base != NULL; base++) { ++ snprintf(buf, bufsize, "%s/fd/%%lu", *base); ++ if(freebsd_fdesc_check(buf)) { ++ return buf; ++ } ++ } ++ return NULL; ++} ++ ++static char* (*proc_fd_patterns[])(char *, size_t) = { ++ linux_pattern, ++ freebsd_pattern, ++ NULL + }; + +-static const char *proc_fd_pattern; ++static char proc_fd_pattern_buf[PATH_MAX]; ++static const char *proc_fd_pattern = NULL; + + bool sys_have_proc_fds(void) + { +- static bool checked; +- static bool have_proc_fds; +- struct proc_fd_pattern *p = NULL; +- struct stat sb; +- int ret; ++ static bool checked = false; ++ static bool have_proc_fds = false; ++ char* (**pattern_func)(char *, size_t) = NULL; + + if (checked) { + return have_proc_fds; + } + +- for (p = &proc_fd_patterns[0]; p->test_path != NULL; p++) { +- ret = stat(p->test_path, &sb); +- if (ret != 0) { +- continue; ++ for (pattern_func = &proc_fd_patterns[0]; *pattern_func != NULL; pattern_func++) { ++ if((*pattern_func)(proc_fd_pattern_buf, sizeof(proc_fd_pattern_buf)) != NULL) { ++ have_proc_fds = true; ++ proc_fd_pattern = proc_fd_pattern_buf; ++ break; + } +- have_proc_fds = true; +- proc_fd_pattern = p->pattern; +- break; + } +- + checked = true; + return have_proc_fds; + } +-- +2.37.1 + diff --git a/net/samba419/files/0100-Fix-pathref-handling-for-FreeBSD-13plus.patch b/net/samba419/files/0100-Fix-pathref-handling-for-FreeBSD-13plus.patch index 3289c0026304..601a1c1c79d8 100644 --- a/net/samba419/files/0100-Fix-pathref-handling-for-FreeBSD-13plus.patch +++ b/net/samba419/files/0100-Fix-pathref-handling-for-FreeBSD-13plus.patch @@ -1,16 +1,5 @@ https://bugzilla.samba.org/show_bug.cgi?id=15376 ---- source3/lib/system.c 2023-01-18 16:32:24.174553200 +0100 -+++ source3/lib/system.c 2023-06-19 23:35:30.132465000 +0200 -@@ -1022,6 +1022,8 @@ - } proc_fd_patterns[] = { - /* Linux */ - { "/proc/self/fd/%d", "/proc/self/fd/0" }, -+ /* FreeBSD */ -+ { "/var/run/samba4/fd/%d", "/var/run/samba4/fd/0" }, - { NULL, NULL }, - }; - --- source3/modules/vfs_zfsacl.c 2023-11-27 13:09:10.612012900 +0100 +++ source3/modules/vfs_zfsacl.c 2025-01-07 18:53:05.292522000 +0100 @@ -169,6 +169,7 @@