Date: Thu, 17 May 2018 03:37:15 +0000 (UTC) From: "Timur I. Bakeyev" <timur@FreeBSD.org> To: ports-committers@freebsd.org, svn-ports-all@freebsd.org, svn-ports-head@freebsd.org Subject: svn commit: r470194 - in head/net: samba46 samba47 samba47/files Message-ID: <201805170337.w4H3bF3r033549@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: timur Date: Thu May 17 03:37:14 2018 New Revision: 470194 URL: https://svnweb.freebsd.org/changeset/ports/470194 Log: Update Samba 4.6 and 4.7 to the most recent versions Sponsored by: iXsystems Inc. Added: head/net/samba47/files/patch-dbwrap (contents, props changed) head/net/samba47/files/patch-source3__modules__wscript_build (contents, props changed) head/net/samba47/files/patch-vfs_freebsd.c (contents, props changed) Modified: head/net/samba46/Makefile head/net/samba46/distinfo head/net/samba47/Makefile head/net/samba47/distinfo head/net/samba47/files/0001-Zfs-provision-1.patch head/net/samba47/files/samba_server.in Modified: head/net/samba46/Makefile ============================================================================== --- head/net/samba46/Makefile Thu May 17 03:34:54 2018 (r470193) +++ head/net/samba46/Makefile Thu May 17 03:37:14 2018 (r470194) @@ -21,7 +21,7 @@ CONFLICTS_INSTALL?= samba4-4.0.* samba4[1-57-9]-4.* p SAMBA4_BASENAME= samba SAMBA4_PORTNAME= ${SAMBA4_BASENAME}4 -SAMBA4_VERSION= 4.6.14 +SAMBA4_VERSION= 4.6.15 SAMBA4_DISTNAME= ${SAMBA4_BASENAME}-${SAMBA4_VERSION:S|.p|pre|:S|.r|rc|:S|.t|tp|:S|.a|alpha|} WRKSRC?= ${WRKDIR}/${DISTNAME} Modified: head/net/samba46/distinfo ============================================================================== --- head/net/samba46/distinfo Thu May 17 03:34:54 2018 (r470193) +++ head/net/samba46/distinfo Thu May 17 03:37:14 2018 (r470194) @@ -1,3 +1,3 @@ -TIMESTAMP = 1520935711 -SHA256 (samba-4.6.14.tar.gz) = 673f459f9e423f3893b017c86343df1e65d57571c949fe030fcffdcc05b8de47 -SIZE (samba-4.6.14.tar.gz) = 21161954 +TIMESTAMP = 1526084366 +SHA256 (samba-4.6.15.tar.gz) = 72f66dbefd08807d2f1bacdbbb1398a03536c3fc640deec6a3b91e7308b30772 +SIZE (samba-4.6.15.tar.gz) = 21175479 Modified: head/net/samba47/Makefile ============================================================================== --- head/net/samba47/Makefile Thu May 17 03:34:54 2018 (r470193) +++ head/net/samba47/Makefile Thu May 17 03:37:14 2018 (r470194) @@ -22,7 +22,7 @@ EXTRA_PATCHES+= ${PATCHDIR}/0001-Freenas-master-mdns SAMBA4_BASENAME= samba SAMBA4_PORTNAME= ${SAMBA4_BASENAME}4 -SAMBA4_VERSION= 4.7.6 +SAMBA4_VERSION= 4.7.7 SAMBA4_DISTNAME= ${SAMBA4_BASENAME}-${SAMBA4_VERSION:S|.p|pre|:S|.r|rc|:S|.t|tp|:S|.a|alpha|} WRKSRC?= ${WRKDIR}/${DISTNAME} @@ -350,7 +350,7 @@ LIB_DEPENDS+= libdbus-1.so:devel/dbus LIB_DEPENDS+= libdbus-glib-1.so:devel/dbus-glib .endif -#SAMBA4_MODULES+= vfs_freebsd +SAMBA4_MODULES+= vfs_freebsd SAMBA4_MODULES+= idmap_nss idmap_autorid idmap_rid idmap_hash idmap_tdb idmap_tdb2 idmap_script nss-info_hash # List of extra modules taken from RHEL build @@ -412,10 +412,10 @@ BUILD_DEPENDS+= ${PYTHON_PKGNAMEPREFIX}iso8601>=0.1. RUN_DEPENDS+= ${PYTHON_PKGNAMEPREFIX}iso8601>=0.1.11:devel/py-iso8601@${PY_FLAVOR} # XXX: This is a gross hack to make port use both Python 2.7+ and 3.3+ # This is not officially supported, use at your own risk -.if defined(WITH_SAMBA4_PYTHON3) && ${WITH_SAMBA4_PYTHON3:Mpython3\.[0-9]} -SAMBA4_PYTHON3= ${WITH_SAMBA4_PYTHON3} -SAMBA4_PYTHON3_VERSION:= ${SAMBA4_PYTHON3:S/^python//} -SAMBA4_PYTHON3_VER:= ${SAMBA4_PYTHON3_VERSION:C/\.//} +.if defined(WITH_SAMBA4_PYTHON3) && ${WITH_SAMBA4_PYTHON3:M3\.[0-9]} +SAMBA4_PYTHON3_VERSION= ${WITH_SAMBA4_PYTHON3} +SAMBA4_PYTHON3= python${SAMBA4_PYTHON3_VERSION} +SAMBA4_PYTHON3_VER= ${SAMBA4_PYTHON3_VERSION:C/\.//} .if !exists(${PORTSDIR}/lang/python${SAMBA4_PYTHON3_VER}) .error unsupported or unknown Python version ${SAMBA4_PYTHON3_VERSION} .endif Modified: head/net/samba47/distinfo ============================================================================== --- head/net/samba47/distinfo Thu May 17 03:34:54 2018 (r470193) +++ head/net/samba47/distinfo Thu May 17 03:37:14 2018 (r470194) @@ -1,3 +1,3 @@ -TIMESTAMP = 1520935629 -SHA256 (samba-4.7.6.tar.gz) = 1eede30fc8ef6504e24602fb72b00baa0a7b73b59f16d25cb0771dc8c7c57d6e -SIZE (samba-4.7.6.tar.gz) = 16864824 +TIMESTAMP = 1525222693 +SHA256 (samba-4.7.7.tar.gz) = 29fad16fa70c1342c300d28d1b474b04c01a2a650149e94cace36fcbace80131 +SIZE (samba-4.7.7.tar.gz) = 16875059 Modified: head/net/samba47/files/0001-Zfs-provision-1.patch ============================================================================== --- head/net/samba47/files/0001-Zfs-provision-1.patch Thu May 17 03:34:54 2018 (r470193) +++ head/net/samba47/files/0001-Zfs-provision-1.patch Thu May 17 03:37:14 2018 (r470194) @@ -26,16 +26,15 @@ diff --git a/python/samba/provision/__init__.py b/pyth index 5de986463a5..cd3b91f41b9 100644 --- a/python/samba/provision/__init__.py +++ b/python/samba/provision/__init__.py -@@ -1556,19 +1556,25 @@ def setsysvolacl(samdb, netlogon, sysvol, uid, gid, domainsid, dnsdomain, +@@ -1556,19 +1556,24 @@ def setsysvolacl(samdb, netlogon, sysvol, uid, gid, domainsid, dnsdomain, s3conf = s3param.get_context() s3conf.load(lp.configfile) - file = tempfile.NamedTemporaryFile(dir=os.path.abspath(sysvol)) + sysvol_dir = os.path.abspath(sysvol) + -+ if smbd.has_posix_acls(sysvol_dir): -+ set_simple_acl = smbd.set_simple_acl -+ elif smbd.has_nfsv4_acls(sysvol_dir): ++ set_simple_acl = smbd.set_simple_acl ++ if smbd.has_nfsv4_acls(sysvol_dir): + set_simple_acl = smbd.set_simple_nfsv4_acl + + file = tempfile.NamedTemporaryFile(dir=sysvol_dir) Added: head/net/samba47/files/patch-dbwrap ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/net/samba47/files/patch-dbwrap Thu May 17 03:37:14 2018 (r470194) @@ -0,0 +1,96 @@ +--- lib/dbwrap/dbwrap.c.orig 2018-01-17 10:08:39 UTC ++++ lib/dbwrap/dbwrap.c +@@ -28,6 +28,9 @@ + #include "lib/util/util_tdb.h" + #include "lib/util/tevent_ntstatus.h" + ++#undef DBGC_CLASS ++#define DBGC_CLASS DBGC_LOCKING ++ + /* + * Fall back using fetch if no genuine exists operation is provided + */ +--- lib/dbwrap/dbwrap_local_open.c.orig 2018-01-14 21:41:58.000000000 +0100 ++++ lib/dbwrap/dbwrap_local_open.c 2018-03-29 23:49:51.888588000 +0200 +@@ -24,6 +24,9 @@ + #include "tdb.h" + #include "lib/param/param.h" + ++#undef DBGC_CLASS ++#define DBGC_CLASS DBGC_LOCKING ++ + struct db_context *dbwrap_local_open(TALLOC_CTX *mem_ctx, + struct loadparm_context *lp_ctx, + const char *name, +--- lib/dbwrap/dbwrap_rbt.c.orig 2018-01-17 09:08:39.000000000 +0100 ++++ lib/dbwrap/dbwrap_rbt.c 2018-03-29 23:50:13.427755000 +0200 +@@ -24,6 +24,9 @@ + #include "../lib/util/rbtree.h" + #include "../lib/util/dlinklist.h" + ++#undef DBGC_CLASS ++#define DBGC_CLASS DBGC_LOCKING ++ + #define DBWRAP_RBT_ALIGN(_size_) (((_size_)+15)&~15) + + struct db_rbt_ctx { +--- lib/dbwrap/dbwrap_tdb.c.orig 2018-01-17 09:08:39.000000000 +0100 ++++ lib/dbwrap/dbwrap_tdb.c 2018-03-29 23:50:40.789642000 +0200 +@@ -27,6 +27,9 @@ + #include "lib/param/param.h" + #include "libcli/util/error.h" + ++#undef DBGC_CLASS ++#define DBGC_CLASS DBGC_LOCKING ++ + struct db_tdb_ctx { + struct tdb_wrap *wtdb; + +--- lib/dbwrap/dbwrap_util.c.orig 2018-01-17 09:08:39.000000000 +0100 ++++ lib/dbwrap/dbwrap_util.c 2018-03-29 23:51:35.907061000 +0200 +@@ -26,6 +26,9 @@ + #include "dbwrap.h" + #include "lib/util/util_tdb.h" + ++#undef DBGC_CLASS ++#define DBGC_CLASS DBGC_LOCKING ++ + struct dbwrap_fetch_int32_state { + NTSTATUS status; + int32_t result; +--- source3/lib/dbwrap/dbwrap_ctdb.c.orig 2018-01-17 09:08:39.000000000 +0100 ++++ source3/lib/dbwrap/dbwrap_ctdb.c 2018-03-29 23:57:41.784931000 +0200 +@@ -38,6 +38,9 @@ + #include "lib/cluster_support.h" + #include "lib/util/tevent_ntstatus.h" + ++#undef DBGC_CLASS ++#define DBGC_CLASS DBGC_LOCKING ++ + struct db_ctdb_transaction_handle { + struct db_ctdb_ctx *ctx; + /* +--- source3/lib/dbwrap/dbwrap_open.c.orig 2018-01-17 09:08:39.000000000 +0100 ++++ source3/lib/dbwrap/dbwrap_open.c 2018-03-29 23:57:54.680614000 +0200 +@@ -31,6 +31,9 @@ + #include "ctdbd_conn.h" + #include "messages.h" + ++#undef DBGC_CLASS ++#define DBGC_CLASS DBGC_LOCKING ++ + bool db_is_local(const char *name) + { + const char *sockname = lp_ctdbd_socket(); +--- source3/lib/dbwrap/dbwrap_watch.c.orig 2018-01-17 09:08:39.000000000 +0100 ++++ source3/lib/dbwrap/dbwrap_watch.c 2018-03-29 23:58:09.746298000 +0200 +@@ -28,6 +28,9 @@ + #include "server_id_watch.h" + #include "lib/dbwrap/dbwrap_private.h" + ++#undef DBGC_CLASS ++#define DBGC_CLASS DBGC_LOCKING ++ + static ssize_t dbwrap_record_watchers_key(struct db_context *db, + struct db_record *rec, + uint8_t *wkey, size_t wkey_len) Added: head/net/samba47/files/patch-source3__modules__wscript_build ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/net/samba47/files/patch-source3__modules__wscript_build Thu May 17 03:37:14 2018 (r470194) @@ -0,0 +1,15 @@ +--- source3/modules/wscript_build.orig 2018-02-08 00:37:51 UTC ++++ source3/modules/wscript_build +@@ -516,3 +516,12 @@ bld.SAMBA3_MODULE('vfs_error_inject', + init_function='', + internal_module=bld.SAMBA3_IS_STATIC_MODULE('vfs_error_inject'), + enabled=bld.SAMBA3_IS_ENABLED_MODULE('vfs_error_inject')) ++ ++bld.SAMBA3_MODULE('vfs_freebsd', ++ subsystem='vfs', ++ source='vfs_freebsd.c', ++ deps='samba-util', ++ init_function='', ++ internal_module=bld.SAMBA3_IS_STATIC_MODULE('vfs_freebsd'), ++ enabled=bld.SAMBA3_IS_ENABLED_MODULE('vfs_freebsd')) ++ Added: head/net/samba47/files/patch-vfs_freebsd.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/net/samba47/files/patch-vfs_freebsd.c Thu May 17 03:37:14 2018 (r470194) @@ -0,0 +1,1785 @@ +--- /dev/null 2018-03-05 02:00:00 UTC ++++ source3/modules/vfs_freebsd.c 2018-03-05 02:04:19.982828000 +0100 +@@ -0,0 +1,1782 @@ ++/* ++ * This module implements VFS calls specific to FreeBSD ++ * ++ * Copyright (C) Timur I. Bakeyev, 2018 ++ * ++ * This program is free software; you can redistribute it and/or modify ++ * it under the terms of the GNU General Public License as published by ++ * the Free Software Foundation; either version 3 of the License, or ++ * (at your option) any later version. ++ * ++ * This program is distributed in the hope that it will be useful, ++ * but WITHOUT ANY WARRANTY; without even the implied warranty of ++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++ * GNU General Public License for more details. ++ * ++ * You should have received a copy of the GNU General Public License ++ * along with this program; if not, see <http://www.gnu.org/licenses/>. ++ */ ++ ++#include "includes.h" ++ ++//#include "../source3/include/includes.h" ++#include "lib/util/tevent_unix.h" ++#include "lib/util/tevent_ntstatus.h" ++#include "system/filesys.h" ++ ++#include <sys/sysctl.h> ++ ++ ++#ifndef EXTATTR_MAXNAMELEN ++#define EXTATTR_MAXNAMELEN UINT8_MAX ++#endif ++ ++#define EXTATTR_NAMESPACE(NS) EXTATTR_NAMESPACE_ ## NS, \ ++ EXTATTR_NAMESPACE_ ## NS ## _STRING ".", \ ++ .data.len = (sizeof(EXTATTR_NAMESPACE_ ## NS ## _STRING ".") - 1) ++ ++#define EXTATTR_EMPTY 0x00 ++#define EXTATTR_USER 0x01 ++#define EXTATTR_SYSTEM 0x02 ++#define EXTATTR_SECURITY 0x03 ++#define EXTATTR_TRUSTED 0x04 ++ ++ ++static bool is_secure = true; ++static bool is_legacy = false; ++ ++typedef struct { ++ int namespace; ++ char name[EXTATTR_MAXNAMELEN+1]; ++ union { ++ uint16_t len; ++ uint16_t flags; ++ } data; ++} extattr_attr; ++ ++ ++/* XXX: This order doesn't match namespace ids order! */ ++static extattr_attr extattr[] = { ++ { EXTATTR_NAMESPACE(EMPTY) }, ++ { EXTATTR_NAMESPACE(SYSTEM) }, ++ { EXTATTR_NAMESPACE(USER) }, ++}; ++ ++typedef struct { ++ enum { ++ FILE, LINK, FDES ++ } method; ++ union { ++ const char *path; ++ int filedes; ++ } param; ++} extattr_arg; ++ ++ ++ ++static bool freebsd_in_jail(void) { ++ int val = 0; ++ size_t val_len = sizeof(val); ++ ++ if((sysctlbyname("security.jail.jailed", &val, &val_len, NULL, 0) != -1) && val == 1) { ++ return true; ++ } ++ return false; ++} ++ ++static uint16_t freebsd_map_attrname(const char *name) ++{ ++ if(name == NULL || name[0] == '\0') { ++ return EXTATTR_EMPTY; ++ } ++ ++ switch(name[0]) { ++ case 'u': ++ if(strncmp(name, "user.", 5) == 0) ++ return EXTATTR_USER; ++ break; ++ case 't': ++ if(strncmp(name, "trusted.", 8) == 0) ++ return EXTATTR_TRUSTED; ++ break; ++ case 's': ++ /* name[1] could be any character, including '\0' */ ++ switch(name[1]) { ++ case 'e': ++ if(strncmp(name, "security.", 9) == 0) ++ return EXTATTR_SECURITY; ++ break; ++ case 'y': ++ if(strncmp(name, "system.", 7) == 0) ++ return EXTATTR_SYSTEM; ++ break; ++ } ++ break; ++ } ++ return EXTATTR_USER; ++} ++ ++/* security, system, trusted or user */ ++static extattr_attr* freebsd_map_xattr(const char *name, extattr_attr *attr) ++{ ++ int attrnamespace = EXTATTR_NAMESPACE_EMPTY; ++ const char *attrname = name; ++ ++ if(name == NULL || name[0] == '\0') { ++ return NULL; ++ } ++ ++ if(attr == NULL) { ++ return NULL; ++ } ++ ++ uint16_t flags = freebsd_map_attrname(name); ++ ++ switch(flags) { ++ case EXTATTR_USER: ++ attrnamespace = EXTATTR_NAMESPACE_USER; ++ if(is_legacy) ++ attrname = name + 5; ++ break; ++ case EXTATTR_SECURITY: ++ case EXTATTR_TRUSTED: ++ attrnamespace = (is_secure) ? ++ EXTATTR_NAMESPACE_SYSTEM : ++ EXTATTR_NAMESPACE_USER; ++ break; ++ case EXTATTR_SYSTEM: ++ attrnamespace = (is_secure) ? ++ EXTATTR_NAMESPACE_SYSTEM : ++ EXTATTR_NAMESPACE_USER; ++ if (is_legacy) ++ attrname = name + 7; ++ break; ++ default: ++ /* Default to "user" namespace if nothing else was specified */ ++ attrnamespace = EXTATTR_NAMESPACE_USER; ++ flags = EXTATTR_USER; ++ } ++ ++ attr->namespace = attrnamespace; ++ attr->data.flags = flags; ++ strlcpy(attr->name, attrname, EXTATTR_MAXNAMELEN+1); ++ ++ return attr; ++} ++ ++static ssize_t extattr_size(extattr_arg arg, extattr_attr *attr) ++{ ++ ssize_t result; ++ ++ switch(arg.method) { ++#if defined(HAVE_EXTATTR_GET_FILE) ++ case FILE: ++ result = extattr_get_file(arg.param.path, attr->namespace, attr->name, NULL, 0); ++ break; ++#endif ++#if defined(HAVE_EXTATTR_GET_LINK) ++ case LINK: ++ result = extattr_get_link(arg.param.path, attr->namespace, attr->name, NULL, 0); ++ break; ++#endif ++#if defined(HAVE_EXTATTR_GET_FD) ++ case FDES: ++ result = extattr_get_fd(arg.param.filedes, attr->namespace, attr->name, NULL, 0); ++ break; ++#endif ++ default: ++ errno = ENOSYS; ++ return -1; ++ } ++ ++ if(result < 0) { ++ errno = EINVAL; ++ return -1; ++ } ++ ++ return result; ++} ++ ++ ++/* ++ * The list of names is returned as an unordered array of NULL-terminated ++ * character strings (attribute names are separated by NULL characters), ++ * like this: ++ * user.name1\0system.name1\0user.name2\0 ++ * ++ * Filesystems like ext2, ext3 and XFS which implement POSIX ACLs using ++ * extended attributes, might return a list like this: ++ * system.posix_acl_access\0system.posix_acl_default\0 ++ */ ++/* ++ * The extattr_list_file() returns a list of attributes present in the ++ * requested namespace. Each list entry consists of a single byte containing ++ * the length of the attribute name, followed by the attribute name. The ++ * attribute name is not terminated by ASCII 0 (nul). ++*/ ++ ++static ssize_t freebsd_extattr_list(extattr_arg arg, char *list, size_t size) ++{ ++ ssize_t list_size, total_size = 0; ++ char *p, *q, *list_end; ++ int len; ++ /* ++ Ignore all but user namespace when we are not root or in jail ++ See: https://bugzilla.samba.org/show_bug.cgi?id=10247 ++ */ ++ bool as_root = (geteuid() == 0); ++ ++ int ns = (is_secure && as_root) ? 1 : 2; ++ ++ /* Iterate through extattr(2) namespaces */ ++ for(; ns < ARRAY_SIZE(extattr); ns++) { ++ switch(arg.method) { ++#if defined(HAVE_EXTATTR_LIST_FILE) ++ case FILE: ++ list_size = extattr_list_file(arg.param.path, extattr[ns].namespace, list, size); ++ break; ++#endif ++#if defined(HAVE_EXTATTR_LIST_LINK) ++ case LINK: ++ list_size = extattr_list_link(arg.param.path, extattr[ns].namespace, list, size); ++ break; ++#endif ++#if defined(HAVE_EXTATTR_LIST_FD) ++ case FDES: ++ list_size = extattr_list_fd(arg.param.filedes, extattr[ns].namespace, list, size); ++ break; ++#endif ++ default: ++ errno = ENOSYS; ++ return -1; ++ } ++ /* Some error happend. Errno should be set by the previous call */ ++ if(list_size < 0) ++ return -1; ++ /* No attributes in this namespace */ ++ if(list_size == 0) ++ continue; ++ /* ++ Call with an empty buffer may be used to calculate ++ necessary buffer size. ++ */ ++ if(list == NULL) { ++ /* ++ XXX: Unfortunately, we can't say, how many attributes were ++ returned, so here is the potential problem with the emulation. ++ */ ++ if(is_legacy) { ++ /* ++ Take the worse case of one char attribute names - ++ two bytes per name plus one more for sanity. ++ */ ++ total_size += list_size + (list_size/2 + 1)*extattr[ns].data.len; ++ } ++ else { ++ total_size += list_size; ++ } ++ continue; ++ } ++ ++ if(is_legacy) { ++ /* Count necessary offset to fit namespace prefixes */ ++ int extra_len = 0; ++ uint16_t flags; ++ list_end = list + list_size; ++ for(list_size = 0, p = q = list; p < list_end; p += len) { ++ len = p[0] + 1; ++ (void)strlcpy(q, p + 1, len); ++ flags = freebsd_map_attrname(q); ++ /* Skip secure attributes for non-root user */ ++ if(!is_secure && !as_root && flags > EXTATTR_USER) { ++ continue; ++ } ++ if(flags <= EXTATTR_USER) { ++ /* Don't count trailing '\0' */ ++ extra_len += extattr[ns].data.len; ++ } ++ list_size += len; ++ q += len; ++ } ++ total_size += list_size + extra_len; ++ /* Buffer is too small to fit the results */ ++ if(total_size > size) { ++ errno = ERANGE; ++ return -1; ++ } ++ /* Shift results backwards, so we can prepend prefixes */ ++ list_end = list + extra_len; ++ p = (char*)memmove(list_end, list, list_size); ++ /* ++ We enter the loop with `p` pointing to the shifted list and ++ `extra_len` having the total margin between `list` and `p` ++ */ ++ for(list_end += list_size; p < list_end; p += len) { ++ len = strlen(p) + 1; ++ flags = freebsd_map_attrname(p); ++ if(flags <= EXTATTR_USER) { ++ /* Add namespace prefix */ ++ (void)strncpy(list, extattr[ns].name, extattr[ns].data.len); ++ list += extattr[ns].data.len; ++ } ++ /* Append attribute name */ ++ (void)strlcpy(list, p, len); ++ list += len; ++ } ++ } ++ else { ++ /* Convert UCSD strings into nul-terminated strings */ ++ for(list_end = list + list_size; list < list_end; list += len) { ++ len = list[0] + 1; ++ (void)strlcpy(list, list + 1, len); ++ } ++ total_size += list_size; ++ } ++ } ++ return total_size; ++} ++ ++/* ++static ssize_t freebsd_getxattr_size(vfs_handle_struct *handle, ++ const struct smb_filename *smb_fname, ++ const char *name) ++{ ++ extattr_arg arg = { FILE, smb_fname->base_name }; ++ extattr_attr attr; ++ ++ if(!freebsd_map_xattr(name, &attr)) { ++ errno = EINVAL; ++ return -1; ++ } ++ ++ if(!is_secure && geteuid() != 0 && attr.data.flags > EXTATTR_USER) { ++ errno = ENOATTR; ++ return -1; ++ } ++ ++ return extattr_size(arg, &attr); ++} ++*/ ++ ++/* VFS entries */ ++static ssize_t freebsd_getxattr(vfs_handle_struct *handle, ++ const struct smb_filename *smb_fname, ++ const char *name, ++ void *value, ++ size_t size) ++{ ++#if defined(HAVE_EXTATTR_GET_FILE) ++ extattr_arg arg = { FILE, .param.path = smb_fname->base_name }; ++ extattr_attr attr; ++ ssize_t res; ++ ++ if(!freebsd_map_xattr(name, &attr)) { ++ errno = EINVAL; ++ return -1; ++ } ++ ++ /* Filter out 'secure' entries */ ++ if(!is_secure && geteuid() != 0 && attr.data.flags > EXTATTR_USER) { ++ errno = ENOATTR; ++ return -1; ++ } ++ ++ /* ++ * The BSD implementation has a nasty habit of silently truncating ++ * the returned value to the size of the buffer, so we have to check ++ * that the buffer is large enough to fit the returned value. ++ */ ++ if((res=extattr_size(arg, &attr)) < 0) { ++ return -1; ++ } ++ ++ if (size == 0) { ++ return res; ++ } ++ else if (res > size) { ++ errno = ERANGE; ++ return -1; ++ } ++ ++ if((res=extattr_get_file(smb_fname->base_name, attr.namespace, attr.name, value, size)) >= 0) { ++ return res; ++ } ++ return -1; ++#else ++ errno = ENOSYS; ++ return -1; ++#endif ++} ++ ++ ++static ssize_t freebsd_fgetxattr(vfs_handle_struct *handle, ++ struct files_struct *fsp, const char *name, ++ void *value, size_t size) ++{ ++#if defined(HAVE_EXTATTR_GET_FD) ++ extattr_arg arg = { FDES, .param.filedes = fsp->fh->fd }; ++ extattr_attr attr; ++ ssize_t res; ++ ++ if(!freebsd_map_xattr(name, &attr)) { ++ errno = EINVAL; ++ return -1; ++ } ++ ++ /* Filter out 'secure' entries */ ++ if(!is_secure && geteuid() != 0 && attr.data.flags > EXTATTR_USER) { ++ errno = ENOATTR; ++ return -1; ++ } ++ ++ /* ++ * The BSD implementation has a nasty habit of silently truncating ++ * the returned value to the size of the buffer, so we have to check ++ * that the buffer is large enough to fit the returned value. ++ */ ++ if((res=extattr_size(arg, &attr)) < 0) { ++ return -1; ++ } ++ ++ if (size == 0) { ++ return res; ++ } ++ else if (res > size) { ++ errno = ERANGE; ++ return -1; ++ } ++ ++ if((res=extattr_get_fd(fsp->fh->fd, attr.namespace, attr.name, value, size)) >= 0) { ++ return res; ++ } ++ return -1; ++#else ++ errno = ENOSYS; ++ return -1; ++#endif ++} ++ ++ ++static ssize_t freebsd_listxattr(vfs_handle_struct *handle, ++ const struct smb_filename *smb_fname, ++ char *list, ++ size_t size) ++{ ++#if defined(HAVE_EXTATTR_LIST_FILE) ++ extattr_arg arg = { FILE, .param.path = smb_fname->base_name }; ++ ++ return freebsd_extattr_list(arg, list, size); ++#else ++ errno = ENOSYS; ++ return -1; ++#endif ++} ++ ++ ++static ssize_t freebsd_flistxattr(vfs_handle_struct *handle, ++ struct files_struct *fsp, char *list, ++ size_t size) ++{ ++#if defined(HAVE_EXTATTR_LIST_FD) ++ extattr_arg arg = { FDES, .param.filedes = fsp->fh->fd }; ++ ++ return freebsd_extattr_list(arg, list, size); ++#else ++ errno = ENOSYS; ++ return -1; ++#endif ++} ++ ++static int freebsd_removexattr(vfs_handle_struct *handle, ++ const struct smb_filename *smb_fname, ++ const char *name) ++{ ++#if defined(HAVE_EXTATTR_DELETE_FILE) ++ extattr_attr attr; ++ ++ if(!freebsd_map_xattr(name, &attr)) { ++ errno = EINVAL; ++ return -1; ++ } ++ ++ /* Filter out 'secure' entries */ ++ if(!is_secure && geteuid() != 0 && attr.data.flags > EXTATTR_USER) { ++ errno = ENOATTR; ++ return -1; ++ } ++ ++ return extattr_delete_file(smb_fname->base_name, attr.namespace, attr.name); ++#else ++ errno = ENOSYS; ++ return -1; ++#endif ++} ++ ++ ++static int freebsd_fremovexattr(vfs_handle_struct *handle, ++ struct files_struct *fsp, const char *name) ++{ ++#if defined(HAVE_EXTATTR_DELETE_FD) ++ extattr_attr attr; ++ ++ if(!freebsd_map_xattr(name, &attr)) { ++ errno = EINVAL; ++ return -1; ++ } ++ ++ /* Filter out 'secure' entries */ ++ if(!is_secure && geteuid() != 0 && attr.data.flags > EXTATTR_USER) { ++ errno = ENOATTR; ++ return -1; ++ } ++ ++ return extattr_delete_fd(fsp->fh->fd, attr.namespace, attr.name); ++#else ++ errno = ENOSYS; ++ return -1; ++#endif ++} ++ ++ ++static int freebsd_setxattr(vfs_handle_struct *handle, ++ const struct smb_filename *smb_fname, ++ const char *name, ++ const void *value, ++ size_t size, ++ int flags) ++{ ++#if defined(HAVE_EXTATTR_SET_FILE) ++ extattr_attr attr; ++ ssize_t res; ++ ++ if(!freebsd_map_xattr(name, &attr)) { ++ errno = EINVAL; ++ return -1; ++ } ++ ++ /* Filter out 'secure' entries */ ++ if(!is_secure && geteuid() != 0 && attr.data.flags > EXTATTR_USER) { ++ errno = ENOATTR; ++ return -1; ++ } ++ ++ if (flags) { ++ extattr_arg arg = { FILE, .param.path = smb_fname->base_name }; ++ /* Check attribute existence */ ++ res = extattr_size(arg, &attr); ++ if (res < 0) { ++ /* REPLACE attribute, that doesn't exist */ ++ if ((flags & XATTR_REPLACE) && errno == ENOATTR) { ++ errno = ENOATTR; ++ return -1; ++ } ++ /* Ignore other errors */ ++ } ++ else { ++ /* CREATE attribute, that already exists */ ++ if (flags & XATTR_CREATE) { ++ errno = EEXIST; ++ return -1; ++ } ++ } ++ } ++ res = extattr_set_file(smb_fname->base_name, attr.namespace, attr.name, value, size); ++ ++ return (res >= 0) ? 0 : -1; ++#else ++ errno = ENOSYS; ++ return -1; ++#endif ++} ++ ++ ++static int freebsd_fsetxattr(vfs_handle_struct *handle, struct files_struct *fsp, ++ const char *name, const void *value, size_t size, ++ int flags) ++{ ++#if defined(HAVE_EXTATTR_SET_FD) ++ extattr_attr attr; ++ ssize_t res; ++ ++ if(!freebsd_map_xattr(name, &attr)) { ++ errno = EINVAL; ++ return -1; ++ } ++ ++ /* Filter out 'secure' entries */ ++ if(!is_secure && geteuid() != 0 && attr.data.flags > EXTATTR_USER) { ++ errno = ENOATTR; ++ return -1; ++ } ++ ++ if (flags) { ++ extattr_arg arg = { FDES, .param.filedes = fsp->fh->fd }; ++ /* Check attribute existence */ ++ res = extattr_size(arg, &attr); ++ if (res < 0) { ++ /* REPLACE attribute, that doesn't exist */ ++ if ((flags & XATTR_REPLACE) && errno == ENOATTR) { ++ errno = ENOATTR; ++ return -1; ++ } ++ /* Ignore other errors */ ++ } ++ else { ++ /* CREATE attribute, that already exists */ ++ if (flags & XATTR_CREATE) { ++ errno = EEXIST; ++ return -1; ++ } ++ } ++ } ++ ++ res = extattr_set_fd(fsp->fh->fd, attr.namespace, attr.name, value, size); ++ ++ return (res >= 0) ? 0 : -1; ++#else ++ errno = ENOSYS; ++ return -1; ++#endif ++} ++ ++ ++ ++ ++static int freebsd_connect(vfs_handle_struct *handle, const char *service, ++ const char *user) ++{ ++ return SMB_VFS_NEXT_CONNECT(handle, service, user); ++} ++ ++static void freebsd_disconnect(vfs_handle_struct *handle) ++{ ++ SMB_VFS_NEXT_DISCONNECT(handle); ++} ++ ++static uint64_t freebsd_disk_free(vfs_handle_struct *handle, ++ const struct smb_filename *smb_fname, ++ uint64_t *bsize, ++ uint64_t *dfree, ++ uint64_t *dsize) ++{ ++ return SMB_VFS_NEXT_DISK_FREE(handle, smb_fname, bsize, dfree, dsize); ++} ++ ++static int freebsd_get_quota(vfs_handle_struct *handle, ++ const struct smb_filename *smb_fname, ++ enum SMB_QUOTA_TYPE qtype, ++ unid_t id, ++ SMB_DISK_QUOTA *dq) ++{ ++ return SMB_VFS_NEXT_GET_QUOTA(handle, smb_fname, qtype, id, dq); ++} ++ ++static int freebsd_set_quota(vfs_handle_struct *handle, enum SMB_QUOTA_TYPE qtype, ++ unid_t id, SMB_DISK_QUOTA *dq) ++{ ++ return SMB_VFS_NEXT_SET_QUOTA(handle, qtype, id, dq); ++} ++ ++static int freebsd_get_shadow_copy_data(vfs_handle_struct *handle, ++ files_struct *fsp, ++ struct shadow_copy_data *shadow_copy_data, ++ bool labels) ++{ ++ return SMB_VFS_NEXT_GET_SHADOW_COPY_DATA(handle, fsp, shadow_copy_data, ++ labels); ++} ++ ++static int freebsd_statvfs(struct vfs_handle_struct *handle, ++ const struct smb_filename *smb_fname, ++ struct vfs_statvfs_struct *statbuf) ++{ ++ return SMB_VFS_NEXT_STATVFS(handle, smb_fname, statbuf); ++} ++ ++static uint32_t freebsd_fs_capabilities(struct vfs_handle_struct *handle, ++ enum timestamp_set_resolution *p_ts_res) ++{ ++ return SMB_VFS_NEXT_FS_CAPABILITIES(handle, p_ts_res); ++} ++ ++static NTSTATUS freebsd_get_dfs_referrals(struct vfs_handle_struct *handle, ++ struct dfs_GetDFSReferral *r) ++{ ++ return SMB_VFS_NEXT_GET_DFS_REFERRALS(handle, r); ++} ++ ++static DIR *freebsd_opendir(vfs_handle_struct *handle, ++ const struct smb_filename *smb_fname, ++ const char *mask, ++ uint32_t attr) ++{ ++ return SMB_VFS_NEXT_OPENDIR(handle, smb_fname, mask, attr); ++} ++ ++static NTSTATUS freebsd_snap_check_path(struct vfs_handle_struct *handle, ++ TALLOC_CTX *mem_ctx, ++ const char *service_path, ++ char **base_volume) ++{ ++ return SMB_VFS_NEXT_SNAP_CHECK_PATH(handle, mem_ctx, service_path, ++ base_volume); ++} ++ ++static NTSTATUS freebsd_snap_create(struct vfs_handle_struct *handle, ++ TALLOC_CTX *mem_ctx, ++ const char *base_volume, ++ time_t *tstamp, ++ bool rw, ++ char **base_path, ++ char **snap_path) ++{ ++ return SMB_VFS_NEXT_SNAP_CREATE(handle, mem_ctx, base_volume, tstamp, ++ rw, base_path, snap_path); ++} ++ ++static NTSTATUS freebsd_snap_delete(struct vfs_handle_struct *handle, ++ TALLOC_CTX *mem_ctx, ++ char *base_path, ++ char *snap_path) ++{ ++ return SMB_VFS_NEXT_SNAP_DELETE(handle, mem_ctx, base_path, snap_path); ++} ++ ++static DIR *freebsd_fdopendir(vfs_handle_struct *handle, files_struct *fsp, ++ const char *mask, uint32_t attr) ++{ ++ return SMB_VFS_NEXT_FDOPENDIR(handle, fsp, mask, attr); ++} ++ ++static struct dirent *freebsd_readdir(vfs_handle_struct *handle, ++ DIR *dirp, SMB_STRUCT_STAT *sbuf) ++{ ++ return SMB_VFS_NEXT_READDIR(handle, dirp, sbuf); ++} ++ ++static void freebsd_seekdir(vfs_handle_struct *handle, DIR *dirp, long offset) ++{ ++ SMB_VFS_NEXT_SEEKDIR(handle, dirp, offset); ++} ++ ++static long freebsd_telldir(vfs_handle_struct *handle, DIR *dirp) ++{ ++ return SMB_VFS_NEXT_TELLDIR(handle, dirp); ++} ++ ++static void freebsd_rewind_dir(vfs_handle_struct *handle, DIR *dirp) ++{ ++ SMB_VFS_NEXT_REWINDDIR(handle, dirp); ++} ++ ++static int freebsd_mkdir(vfs_handle_struct *handle, ++ const struct smb_filename *smb_fname, ++ mode_t mode) ++{ ++ return SMB_VFS_NEXT_MKDIR(handle, smb_fname, mode); ++} ++ ++static int freebsd_rmdir(vfs_handle_struct *handle, ++ const struct smb_filename *smb_fname) ++{ ++ return SMB_VFS_NEXT_RMDIR(handle, smb_fname); ++} ++ ++static int freebsd_closedir(vfs_handle_struct *handle, DIR *dir) ++{ ++ return SMB_VFS_NEXT_CLOSEDIR(handle, dir); ++} ++ ++static int freebsd_open(vfs_handle_struct *handle, struct smb_filename *smb_fname, ++ files_struct *fsp, int flags, mode_t mode) *** DIFF OUTPUT TRUNCATED AT 1000 LINES ***
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201805170337.w4H3bF3r033549>