Fix port
This commit is contained in:
@ -1,6 +1,6 @@
|
||||
PORTNAME= ${SAMBA4_BASENAME}420
|
||||
PORTVERSION= ${SAMBA4_VERSION}
|
||||
PORTREVISION= 5
|
||||
#PORTREVISION= 5
|
||||
CATEGORIES?= net
|
||||
MASTER_SITES= SAMBA/samba/stable SAMBA/samba/rc
|
||||
DISTNAME= ${SAMBA4_DISTNAME}
|
||||
@ -45,8 +45,8 @@ 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_samba42x.patch:p1 \
|
||||
${PATCHDIR}/0028-s3-lib-system-add-FreeBSD-proc_fd_pattern.patch \
|
||||
${PATCHDIR}/0100-Fix-pathref-handling-for-FreeBSD-13plus_samba42x.patch:-p1 \
|
||||
${PATCHDIR}/0101-FreeBSD-add-fdescfs-paths-workaround.patch:-p1 \
|
||||
${PATCHDIR}/0102-FreeBSD-vfs_freebsd-fix-sys_proc_fd_path-args.patch:-p1
|
||||
|
||||
|
||||
@ -1,35 +1,14 @@
|
||||
From 584c69e77abb537a7345222648a397a9963c01b7 Mon Sep 17 00:00:00 2001
|
||||
From: "Timur I. Bakeyev" <timur@FreeBSD.org>
|
||||
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 <timur@FreeBSD.org>
|
||||
---
|
||||
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)
|
||||
--- source3/lib/system.c.orig 2024-02-02 10:33:51.188489400 +0100
|
||||
+++ source3/lib/system.c 2025-01-22 17:39:58.625028000 +0100
|
||||
@@ -1047,22 +1047,108 @@
|
||||
}
|
||||
#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 },
|
||||
-bool sys_have_proc_fds(void)
|
||||
+static bool freebsd_fdesc_check(const char *pattern)
|
||||
+{
|
||||
{
|
||||
- static bool checked = false;
|
||||
- static bool have_proc_fds = false;
|
||||
+ char fdesc_path[PATH_MAX];
|
||||
+ int fd, fd2;
|
||||
+
|
||||
@ -74,16 +53,22 @@ index 00d31692e00..d22ec08361c 100644
|
||||
+{
|
||||
+ char proc_fd_path[PATH_MAX];
|
||||
+ const char *pattern = "/proc/self/fd/%lu";
|
||||
+ struct stat sb;
|
||||
+
|
||||
struct stat sb;
|
||||
- int ret;
|
||||
|
||||
- if (checked) {
|
||||
- return have_proc_fds;
|
||||
+ 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;
|
||||
+}
|
||||
+
|
||||
|
||||
- ret = stat("/proc/self/fd/0", &sb);
|
||||
- have_proc_fds = (ret == 0);
|
||||
- checked = true;
|
||||
+static char* freebsd_pattern(char *buf, size_t bufsize) {
|
||||
+ const char** base;
|
||||
+ const char* base_dir[] = {
|
||||
@ -91,7 +76,8 @@ index 00d31692e00..d22ec08361c 100644
|
||||
+ "/dev",
|
||||
+ NULL
|
||||
+ };
|
||||
+
|
||||
|
||||
- return have_proc_fds;
|
||||
+ for(base = &base_dir[0]; *base != NULL; base++) {
|
||||
+ snprintf(buf, bufsize, "%s/fd/%%lu", *base);
|
||||
+ if(freebsd_fdesc_check(buf)) {
|
||||
@ -105,45 +91,31 @@ index 00d31692e00..d22ec08361c 100644
|
||||
+ 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;
|
||||
+
|
||||
+bool sys_have_proc_fds(void)
|
||||
+{
|
||||
+ 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;
|
||||
+
|
||||
+ if (checked) {
|
||||
+ return have_proc_fds;
|
||||
+ }
|
||||
+
|
||||
+ 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;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ checked = true;
|
||||
+ return have_proc_fds;
|
||||
}
|
||||
--
|
||||
2.37.1
|
||||
|
||||
char *sys_proc_fd_path(int fd, struct sys_proc_fd_path_buf *buf)
|
||||
|
||||
@ -60,15 +60,6 @@ diff -Naurp a/source3/include/proto.h b/source3/include/proto.h
|
||||
diff -Naurp a/source3/lib/system.c b/source3/lib/system.c
|
||||
--- a/source3/lib/system.c 2024-08-05 20:40:38.434801000 -0400
|
||||
+++ b/source3/lib/system.c 2024-08-05 20:41:16.625938000 -0400
|
||||
@@ -1058,7 +1058,7 @@ bool sys_have_proc_fds(void)
|
||||
return have_proc_fds;
|
||||
}
|
||||
|
||||
- ret = stat("/proc/self/fd/0", &sb);
|
||||
+ ret = stat(PROC_FD_PATH_MKSTR(0), &sb);
|
||||
have_proc_fds = (ret == 0);
|
||||
checked = true;
|
||||
|
||||
@@ -1068,7 +1068,7 @@ char *sys_proc_fd_path(int fd, struct sys_proc_fd_path
|
||||
char *sys_proc_fd_path(int fd, struct sys_proc_fd_path_buf *buf)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user