From 833e4f6b0b1fa5e4b78ea7ede1545691a843161c Mon Sep 17 00:00:00 2001 From: coolsnowwolf Date: Mon, 29 Jan 2018 16:05:37 +0800 Subject: [PATCH] add samba 4.x package --- package/lean/heimdal/Makefile | 157 ++++++++ package/lean/heimdal/files/roken-h-process.pl | 184 +++++++++ .../heimdal/patches/001-snprintf-len.patch | 16 + .../patches/002-remove-unused-version.patch | 10 + .../010-configure-fix-cross-compiling.patch | 26 ++ .../heimdal/patches/100-build-fixes.patch | 42 +++ package/lean/samba4x/Makefile | 283 ++++++++++++++ package/lean/samba4x/files/python2-config | 26 ++ package/lean/samba4x/files/samba4x.config | 7 + package/lean/samba4x/files/samba4x.init | 162 ++++++++ package/lean/samba4x/files/smb.conf.template | 42 +++ .../samba4x/patches/000-disable-libbsd.patch | 25 ++ .../004-pythogn-DEBUGLEVEL-undefined.patch | 11 + ...8-avoid-get-config-by-native-ncurses.patch | 22 ++ .../samba4x/patches/020-splice-support.patch | 91 +++++ .../lean/samba4x/patches/022-wscript.patch | 15 + .../patches/023-wscript_perl_fixup.patch | 26 ++ .../lean/samba4x/patches/110-multicall.patch | 77 ++++ .../patches/111-multicall-wscript-build.patch | 84 +++++ .../patches/120-add_missing_ifdef.patch | 26 ++ .../patches/200-remove_printer_support.patch | 355 ++++++++++++++++++ .../samba4x/patches/220-remove_services.patch | 46 +++ .../patches/230-remove_winreg_support.patch | 101 +++++ .../patches/270-remove_registry_backend.patch | 43 +++ .../samba4x/patches/280-strip_srvsvc.patch | 146 +++++++ .../patches/300-assert_debug_level.patch | 11 + .../patches/320-debug_level_checks.patch | 22 ++ .../patches/390-remove-auth-winbind.patch | 20 + .../lean/samba4x/patches/800-ldap-sasl.patch | 76 ++++ ...-ldap-determine-suffix-automatically.patch | 77 ++++ ...00-musl-remove-getgrent_r-getpwent_r.patch | 60 +++ .../samba4x/patches/911-musl-NETDB-fix.patch | 15 + .../patches/912-msgsock-nvram-fix.patch | 46 +++ 33 files changed, 2350 insertions(+) create mode 100644 package/lean/heimdal/Makefile create mode 100644 package/lean/heimdal/files/roken-h-process.pl create mode 100644 package/lean/heimdal/patches/001-snprintf-len.patch create mode 100644 package/lean/heimdal/patches/002-remove-unused-version.patch create mode 100644 package/lean/heimdal/patches/010-configure-fix-cross-compiling.patch create mode 100644 package/lean/heimdal/patches/100-build-fixes.patch create mode 100644 package/lean/samba4x/Makefile create mode 100755 package/lean/samba4x/files/python2-config create mode 100644 package/lean/samba4x/files/samba4x.config create mode 100755 package/lean/samba4x/files/samba4x.init create mode 100644 package/lean/samba4x/files/smb.conf.template create mode 100644 package/lean/samba4x/patches/000-disable-libbsd.patch create mode 100644 package/lean/samba4x/patches/004-pythogn-DEBUGLEVEL-undefined.patch create mode 100644 package/lean/samba4x/patches/018-avoid-get-config-by-native-ncurses.patch create mode 100644 package/lean/samba4x/patches/020-splice-support.patch create mode 100644 package/lean/samba4x/patches/022-wscript.patch create mode 100644 package/lean/samba4x/patches/023-wscript_perl_fixup.patch create mode 100644 package/lean/samba4x/patches/110-multicall.patch create mode 100644 package/lean/samba4x/patches/111-multicall-wscript-build.patch create mode 100644 package/lean/samba4x/patches/120-add_missing_ifdef.patch create mode 100644 package/lean/samba4x/patches/200-remove_printer_support.patch create mode 100644 package/lean/samba4x/patches/220-remove_services.patch create mode 100644 package/lean/samba4x/patches/230-remove_winreg_support.patch create mode 100644 package/lean/samba4x/patches/270-remove_registry_backend.patch create mode 100644 package/lean/samba4x/patches/280-strip_srvsvc.patch create mode 100644 package/lean/samba4x/patches/300-assert_debug_level.patch create mode 100644 package/lean/samba4x/patches/320-debug_level_checks.patch create mode 100644 package/lean/samba4x/patches/390-remove-auth-winbind.patch create mode 100644 package/lean/samba4x/patches/800-ldap-sasl.patch create mode 100644 package/lean/samba4x/patches/810-ldap-determine-suffix-automatically.patch create mode 100644 package/lean/samba4x/patches/900-musl-remove-getgrent_r-getpwent_r.patch create mode 100644 package/lean/samba4x/patches/911-musl-NETDB-fix.patch create mode 100644 package/lean/samba4x/patches/912-msgsock-nvram-fix.patch diff --git a/package/lean/heimdal/Makefile b/package/lean/heimdal/Makefile new file mode 100644 index 000000000..471e189c2 --- /dev/null +++ b/package/lean/heimdal/Makefile @@ -0,0 +1,157 @@ +# +# Copyright (C) 2009-2011 OpenWrt.org +# +# This is free software, licensed under the GNU General Public License v2. +# See /LICENSE for more information. +# + +include $(TOPDIR)/rules.mk + +PKG_NAME:=heimdal +PKG_VERSION:=1.5.3 +PKG_RELEASE:=1 +PKG_INSTALL:=1 + +PKG_BUILD_DEPENDS:=heimdal/host + +PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz +PKG_SOURCE_URL:=http://www.h5l.org/dist/src/ +PKG_MD5SUM:=30b379e3de12f332fbd201131f02ffca +#PKG_FIXUP:=autoreconf + +include $(INCLUDE_DIR)/package.mk +include $(INCLUDE_DIR)/host-build.mk + +HOST_CONFIGURE_ARGS += \ + --disable-shared \ + --enable-static \ + --without-openldap \ + --without-capng \ + --without-sqlite3 \ + --without-libintl \ + --without-openssl \ + --without-berkeley-db \ + --without-readline \ + --without-libedit \ + --without-hesiod \ + --without-x \ + --disable-heimdal-documentation + +define Host/Compile + $(MAKE) -C $(HOST_BUILD_DIR)/include $(HOST_MAKE_FLAGS) + $(MAKE) -C $(HOST_BUILD_DIR)/lib/roken $(HOST_MAKE_FLAGS) + $(MAKE) -C $(HOST_BUILD_DIR)/lib/vers $(HOST_MAKE_FLAGS) + $(MAKE) -C $(HOST_BUILD_DIR)/lib/com_err $(HOST_MAKE_FLAGS) + $(MAKE) -C $(HOST_BUILD_DIR)/lib/asn1 $(HOST_MAKE_FLAGS) + $(MAKE) -C $(HOST_BUILD_DIR)/lib/libedit $(HOST_MAKE_FLAGS) + $(MAKE) -C $(HOST_BUILD_DIR)/lib/sl $(HOST_MAKE_FLAGS) +endef + +define Host/Install + $(INSTALL_DIR) $(STAGING_DIR)/host/bin + $(CP) $(HOST_BUILD_DIR)/lib/com_err/compile_et $(STAGING_DIR)/host/bin + $(CP) $(HOST_BUILD_DIR)/lib/asn1/asn1_compile $(STAGING_DIR)/host/bin + $(CP) $(HOST_BUILD_DIR)/lib/sl/slc $(STAGING_DIR)/host/bin +endef + +CONFIGURE_ARGS += \ + --disable-pk-init \ + --disable-kx509 \ + --disable-sqlite-cache \ + --enable-pthread-support \ + --disable-afs-support \ + --disable-ndbm-db \ + --with-cross-tools=$(STAGING_DIR_HOST)/bin \ + --disable-heimdal-documentation \ + --enable-developer \ + --with-sqlite3=yes \ + --with-sqlite3-include=$(STAGING_DIR)/usr/include \ + --with-sqlite3-lib=$(STAGING_DIR)/usr/lib \ + --with-openssl=yes \ + --with-openssl-include=$(STAGING_DIR)/usr/include \ + --with-openssl-lib=$(STAGING_DIR)/usr/lib \ + --without-x \ + --disable-afs-support \ + --disable-ndbm-db \ + --disable-mmap + +EXTRA_CFLAGS += \ + -Wno-deprecated-declarations \ + -Wno-unused-variable \ + -Wno-unused-function \ + -Wno-maybe-uninitialized \ + -Wno-return-type \ + -Wno-enum-compare + +define Build/Prepare + $(call Build/Prepare/Default) + $(CP) files/roken-h-process.pl $(PKG_BUILD_DIR)/cf +endef + +define Build/Compile +endef + + +define Package/heimdal/Default + SECTION:=network + CATEGORY:=Network + SUBMENU:=Kerberos + TITLE:=Heimdal Kerberos 5 + URL:=http://www.h5l.org +endef + +define Package/heimdal-libs + $(call Package/heimdal/Default) + TITLE+= (Libraries) + DEPENDS:=+libsqlite3 +libreadline +libncurses +libopenssl +endef + +define Package/heimdal-server + $(call Package/heimdal/Default) + TITLE+= (Server) + DEPENDS:=+heimdal-libs +endef + +define Package/heimdal-client + $(call Package/heimdal/Default) + TITLE+= (Client) + DEPENDS:=+heimdal-libs +endef + +define Package/heimdal-libs/install + $(INSTALL_DIR) $(1)/usr/lib + $(CP) $(PKG_INSTALL_DIR)/usr/lib/*.so* $(1)/usr/lib +endef + +define Package/heimdal-client/install + $(INSTALL_DIR) $(1)/usr/bin + $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/kdestroy $(1)/usr/bin + $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/kinit $(1)/usr/bin + $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/kcc $(1)/usr/bin + $(CP) $(PKG_INSTALL_DIR)/usr/bin/klist $(1)/usr/bin + $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/kpasswd $(1)/usr/bin + $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/su $(1)/usr/bin/ksu +endef + +define Package/heimdal-server/install + $(INSTALL_DIR) $(1)/usr/sbin + $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/kadmin $(1)/usr/sbin + $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/ktutil $(1)/usr/sbin + $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/kstash $(1)/usr/sbin + $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/lib/kdc $(1)/usr/sbin + $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/lib/kadmind $(1)/usr/sbin + $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/lib/kpasswdd $(1)/usr/sbin +endef + +#define Build/InstallDev +# $(INSTALL_DIR) $(1)/usr/include/heimdal +# $(CP) $(PKG_BUILD_DIR)/include/heimdal/heimdal.h $(TOOLCHAIN_DIR)/include/sys +# $(CP) $(PKG_BUILD_DIR)/include/heimdal/libheimdal.h $(1)/usr/include/heimdal +# $(INSTALL_DIR) $(1)/usr/lib/ +# $(CP) $(PKG_BUILD_DIR)/libheimdal/.libs/libheimdal.{a,so*} $(1)/usr/lib/ +#endef + +$(eval $(call HostBuild)) +$(eval $(call BuildPackage,heimdal-libs)) +$(eval $(call BuildPackage,heimdal-client)) +$(eval $(call BuildPackage,heimdal-server)) diff --git a/package/lean/heimdal/files/roken-h-process.pl b/package/lean/heimdal/files/roken-h-process.pl new file mode 100644 index 000000000..e797dd224 --- /dev/null +++ b/package/lean/heimdal/files/roken-h-process.pl @@ -0,0 +1,184 @@ +#!/usr/bin/perl + +use Getopt::Std; + +my $debug = 0; + +getopts('dc:p:o:') || die "foo"; + +if ($opt_d) { + $debug = 1; +} + +die "missing arg" if (!defined $opt_c || !defined $opt_p || !defined $opt_o); + +my %defines; +my $IN; +my $OUT; + +print "parse config.h\n" if ($debug); + +open IN, $opt_c || die "failed open ${opt_c}"; + +my @nesting; + +push @nesting, 1; + +while () { + if (m/\s*#ifdef\s+(.*)/) { + my $var = $1; + if (defined $defines{$var}) { + push @nesting, 1; + } else { + push @nesting, 0; + } + next; + } elsif (m/\s*#ifndef\s+(.*)/) { + my $var = $1; + if (defined $defines{$var}) { + push @nesting, 0; + } else { + push @nesting, 1; + } + next; + } elsif (m/\s*#else/) { + my $var = pop @nesting; + $var = !$var; + push @nesting, $var; + next; + } elsif ($nesting[$#nesting] and m/\s*#define\s+(\w+)\s+(\S+)/) { + my $res = $2; + $res = 1 if (!defined $res); + $defines{$1} = $res; + } +} + +close IN; + +if ($debug) { + foreach my $i (keys %defines) { + print "k: $i v: $defines{$i}\n"; + } +} + +open IN, "$opt_p" || die "failed open ${opt_p}"; +open OUT, ">$opt_o" || die "failed open ${opt_o}"; + +print "parse roken.h.in\n" if ($debug); + +print OUT "/* This is an OS dependent, generated file */\n"; +print OUT "\n"; +print OUT "\n"; +print OUT "#ifndef __ROKEN_H__\n"; +print OUT "#define __ROKEN_H__\n"; +print OUT "\n"; + +@nesting = (1); + +while () { + if (m/\s*#ifdef\s+(.*)/) { + my $var = $1; + if (defined $defines{$var}) { + push @nesting, 1; + } else { + push @nesting, 0; + } + next; + } elsif (m/\s*#ifndef\s+(.*)/) { + my $var = $1; + if (defined $defines{$var}) { + push @nesting, 0; + } else { + push @nesting, 1; + } + next; + } elsif (m/\s*#if\s+(.*)/) { + my $res = parse_if($1); + print "line = $res: $1\n" if ($debug); + push @nesting, $res; + next; + } elsif (m/\s*#elif\s+(.*)/) { + my $res = pop @nesting; + if ($res gt 0) { + $res = -1; + } else { + my $res = parse_if($1); + } + push @nesting, $res; + next; + } elsif (m/\s*#else/) { + my $var = pop @nesting; + $var = !$var; + push @nesting, $var; + next; + } elsif (m/\s*#endif/) { + pop @nesting; + next; + } + print "line: $_\n" if ($debug); + print "nesting dep $#{nesting}\n" if ($debug); + my $i = 0, $t = 1; + while ($i le $#nesting) { + $t = 0 if ($nesting[$i] le 0); + print "nesting $i val $nesting[$i] -> $t\n" if ($debug); + $i++; + } + if ($t) { + print OUT; + } +} + +print OUT "\n"; +print OUT "#endif /* __ROKEN_H__ */\n"; + + +close IN; + +exit 0; + +sub parse_if +{ + my ($neg, $var); + + $_ = shift; + + if (m/^\s*$/) { + print "end $_\n" if ($debug); + return 1; + } elsif (m/^\(([^&]+)\&\&(.*)\)\s*\|\|\s*\(([^&]+)\&\&(.*)\)$/) { + print "($1 and $2) or ($3 and $4)\n" if ($debug); + return ((parse_if($1) and parse_if($2)) or (parse_if($3) and parse_if($4))); + } elsif (m/^([^&]+)\&\&(.*)$/) { + print "$1 and $2\n" if ($debug); + return parse_if($1) and parse_if($2); + } elsif (m/^([^\|]+)\|\|(.*)$/) { + print "$1 or $2\n" if ($debug); + return (parse_if($1) or parse_if($2)); + } elsif (m/^\s*(\!)?\s*defined\((\w+)\)/) { + ($neg, $var) = ($1, $2); + print "def: ${neg}-defined(${var})\n" if ($debug); + my $res = defined $defines{$var}; + if ($neg eq "!") { + if ($res) { + $res = 0; + } else { + $res = 1; + } + } + print "res: $res\n" if ($debug); + return $res; + } elsif (m/^\s*(\!)?(\w+)/) { + ($neg, $var) = ($1, $2); + print "var: $neg $var\n" if ($debug); + my $res; + if (defined $defines{$var}) { + $res = $defines{$var}; + } else { + $res = 0; + } + $res = ! $res if ($neg =~ m/!/); + print "res: $res\n" if ($debug); + return $res; + } + die "failed parse: $_\n"; +} diff --git a/package/lean/heimdal/patches/001-snprintf-len.patch b/package/lean/heimdal/patches/001-snprintf-len.patch new file mode 100644 index 000000000..2b3c658f1 --- /dev/null +++ b/package/lean/heimdal/patches/001-snprintf-len.patch @@ -0,0 +1,16 @@ +--- a/lib/roken/snprintf.c ++++ b/lib/roken/snprintf.c +@@ -109,13 +109,8 @@ + + /* longest integer types */ + +-#ifdef HAVE_LONG_LONG +-typedef unsigned long long u_longest; +-typedef long long longest; +-#else + typedef unsigned long u_longest; + typedef long longest; +-#endif + + + diff --git a/package/lean/heimdal/patches/002-remove-unused-version.patch b/package/lean/heimdal/patches/002-remove-unused-version.patch new file mode 100644 index 000000000..9e25557e0 --- /dev/null +++ b/package/lean/heimdal/patches/002-remove-unused-version.patch @@ -0,0 +1,10 @@ +--- a/configure ++++ b/configure +@@ -31283,7 +31283,6 @@ + #ifndef VERSION_HIDDEN + #define VERSION_HIDDEN + #endif +-VERSION_HIDDEN const char *heimdal_long_version = "@(#)\$Version: $PACKAGE_STRING by @USER@ on @HOST@ ($host) @DATE@ \$"; + VERSION_HIDDEN const char *heimdal_version = "Heimdal 1.5.3"; + EOF + diff --git a/package/lean/heimdal/patches/010-configure-fix-cross-compiling.patch b/package/lean/heimdal/patches/010-configure-fix-cross-compiling.patch new file mode 100644 index 000000000..25120dbd4 --- /dev/null +++ b/package/lean/heimdal/patches/010-configure-fix-cross-compiling.patch @@ -0,0 +1,26 @@ +--- a/configure ++++ b/configure +@@ -1455,6 +1455,10 @@ + fi + fi + ++if test "${with_cross_tools+set}" = set; then ++ cross_compiling=yes ++fi ++ + ac_tool_prefix= + test -n "$host_alias" && ac_tool_prefix=$host_alias- + +@@ -28246,6 +28250,12 @@ + krb_cv_compile_et="no" + krb_cv_com_err_need_r="" + krb_cv_compile_et_cross=no ++ ++if test "${with_cross_tools+set}" = set; then ++ krb_cv_compile_et_cross=yes ++ krb_cv_com_err=yes ++fi ++ + if test "${COMPILE_ET}" = "compile_et"; then + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether compile_et has the features we need" >&5 diff --git a/package/lean/heimdal/patches/100-build-fixes.patch b/package/lean/heimdal/patches/100-build-fixes.patch new file mode 100644 index 000000000..361237c8a --- /dev/null +++ b/package/lean/heimdal/patches/100-build-fixes.patch @@ -0,0 +1,42 @@ +--- a/kcm/cache.c ++++ b/kcm/cache.c +@@ -102,7 +102,7 @@ + for (p = ccache_head; p != NULL; p = p->next) { + if ((p->flags & KCM_FLAGS_VALID) == 0) + continue; +- if (memcmp(p->uuid, uuid, sizeof(uuid)) == 0) { ++ if (memcmp(p->uuid, uuid, sizeof(*uuid)) == 0) { + ret = 0; + break; + } +--- a/lib/hcrypto/engine.c ++++ b/lib/hcrypto/engine.c +@@ -88,7 +88,7 @@ + if(engine->destroy) + (*engine->destroy)(engine); + +- memset(engine, 0, sizeof(engine)); ++ memset(engine, 0, sizeof(*engine)); + engine->references = -1; + + +--- a/lib/hcrypto/md2.c ++++ b/lib/hcrypto/md2.c +@@ -130,5 +130,5 @@ + MD2_Update(m, pad, 16); + + memcpy(res, m->state, MD2_DIGEST_LENGTH); +- memset(m, 0, sizeof(m)); ++ memset(m, 0, sizeof(*m)); + } +--- a/lib/hcrypto/test_rand.c ++++ b/lib/hcrypto/test_rand.c +@@ -164,7 +164,7 @@ + + for (bit = 0; bit < 8; bit++) { + +- res = ((double)abs(len - bits[bit] * 2)) / (double)len; ++ res = abs(len - bits[bit] * 2) / (double)len; + if (res > 0.005) + errx(1, "head%d vs tail%d > 0.5%%%% %lf == %d vs %d", + bit, bit, res, len, bits[bit]); diff --git a/package/lean/samba4x/Makefile b/package/lean/samba4x/Makefile new file mode 100644 index 000000000..86489bf85 --- /dev/null +++ b/package/lean/samba4x/Makefile @@ -0,0 +1,283 @@ +# +# Copyright (C) 2007-2015 wongsyrone +# +# This is free software, licensed under the GNU General Public License v2. +# See /LICENSE for more information. +# + +include $(TOPDIR)/rules.mk + +PKG_NAME:=samba4x +PKG_VERSION:=4.4.2 +PKG_RELEASE:=1 + +PKG_SOURCE_URL:= \ + http://download.samba.org/pub/samba/stable \ + http://ftp.samba.org/pub/samba \ + http://ftp.samba.org/pub/samba/old-versions + +PKG_SOURCE:=samba-$(PKG_VERSION).tar.gz +PKG_BUILD_DIR:=$(BUILD_DIR)/samba-$(PKG_VERSION) +PKG_MD5SUM:=03a65a3adf08ceb1636ad59d234d7f9d + +PKG_LICENSE:=GPLv3 +PKG_LICENSE_FILES:=COPYING + +PKG_BUILD_DEPENDS:=heimdal + +PKG_BUILD_PARALLEL:=1 +PKG_INSTALL:=1 + +include $(INCLUDE_DIR)/package.mk +# for "uname release type" check +include $(INCLUDE_DIR)/kernel.mk + + +define Package/samba4x-server + SECTION:=net + CATEGORY:=Network + TITLE:=Samba $(PKG_VERSION) SMB/CIFS server + URL:=http://www.samba.org/ + DEPENDS:=+zlib +libpthread +libpopt +libcap +python-light +#DEPENDS+= +libreadline +libuuid +libtirpc libtirpc +endef + +define Package/samba4x-server/description + The Samba software suite is a collection of programs that implements the + SMB protocol for UNIX systems, allowing you to serve files and printers to + Windows, NT, OS/2 and DOS clients. This protocol is sometimes also referred + to as the LanManager or Netbios protocol. +endef + + +# fix include "dbwrap/dbwrap_open.h" not found in auth/credentials/credentials_secrets.c -I$(PKG_BUILD_DIR)/source3/lib +EXTRA_CFLAGS += \ + -ffunction-sections -fdata-sections \ + -Wno-deprecated-declarations +EXTRA_LDFLAGS += -Wl,--gc-sections + +# Use host compiled python2 as interpreter +# Use target python2-config to retrive cflags, ldflags, libs, etc. +# Must have python2 patched to make python2-config works + +# _python_sysroot="$(STAGING_DIR)" \ + _python_prefix="/usr" \ + _python_exec_prefix="/usr/bin" \ + PYTHON="$(STAGING_DIR_HOST)/bin/python2" + +CONFIGURE_VARS += \ + PYTHON_CONFIG="$(STAGING_DIR)/usr/bin/python2-config" \ + python_LDFLAGS="" \ + python_LIBDIR="" + +# XXX: Be sure to take care of commas(,) or you will get 'out of range' error when waf configuring settings. +SAMBA4_IDMAP_MODULES_SHARED := idmap_ad,idmap_rid,idmap_adex,idmap_hash,idmap_tdb2, +SAMBA4_IDMAP_MODULES_STATIC := +SAMBA4_PDB_MODULES_SHARED := pdb_wbc_sam,pdb_samba4, +SAMBA4_PDB_MODULES_STATIC := pdb_smbpasswd,pdb_tdbsam, +SAMBA4_AUTH_MODULES_SHARED := auth_wbc,auth_script,auth_samba4 +SAMBA4_AUTH_MODULES_STATIC := auth_sam,auth_unix, +SAMBA4_VFS_MODULES_STATIC := vfs_default,vfs_aio_pthread + + +SAMBA4_MODULES_SHARED = "${SAMBA4_IDMAP_MODULES_SHARED}${SAMBA4_PDB_MODULES_SHARED}${SAMBA4_AUTH_MODULES_SHARED}" +SAMBA4_MODULES_STATIC = "${SAMBA4_IDMAP_MODULES_STATIC}${SAMBA4_PDB_MODULES_STATIC}${SAMBA4_AUTH_MODULES_STATIC}${SAMBA4_VFS_MODULES_STATIC}" + +# Taken from package-defaults.mk +SAMBA_CONFIGURE_ARGS += \ + --target=$(GNU_TARGET_NAME) \ + --program-prefix="" \ + --prefix=$(CONFIGURE_PREFIX) \ + --exec-prefix=$(CONFIGURE_PREFIX) \ + --bindir=$(CONFIGURE_PREFIX)/bin \ + --sbindir=$(CONFIGURE_PREFIX)/sbin \ + --libexecdir=$(CONFIGURE_PREFIX)/lib \ + --sysconfdir=/etc \ + --datadir=$(CONFIGURE_PREFIX)/share \ + --localstatedir=/var \ + --mandir=$(CONFIGURE_PREFIX)/man \ + --infodir=$(CONFIGURE_PREFIX)/info + +# Should have a look before compiling. +SAMBA43_CACHE := " \ + \nChecking simple C program: OK \ + \nrpath library support: OK \ + \n-Wl,--version-script support: OK \ + \nChecking getconf LFS_CFLAGS: NO \ + \nChecking for large file support without additional flags: OK \ + \nChecking for -D_LARGE_FILES: OK \ + \nChecking correct behavior of strtoll: NO \ + \nChecking for working strptime: OK \ + \nChecking for C99 vsnprintf: OK \ + \nChecking for HAVE_SHARED_MMAP: OK \ + \nChecking for HAVE_MREMAP: OK \ + \nChecking for HAVE_INCOHERENT_MMAP: NO \ + \nChecking for HAVE_SECURE_MKSTEMP: OK \ + \nChecking for HAVE_IFACE_GETIFADDRS: OK \ + \nChecking for kernel change notify support: OK \ + \nChecking for Linux kernel oplocks: OK \ + \nChecking for kernel share modes: OK \ + \nChecking if can we convert from CP850 to UCS-2LE: OK \ + \nChecking if can we convert from UTF-8 to UCS-2LE: OK \ + \nChecking whether we can use Linux thread-specific credentials with 32-bit system calls: OK \ + \nChecking whether we can use Linux thread-specific credentials: OK \ + \nChecking whether setreuid is available: OK \ + \nChecking whether setresuid is available: OK \ + \nChecking whether seteuid is available: OK \ + \nChecking whether fcntl locking is available: OK \ + \nChecking whether the realpath function allows a NULL argument: OK \ + \nChecking whether POSIX capabilities are available: OK \ + \nChecking for the maximum value of the 'time_t' type: NO \ + \nChecking for ftruncate extend: OK \ + \nvfs_fileid checking for statfs() and struct statfs.f_fsid: OK \ + \ngetcwd takes a NULL argument: OK \ + \nChecking value of NSIG: \"65\" \ + \nChecking value of _NSIG: \"65\" \ + \nChecking value of SIGRTMAX: \"64\" \ + \nChecking value of SIGRTMIN: \"34\" \ + \n" +# \nChecking for the maximum value of the 'time_t' type: OK <<-- check it, not for sure. It seems musl-libc don't have max time_t + +# do the renaming trick +define Build/Prepare + $(call Build/Prepare/Default) + $(SED) 's#__OPENWRT_SAMBA_MULTICALL__#$(PKG_NAME)_multicall#g' $(PKG_BUILD_DIR)/source3/wscript_build + $(CP) ./files/python2-config "$(STAGING_DIR)/usr/bin/python2-config" +endef + +define Build/Configure + (cd $(PKG_BUILD_DIR); \ + echo -e >cache.txt $(SAMBA43_CACHE) " \ + \nChecking uname release type: \"$(LINUX_VERSION)\" \ + \nChecking uname machine type: \"$(ARCH)\" \ + \nChecking uname version type: \"#1 Tue Nov 1 12:34:56 UTC 2013\" \ + \nChecking uname sysname type: \"Linux\" \ + \n" ; \ + $(CONFIGURE_VARS) \ + ./buildtools/bin/waf configure -j$(shell nproc) \ + --cross-compile \ + --cross-answers=$(PKG_BUILD_DIR)/cache.txt \ + --hostcc="$(HOSTCC)" \ + $(SAMBA_CONFIGURE_ARGS) \ + --with-lockdir=/var/lock \ + --with-logfilebase=/var/log \ + --with-piddir=/var/run \ + --with-privatedir=/etc/samba \ + --enable-fhs \ + --without-dmapi \ + --disable-glusterfs \ + --disable-rpath \ + --disable-rpath-install \ + --disable-avahi \ + --disable-cups \ + --disable-iprint \ + --disable-gnutls \ + --with-relro \ + --with-sendfile-support \ + --without-acl-support \ + --without-ads \ + --without-ad-dc \ + --without-automount \ + --without-cluster-support \ + --without-dnsupdate \ + --without-fam \ + --without-gettext \ + --without-iconv \ + --without-ldap \ + --without-pam \ + --without-pie \ + --without-regedit \ + --without-systemd \ + --without-utmp \ + --without-winbind \ + --enable-auto-reconfigure \ + --nonshared-binary=$(PKG_NAME)_multicall \ + --with-static-modules=${SAMBA4_MODULES_STATIC} \ + --with-shared-modules=${SAMBA4_MODULES_SHARED} \ + --bundled-libraries='heimdal,!asn1_compile,!compile_et,!zlib,popt,talloc,pytalloc,pytalloc-util' \ + --without-quotas \ + --with-syslog \ + --nopyc \ + --nopyo \ + ) +endef +# leftovers of samba 4.0: --with-shared-modules=pdb_tdbsam,pdb_wbc_sam,idmap_nss,nss_info_template,auth_wbc +# simple file server: --bundled-libraries=NONE --builtin-libraries=NONE +# --bundled-libraries=ALL ---> do not find libs from system, use integrated libs +# '--nonshared-binary' works like '--disable-shared-libs' in samba 4.0.26 +# or use '--builtin-libraries' to specify which library to build into. +# --nonshared-binary=smbd/smbd,nmbd/nmbd,smbpasswd,smbcontrol,smbtree,smbstatus,smbcquotas,smbcacls,nmblookup,testparm,$(PKG_NAME)_multicall + +# 'builtin-libraries' +# smbd_base samba-util tdb talloc param pdb +# seems don't need: krb5samba + +# Some important options: +# +# --with-static-modules=STATIC_MODULES +# Comma-separated list of names of modules to statically link in +# --with-shared-modules=SHARED_MODULES +# Comma-separated list of names of modules to build shared +# --private-libraries=PRIVATE_LIBS +# comma separated list of normally public libraries to build instead as private libraries. May include !LIBNAME to disable making a library private. Can be 'NONE' or 'ALL' [auto] +# --builtin-libraries=BUILTIN_LIBRARIES +# command separated list of libraries to build directly into binaries [NONE] +# --nonshared-binary=NONSHARED_BINARIES +# Disable use of shared libs for the listed binaries +# + +# Disable some libs +# --without-libtdb \ bld.SAMBA_LIBRARY('tdb', +# --without-libtalloc \ +# --without-libnetapi \ bld.SAMBA3_LIBRARY('netapi', +# --without-libsmbclient \ +# --without-libsmbsharemodes \ +# + +# speed up +# $(shell nproc) +define Build/Compile + (cd $(PKG_BUILD_DIR); \ + ./buildtools/bin/waf build \ + --targets=$(PKG_NAME)_multicall \ + -j$(shell nproc) \ + ) +endef + +# Do NOT run 'make install' since we only need the multicall binary +define Build/Install + $(RSTRIP) $(PKG_BUILD_DIR)/bin/default/source3/$(PKG_NAME)_multicall +endef + +# XXX: Make sure the name of multicall binary matches name in 111-multicall-wscript-build.patch +define Package/samba4x-server/install + $(INSTALL_DIR) $(1)/etc/config + $(INSTALL_DATA) ./files/$(PKG_NAME).config $(1)/etc/config/samba4 + $(INSTALL_DIR) $(1)/etc/samba + $(INSTALL_DATA) ./files/smb.conf.template $(1)/etc/samba + $(INSTALL_DIR) $(1)/etc/init.d + $(INSTALL_BIN) ./files/$(PKG_NAME).init $(1)/etc/init.d/samba4 + $(INSTALL_DIR) $(1)/usr/sbin + $(INSTALL_BIN) $(PKG_BUILD_DIR)/bin/default/source3/$(PKG_NAME)_multicall $(1)/usr/sbin + $(LN) $(PKG_NAME)_multicall $(1)/usr/sbin/smbd + $(LN) $(PKG_NAME)_multicall $(1)/usr/sbin/nmbd + $(LN) $(PKG_NAME)_multicall $(1)/usr/sbin/smbpasswd + $(LN) $(PKG_NAME)_multicall $(1)/usr/sbin/pdbedit + $(INSTALL_DIR) $(1)/usr/bin + $(LN) ../sbin/$(PKG_NAME)_multicall $(1)/usr/bin/smbcontrol + $(LN) ../sbin/$(PKG_NAME)_multicall $(1)/usr/bin/smbtree + $(LN) ../sbin/$(PKG_NAME)_multicall $(1)/usr/bin/smbstatus + $(LN) ../sbin/$(PKG_NAME)_multicall $(1)/usr/bin/smbcquotas + $(LN) ../sbin/$(PKG_NAME)_multicall $(1)/usr/bin/smbcacls + $(LN) ../sbin/$(PKG_NAME)_multicall $(1)/usr/bin/nmblookup + $(LN) ../sbin/$(PKG_NAME)_multicall $(1)/usr/bin/testparm +endef + +define Package/samba4x-server/conffiles +/etc/config/samba4 +/etc/samba/smb.conf.template +/etc/samba/smbpasswd +endef + + +$(eval $(call BuildPackage,$(PKG_NAME)-server)) diff --git a/package/lean/samba4x/files/python2-config b/package/lean/samba4x/files/python2-config new file mode 100755 index 000000000..f86cbe052 --- /dev/null +++ b/package/lean/samba4x/files/python2-config @@ -0,0 +1,26 @@ +#!/bin/sh +# /tree-lede/staging_dir/target-powerpc_464fp_musl-1.1.15/usr/bin/python2-config +BASEDIR=$(cd `dirname $0`;cd ..;pwd) +case "$1" in +--prefix) + echo $BASEDIR +;; +--exec-prefix) + echo $BASEDIR +;; +--includes) + echo -I$BASEDIR/include/python2.7 -I$BASEDIR/include/python2.7 +;; +--libs) + echo -lpython2.7 -lpthread -ldl -lutil -lm +;; +--cflags) + echo -I$BASEDIR/include/python2.7 -I$BASEDIR/include/python2.7 +;; +--ldflags) + echo -lpython2.7 -lpthread -ldl -lutil -lm -Xlinker -export-dynamic +;; +*) + echo 'Usage: python2-config [--prefix|--exec-prefix|--includes|--libs|--cflags|--ldflags|--help]' +;; +esac diff --git a/package/lean/samba4x/files/samba4x.config b/package/lean/samba4x/files/samba4x.config new file mode 100644 index 000000000..eaaf1a50e --- /dev/null +++ b/package/lean/samba4x/files/samba4x.config @@ -0,0 +1,7 @@ +config samba + option 'enabled' '0' + option 'name' 'OpenWrt-SMB' + option 'workgroup' 'WORKGROUP' + option 'description' 'Samba on OpenWrt' + option 'charset' 'UTF-8' + option 'homes' '1' diff --git a/package/lean/samba4x/files/samba4x.init b/package/lean/samba4x/files/samba4x.init new file mode 100755 index 000000000..5682a0a57 --- /dev/null +++ b/package/lean/samba4x/files/samba4x.init @@ -0,0 +1,162 @@ +#!/bin/sh /etc/rc.common +# Copyright (C) 2008-2012 OpenWrt.org +# Copyright (C) 2015 wongsyrone + + +START=60 +USE_PROCD=1 + +smb_header() { + local interface + config_get interface $1 interface "loopback lan" + + # resolve interfaces + . /lib/functions/network.sh + local interfaces=$( + local net + for net in $interface; do + local device + network_get_device device "$net" && { + local subnet + network_get_subnet subnet "$net" && echo -n "$subnet " + network_get_subnet6 subnet "$net" && echo -n "$subnet " + } + + echo -n "${device:-$net} " + done + ) + + local name workgroup description charset domain + local hostname="$(uci_get system.@system[0].hostname)" + + config_get enabled $1 enabled "0" + config_get name $1 name "${hostname:-OpenWrt}" + config_get workgroup $1 workgroup "${hostname:-WORKGROUP}" + config_get description $1 description "Samba on ${hostname:-OpenWrt}" + config_get charset $1 charset "UTF-8" + config_get DISABLENB $1 disablenb "0" + + mkdir -p /var/etc + sed -e "s#|NAME|#$name#g" \ + -e "s#|WORKGROUP|#$workgroup#g" \ + -e "s#|DESCRIPTION|#$description#g" \ + -e "s#|INTERFACES|#$interfaces#g" \ + -e "s#|CHARSET|#$charset#g" \ + /etc/samba/smb.conf.template > /var/etc/smb.conf + + + [ "$DISABLENB" == "1" ] && echo >>/var/etc/smb.conf -e "\tdisable netbios = yes" + + [ -f /etc/krb5.keytab ] && { + KLIST=`klist -k /etc/krb5.keytab` + REALM=${KLIST##*@} + echo >>/var/etc/smb.conf -e "\tkerberos method = dedicated keytab" + echo >>/var/etc/smb.conf -e "\tdedicated keytab file = /etc/krb5.keytab" + echo >>/var/etc/smb.conf -e "\trealm = $REALM" + sed -i -e "s#workgroup = \(.*\)#workgroup = $REALM#g" /var/etc/smb.conf + workgroup=$REALM + } + + [ -S /var/run/ldapi ] && { + echo >>/var/etc/smb.conf -e "\tldapsam:trusted = yes" + echo >>/var/etc/smb.conf -e "\tldapsam:editposix = yes" + echo >>/var/etc/smb.conf -e "\tldap ssl = off" + echo >>/var/etc/smb.conf -e "\tdomain logons = yes" + sed -i -e "s#passdb backend = \(.*\)#passdb backend = ldapsam:ldapi:///#g" \ + /var/etc/smb.conf + } + + local homes + config_get_bool homes $1 homes 0 + [ $homes -gt 0 ] && { + cat <> /var/etc/smb.conf + +[homes] + comment = Home Directories + browseable = no + writable = yes + read only = no + create mask = 0750 +EOT + } + + [ -L /etc/samba/smb.conf ] || ln -nsf /var/etc/smb.conf /etc/samba/smb.conf +} + +smb_add_share() { + local name + local path + local users + #local public + local writable + local printable + local create_mask + local guest_ok + + config_get name $1 name + config_get path $1 path + config_get users $1 users + #config_get public $1 public + config_get writable $1 writable + config_get printable $1 printable + config_get create_mask $1 create_mask + config_get guest_ok $1 guest_ok + + [ -z "$name" -o -z "$path" ] && return + + echo -e "\n[$name]\n\tpath = $path" >> /var/etc/smb.conf + [ -n "$users" ] && echo -e "\tvalid users = $users" >> /var/etc/smb.conf + [ -n "$public" ] && echo -e "\tpublic = $public" >> /var/etc/smb.conf + [ -n "$writable" ] && echo -e "\twritable = $writable" >> /var/etc/smb.conf + [ -n "$printable" ] && echo -e "\tprintable = $printable" >> /var/etc/smb.conf + [ -n "$create_mask" ] && echo -e "\tcreate mask = $create_mask" >> /var/etc/smb.conf + [ -n "$guest_ok" ] && echo -e "\tguest ok = $guest_ok\n\tpublic = $guest_ok" >> /var/etc/smb.conf +} + + +init_config() { + # Create samba dirs + [ -d /var/lib/samba ] || mkdir -p /var/lib/samba + [ -d /var/cache/samba ] || mkdir -p /var/cache/samba + [ -d /var/run/samba ] || mkdir -p /var/run/samba + [ -d /var/lock ] || mkdir -p /var/lock + chmod 0755 /var/lock + + config_load samba4 + config_foreach smb_header samba + config_foreach smb_add_share sambashare +} + +reload_service() { + init_config + + killall -HUP smbd +} + +service_triggers() { + procd_add_reload_trigger samba4 +} + +start_service() { + init_config + + if [ "1" = "$enabled" ] || [ "on" = "$enabled" ] || [ "true" = "$enabled" ]; then + procd_open_instance + procd_set_param command /usr/sbin/smbd -F + procd_set_param respawn + procd_close_instance + # lower priority using renice in busybox + renice -n 2 $(pidof smbd) + + [ "$DISABLENB" != "1" ] && { + procd_open_instance + procd_set_param command /usr/sbin/nmbd -F + procd_set_param respawn + procd_close_instance + # lower priority using renice in busybox + renice -n 2 $(pidof nmbd) + } + else + echo "samba4 is disabled" + fi +} diff --git a/package/lean/samba4x/files/smb.conf.template b/package/lean/samba4x/files/smb.conf.template new file mode 100644 index 000000000..ccb5e757d --- /dev/null +++ b/package/lean/samba4x/files/smb.conf.template @@ -0,0 +1,42 @@ +[global] + netbios name = |NAME| + interfaces = |INTERFACES| + server string = |DESCRIPTION| + hosts allow = 192.168.1. 127. + unix charset = |CHARSET| + workgroup = |WORKGROUP| + passdb backend = smbpasswd + # passdb backend = tdbsam:/etc/samba/passdb.tdb + inherit owner = yes + create mask = 0777 + directory mask = 0777 + force create mode = 0777 + force directory mode = 0777 + security = user + smb encrypt = disabled + smb passwd file = /etc/samba/smbpasswd + lock directory = /var/lock + browseable = yes + domain master = yes + encrypt passwords = yes + enable core files = no + guest account = nobody + invalid users = root + local master = yes + load printers = no + map to guest = Bad User + os level = 20 + preferred master = yes + printable = no + writeable = yes + strict allocate = yes + strict locking = no + socket options = TCP_NODELAY IPTOS_LOWDELAY + use sendfile = yes + max xmit = 65535 + max connections = 8 + deadtime = 30 + dns proxy = no + aio read size = 0 + aio write size = 0 + diff --git a/package/lean/samba4x/patches/000-disable-libbsd.patch b/package/lean/samba4x/patches/000-disable-libbsd.patch new file mode 100644 index 000000000..3c22c4a51 --- /dev/null +++ b/package/lean/samba4x/patches/000-disable-libbsd.patch @@ -0,0 +1,25 @@ +Disable libbsd support, samba4 uses a global config.h for its own +codebase and that of heimdal (when building with builtin). +This causes redefinition conflicts for link(2) when both standard unistd.h +and bsd/unistd.h get included. + +Signed-off-by: Gustavo Zacarias + +--- a/lib/replace/wscript ++++ b/lib/replace/wscript +@@ -256,15 +256,6 @@ def configure(conf): + + conf.CHECK_FUNCS('prctl dirname basename') + +- # libbsd on some platforms provides strlcpy and strlcat +- if not conf.CHECK_FUNCS('strlcpy strlcat'): +- conf.CHECK_FUNCS_IN('strlcpy strlcat', 'bsd', headers='bsd/string.h', +- checklibc=True) +- if not conf.CHECK_FUNCS('getpeereid'): +- conf.CHECK_FUNCS_IN('getpeereid', 'bsd', headers='sys/types.h bsd/unistd.h') +- if not conf.CHECK_FUNCS_IN('setproctitle', 'setproctitle', headers='setproctitle.h'): +- conf.CHECK_FUNCS_IN('setproctitle', 'bsd', headers='sys/types.h bsd/unistd.h') +- + conf.CHECK_CODE(''' + struct ucred cred; + socklen_t cred_len; diff --git a/package/lean/samba4x/patches/004-pythogn-DEBUGLEVEL-undefined.patch b/package/lean/samba4x/patches/004-pythogn-DEBUGLEVEL-undefined.patch new file mode 100644 index 000000000..05cc378bb --- /dev/null +++ b/package/lean/samba4x/patches/004-pythogn-DEBUGLEVEL-undefined.patch @@ -0,0 +1,11 @@ +--- a/python/pyglue.c ++++ b/python/pyglue.c +@@ -112,7 +112,7 @@ static PyObject *py_set_debug_level(PyOb + unsigned level; + if (!PyArg_ParseTuple(args, "I", &level)) + return NULL; +- (DEBUGLEVEL) = level; ++// (DEBUGLEVEL) = level; + Py_RETURN_NONE; + } + diff --git a/package/lean/samba4x/patches/018-avoid-get-config-by-native-ncurses.patch b/package/lean/samba4x/patches/018-avoid-get-config-by-native-ncurses.patch new file mode 100644 index 000000000..66ac64a20 --- /dev/null +++ b/package/lean/samba4x/patches/018-avoid-get-config-by-native-ncurses.patch @@ -0,0 +1,22 @@ +waf trys to get package's configuration by native ncurses6-config. +it will make native header files and library be used. + +Signed-off-by: Bian Naimeng + +--- a/source3/wscript_configure_system_ncurses ++++ b/source3/wscript_configure_system_ncurses +@@ -2,14 +2,6 @@ import Logs, Options, sys + + Logs.info("Looking for ncurses features") + +-conf.find_program('ncurses5-config', var='NCURSES_CONFIG') +-if not conf.env.NCURSES_CONFIG: +- conf.find_program('ncurses6-config', var='NCURSES_CONFIG') +- +-if conf.env.NCURSES_CONFIG: +- conf.CHECK_CFG(path=conf.env.NCURSES_CONFIG, args="--cflags --libs", +- package="", uselib_store="NCURSES") +- + conf.CHECK_HEADERS('ncurses.h menu.h panel.h form.h', lib='ncurses') + + conf.CHECK_FUNCS_IN('initscr', 'ncurses') diff --git a/package/lean/samba4x/patches/020-splice-support.patch b/package/lean/samba4x/patches/020-splice-support.patch new file mode 100644 index 000000000..9dda8c8c0 --- /dev/null +++ b/package/lean/samba4x/patches/020-splice-support.patch @@ -0,0 +1,91 @@ +From d78eafdbd5ae00f77ce11f80ad142eb3c109278b Mon Sep 17 00:00:00 2001 +From: Lior Amsalem +Date: Mon, 2 Dec 2013 11:04:56 +0200 +Subject: [PATCH 1/4] samba 4.0.9 splice support + +Signed-off-by: Lior Amsalem +--- + source3/lib/recvfile.c | 46 ++++++++++++++++++++-------------------------- + 1 file changed, 20 insertions(+), 26 deletions(-) + +--- a/source3/lib/recvfile.c ++++ b/source3/lib/recvfile.c +@@ -43,6 +43,10 @@ + #define TRANSFER_BUF_SIZE (128*1024) + #endif + ++#define SPLICE_F_COPY 0 ++#define MAX_ITERATIONS 4 ++#define RECEIVE_BUF_SIZE 131072 ++ + static ssize_t default_sys_recvfile(int fromfd, + int tofd, + off_t offset, +@@ -158,10 +162,10 @@ ssize_t sys_recvfile(int fromfd, + off_t offset, + size_t count) + { +- static int pipefd[2] = { -1, -1 }; +- static bool try_splice_call = false; ++ static bool try_splice_call = true; + size_t total_written = 0; + loff_t splice_offset = offset; ++ size_t current_count; + + DEBUG(10,("sys_recvfile: from = %d, to = %d, " + "offset=%.0f, count = %lu\n", +@@ -186,20 +190,22 @@ ssize_t sys_recvfile(int fromfd, + count); + } + +- if ((pipefd[0] == -1) && (pipe(pipefd) == -1)) { +- try_splice_call = false; +- return default_sys_recvfile(fromfd, tofd, offset, count); +- } +- + while (count > 0) { +- int nread, to_write; ++ int nread, try_again; ++ ++ if (count > RECEIVE_BUF_SIZE){ ++ current_count=RECEIVE_BUF_SIZE; ++ } else { ++ current_count=count; ++ } ++ try_again = MAX_ITERATIONS; ++ do { ++ nread = splice(fromfd, NULL, tofd, &offset, current_count, SPLICE_F_COPY); ++ if (nread == -1) ++ try_again--; ++ } while(nread ==-1 && try_again); + +- nread = splice(fromfd, NULL, pipefd[1], NULL, +- MIN(count, 16384), SPLICE_F_MOVE); + if (nread == -1) { +- if (errno == EINTR) { +- continue; +- } + if (total_written == 0 && + (errno == EBADF || errno == EINVAL)) { + try_splice_call = false; +@@ -221,19 +227,7 @@ ssize_t sys_recvfile(int fromfd, + } + break; + } +- +- to_write = nread; +- while (to_write > 0) { +- int thistime; +- thistime = splice(pipefd[0], NULL, tofd, +- &splice_offset, to_write, +- SPLICE_F_MOVE); +- if (thistime == -1) { +- goto done; +- } +- to_write -= thistime; +- } +- ++ + total_written += nread; + count -= nread; + } diff --git a/package/lean/samba4x/patches/022-wscript.patch b/package/lean/samba4x/patches/022-wscript.patch new file mode 100644 index 000000000..b77cbd20a --- /dev/null +++ b/package/lean/samba4x/patches/022-wscript.patch @@ -0,0 +1,15 @@ +--- a/source3/wscript ++++ b/source3/wscript +@@ -68,6 +68,12 @@ def set_options(opt): + help=("Directory under which libcephfs is installed"), + action="store", dest='libcephfs_dir', default=None) + ++ opt.add_option('--program-suffix', ++ help=("Directory under which libcephfs is installed")) ++ ++ opt.add_option('--disable-nls', ++ help=("Directory under which libcephfs is installed")) ++ + opt.SAMBA3_ADD_OPTION('glusterfs', with_name="enable", without_name="disable", default=True) + + opt.add_option('--enable-vxfs', diff --git a/package/lean/samba4x/patches/023-wscript_perl_fixup.patch b/package/lean/samba4x/patches/023-wscript_perl_fixup.patch new file mode 100644 index 000000000..fb448f154 --- /dev/null +++ b/package/lean/samba4x/patches/023-wscript_perl_fixup.patch @@ -0,0 +1,26 @@ +From: Andrew Bartlett +Date: Wed, 26 Oct 2016 00:06:12 +0000 (+1300) +Subject: build: Fix build with perl on debian sid. +X-Git-Url: http://git.catalyst.net.nz/gw?p=samba.git;a=commitdiff_plain;h=edb109f6 + +build: Fix build with perl on debian sid. + +It appears that "." is no longer in perl_inc + +Signed-off-by: Andrew Bartlett +--- + +diff --git a/buildtools/wafsamba/samba_perl.py b/buildtools/wafsamba/samba_perl.py +index f2f176d..2e9a53a 100644 +--- a/buildtools/wafsamba/samba_perl.py ++++ b/buildtools/wafsamba/samba_perl.py +@@ -49,7 +49,8 @@ def SAMBA_CHECK_PERL(conf, mandatory=True, version=(5,0,0)): + conf.env.PERL_LIB_INSTALL_DIR = perl_lib_install_dir + + perl_inc = read_perl_config_var('print "@INC"') +- perl_inc.remove('.') ++ if '.' in perl_inc: ++ perl_inc.remove('.') + conf.start_msg("PERL_INC: ") + conf.end_msg("%s" % (perl_inc), 'GREEN') + conf.env.PERL_INC = perl_inc diff --git a/package/lean/samba4x/patches/110-multicall.patch b/package/lean/samba4x/patches/110-multicall.patch new file mode 100644 index 000000000..c5641b6e0 --- /dev/null +++ b/package/lean/samba4x/patches/110-multicall.patch @@ -0,0 +1,77 @@ +--- /dev/null ++++ b/source3/multicall.c +@@ -0,0 +1,74 @@ ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++ ++extern int smbd_main(int argc, char **argv); ++extern int nmbd_main(int argc, char **argv); ++extern int smbpasswd_main(int argc, char **argv); ++extern int smbcontrol_main(int argc, char **argv); ++extern int smbtree_main(int argc, char **argv); ++extern int smbstatus_main(int argc, char **argv); ++extern int smbcquotas_main(int argc, char **argv); ++extern int smbcacls_main(int argc, char **argv); ++extern int nmblookup_main(int argc, char **argv); ++extern int testparm_main(int argc, char **argv); ++extern int pdbedit_main(int argc, char **argv); ++ ++static struct { ++ const char *name; ++ int (*func_main)(int argc, char **argv); ++} multicall[] = { ++ { "smbd", smbd_main }, ++ { "nmbd", nmbd_main }, ++ { "smbpasswd", smbpasswd_main }, ++ { "smbcontrol", smbcontrol_main }, ++ { "smbtree", smbtree_main }, ++ { "smbstatus", smbstatus_main }, ++ { "smbcquotas", smbcquotas_main }, ++ { "smbcacls", smbcacls_main }, ++ { "nmblookup", nmblookup_main }, ++ { "testparm", testparm_main }, ++ { "pdbedit", pdbedit_main }, ++}; ++ ++#define ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0])) ++ ++int main(int argc, char **argv) ++{ ++ unsigned int i, len; ++ extern char *__progname; ++ char path[PATH_MAX], *self; ++ ++ len = readlink("/proc/self/exe", path, sizeof(path)); ++ path[len] = 0; ++ for (i=len-2; i>0 && path[i] != '/'; --i); ++ self = path + i + 1; ++ ++ if (0 == strcmp(__progname, self)) { ++ if (argc == 1) goto usage; ++ argv++; ++ --argc; ++ __progname = argv[0]; ++ } ++ ++ for (i = 0; i < ARRAY_SIZE(multicall); i++) { ++ if (0 == strcmp(__progname, multicall[i].name)) { ++ return multicall[i].func_main(argc, argv); ++ } ++ } ++ ++usage: ++ fprintf(stderr, "%s multicall binary\nAvailable commands:\n\n", self); ++ for (i = 0; i < ARRAY_SIZE(multicall); i++) { ++ fprintf(stderr, "%s", multicall[i].name); ++ if (i != 0 && i != ARRAY_SIZE(multicall)-1) ++ fprintf(stderr, ", "); ++ } ++ fprintf(stderr, "\n"); ++ ++ return 1; ++} diff --git a/package/lean/samba4x/patches/111-multicall-wscript-build.patch b/package/lean/samba4x/patches/111-multicall-wscript-build.patch new file mode 100644 index 000000000..7671c5560 --- /dev/null +++ b/package/lean/samba4x/patches/111-multicall-wscript-build.patch @@ -0,0 +1,84 @@ +--- a/source3/wscript_build ++++ b/source3/wscript_build +@@ -1196,7 +1196,7 @@ bld.SAMBA3_BINARY('testparm', + param + popt_samba3''') + +-smbstatus_source = 'utils/status.c smbd/notify_msg.c' ++smbstatus_source = 'utils/status.c' + + if bld.CONFIG_GET("WITH_PROFILE"): + smbstatus_source += ' utils/status_profile.c' +@@ -1512,6 +1512,72 @@ bld.SAMBA3_BINARY('spotlight2sparql', + enabled=bld.env.with_spotlight, + install=False) + ++ ++bld.SAMBA3_SUBSYSTEM('SMBD_MULTI', ++ source='smbd/server.c', ++ cflags='-Dmain=smbd_main') ++ ++bld.SAMBA3_SUBSYSTEM('NMBD_MULTI', ++ source='nmbd/nmbd.c', ++ cflags='-Dmain=nmbd_main') ++ ++bld.SAMBA3_SUBSYSTEM('SMBPASSWD_MULTI', ++ source='utils/smbpasswd.c', ++ cflags='-Dmain=smbpasswd_main') ++ ++bld.SAMBA3_SUBSYSTEM('SMBCONTROL_MULTI', ++ source='utils/smbcontrol.c', ++ cflags='-Dmain=smbcontrol_main') ++ ++bld.SAMBA3_SUBSYSTEM('SMBTREE_MULTI', ++ source='utils/smbtree.c', ++ cflags='-Dmain=smbtree_main') ++ ++bld.SAMBA3_SUBSYSTEM('SMBSTATUS_MULTI', ++ source=smbstatus_source, ++ cflags='-Dmain=smbstatus_main') ++ ++bld.SAMBA3_SUBSYSTEM('SMBCQUOTAS_MULTI', ++ source='utils/smbcquotas.c', ++ cflags='-Dmain=smbcquotas_main') ++ ++bld.SAMBA3_SUBSYSTEM('SMBCACLS_MULTI', ++ source='utils/smbcacls.c lib/util_sd.c', ++ cflags='-Dmain=smbcacls_main') ++ ++bld.SAMBA3_SUBSYSTEM('NMBLOOKUP_MULTI', ++ source='utils/nmblookup.c', ++ cflags='-Dmain=nmblookup_main') ++ ++bld.SAMBA3_SUBSYSTEM('TESTPARM_MULTI', ++ source='utils/testparm.c', ++ cflags='-Dmain=testparm_main') ++ ++bld.SAMBA3_SUBSYSTEM('PDBEDIT_MULTI', ++ source='utils/pdbedit.c', ++ cflags='-Dmain=pdbedit_main') ++ ++bld.SAMBA3_BINARY('__OPENWRT_SAMBA_MULTICALL__', ++ source='''multicall.c smbd/smbd_cleanupd.c ++ nmbd/asyncdns.c nmbd/nmbd_become_dmb.c ++ nmbd/nmbd_become_lmb.c nmbd/nmbd_browserdb.c ++ nmbd/nmbd_browsesync.c nmbd/nmbd_elections.c ++ nmbd/nmbd_incomingdgrams.c nmbd/nmbd_incomingrequests.c ++ nmbd/nmbd_lmhosts.c nmbd/nmbd_logonnames.c nmbd/nmbd_mynames.c ++ nmbd/nmbd_namelistdb.c nmbd/nmbd_namequery.c ++ nmbd/nmbd_nameregister.c nmbd/nmbd_namerelease.c ++ nmbd/nmbd_nodestatus.c nmbd/nmbd_packets.c ++ nmbd/nmbd_processlogon.c nmbd/nmbd_responserecordsdb.c ++ nmbd/nmbd_sendannounce.c nmbd/nmbd_serverlistdb.c ++ nmbd/nmbd_subnetdb.c nmbd/nmbd_winsproxy.c nmbd/nmbd_winsserver.c ++ nmbd/nmbd_workgroupdb.c nmbd/nmbd_synclists.c''', ++ deps='''smbd_base SMBD_MULTI NMBD_MULTI SMBPASSWD_MULTI ++ SMBCONTROL_MULTI SMBTREE_MULTI SMBSTATUS_MULTI ++ SMBCQUOTAS_MULTI SMBCACLS_MULTI NMBLOOKUP_MULTI PDBEDIT_MULTI ++ PASSWD_UTIL PASSCHANGE TESTPARM_MULTI EPMD LSASD FSSD ++ param''', ++ install_path='${SBINDIR}') ++ + ########################## INCLUDES ################################# + + bld.RECURSE('auth') diff --git a/package/lean/samba4x/patches/120-add_missing_ifdef.patch b/package/lean/samba4x/patches/120-add_missing_ifdef.patch new file mode 100644 index 000000000..797374174 --- /dev/null +++ b/package/lean/samba4x/patches/120-add_missing_ifdef.patch @@ -0,0 +1,26 @@ +#--- a/source3/librpc/rpc/rpc_common.c +#+++ b/source3/librpc/rpc/rpc_common.c +#@@ -120,9 +120,11 @@ static bool initialize_interfaces(void) +# if (!smb_register_ndr_interface(&ndr_table_netdfs)) { +# return false; +# } +#+#ifdef DEVELOPER +# if (!smb_register_ndr_interface(&ndr_table_rpcecho)) { +# return false; +# } +#+#endif +# if (!smb_register_ndr_interface(&ndr_table_initshutdown)) { +# return false; +# } +--- a/source3/rpcclient/rpcclient.c ++++ b/source3/rpcclient/rpcclient.c +@@ -622,7 +622,9 @@ static struct cmd_set *rpcclient_command + netlogon_commands, + srvsvc_commands, + dfs_commands, ++#ifdef DEVELOPER + echo_commands, ++#endif + epmapper_commands, + shutdown_commands, + test_commands, diff --git a/package/lean/samba4x/patches/200-remove_printer_support.patch b/package/lean/samba4x/patches/200-remove_printer_support.patch new file mode 100644 index 000000000..4296534ec --- /dev/null +++ b/package/lean/samba4x/patches/200-remove_printer_support.patch @@ -0,0 +1,355 @@ +--- a/source3/rpc_server/rpc_service_setup.c ++++ b/source3/rpc_server/rpc_service_setup.c +@@ -553,10 +553,12 @@ bool dcesrv_ep_setup(struct tevent_conte + goto done; + } + ++#ifdef PRINTER_SUPPORT + ok = rpc_setup_spoolss(ev_ctx, msg_ctx); + if (!ok) { + goto done; + } ++#endif + + ok = rpc_setup_svcctl(ev_ctx, msg_ctx); + if (!ok) { +--- a/source3/rpcclient/rpcclient.c ++++ b/source3/rpcclient/rpcclient.c +@@ -618,7 +618,9 @@ static struct cmd_set *rpcclient_command + lsarpc_commands, + ds_commands, + samr_commands, ++#ifdef PRINTER_SUPPORT + spoolss_commands, ++#endif + netlogon_commands, + srvsvc_commands, + dfs_commands, +--- a/source3/rpc_server/svcctl/srv_svcctl_nt.c ++++ b/source3/rpc_server/svcctl/srv_svcctl_nt.c +@@ -86,9 +86,11 @@ bool init_service_op_table( void ) + + /* add builtin services */ + ++#ifdef PRINTER_SUPPORT + svcctl_ops[i].name = talloc_strdup( svcctl_ops, "Spooler" ); + svcctl_ops[i].ops = &spoolss_svc_ops; + i++; ++#endif + + svcctl_ops[i].name = talloc_strdup( svcctl_ops, "NETLOGON" ); + svcctl_ops[i].ops = &netlogon_svc_ops; +--- a/source3/printing/spoolssd.c ++++ b/source3/printing/spoolssd.c +@@ -614,6 +614,10 @@ pid_t start_spoolssd(struct tevent_conte + int ret; + bool ok; + ++#ifndef PRINTER_SUPPORT ++ return; ++#endif ++ + DEBUG(1, ("Forking SPOOLSS Daemon\n")); + + /* +--- a/source3/utils/net_rpc.c ++++ b/source3/utils/net_rpc.c +@@ -7987,6 +7987,10 @@ static int rpc_printer_publish(struct ne + {NULL, NULL, 0, NULL, NULL} + }; + ++#ifndef PRINTER_SUPPORT ++ return 0; ++#endif ++ + if (argc == 0) { + if (c->display_usage) { + d_printf(_("Usage:\n")); +--- a/source3/smbd/reply.c ++++ b/source3/smbd/reply.c +@@ -5765,7 +5765,11 @@ void reply_printopen(struct smb_request + return; + } + +- if (!CAN_PRINT(conn)) { ++ ++#ifdef PRINTER_SUPPORT ++ if (!CAN_PRINT(conn)) ++#endif ++ { + reply_nterror(req, NT_STATUS_ACCESS_DENIED); + END_PROFILE(SMBsplopen); + return; +@@ -5871,7 +5875,10 @@ void reply_printqueue(struct smb_request + is really quite gross and only worked when there was only + one printer - I think we should now only accept it if they + get it right (tridge) */ +- if (!CAN_PRINT(conn)) { ++#ifdef PRINTER_SUPPORT ++ if (!CAN_PRINT(conn)) ++#endif ++ { + reply_nterror(req, NT_STATUS_ACCESS_DENIED); + END_PROFILE(SMBsplretq); + return; +--- a/source3/smbd/lanman.c ++++ b/source3/smbd/lanman.c +@@ -784,6 +784,10 @@ static bool api_DosPrintQGetInfo(struct + union spoolss_JobInfo *job_info = NULL; + union spoolss_PrinterInfo printer_info; + ++#ifndef PRINTER_SUPPORT ++ return False; ++#endif ++ + if (!str1 || !str2 || !p) { + return False; + } +@@ -999,6 +1003,10 @@ static bool api_DosPrintQEnum(struct smb + union spoolss_DriverInfo *driver_info; + union spoolss_JobInfo **job_info; + ++#ifndef PRINTER_SUPPORT ++ return False; ++#endif ++ + if (!param_format || !output_format1 || !p) { + return False; + } +@@ -3114,6 +3122,10 @@ static bool api_RDosPrintJobDel(struct s + struct spoolss_DevmodeContainer devmode_ctr; + enum spoolss_JobControl command; + ++#ifndef PRINTER_SUPPORT ++ return False; ++#endif ++ + if (!str1 || !str2 || !p) { + return False; + } +@@ -3247,6 +3259,10 @@ static bool api_WPrintQueueCtrl(struct s + struct sec_desc_buf secdesc_ctr; + enum spoolss_PrinterControl command; + ++#ifndef PRINTER_SUPPORT ++ return False; ++#endif ++ + if (!str1 || !str2 || !QueueName) { + return False; + } +@@ -3413,6 +3429,10 @@ static bool api_PrintJobInfo(struct smbd + union spoolss_JobInfo info; + struct spoolss_SetJobInfo1 info1; + ++#ifndef PRINTER_SUPPORT ++ return False; ++#endif ++ + if (!str1 || !str2 || !p) { + return False; + } +@@ -4567,6 +4587,10 @@ static bool api_WPrintJobGetInfo(struct + struct spoolss_DevmodeContainer devmode_ctr; + union spoolss_JobInfo info; + ++#ifndef PRINTER_SUPPORT ++ return False; ++#endif ++ + if (!str1 || !str2 || !p) { + return False; + } +@@ -4705,6 +4729,10 @@ static bool api_WPrintJobEnumerate(struc + uint32_t count = 0; + union spoolss_JobInfo *info; + ++#ifndef PRINTER_SUPPORT ++ return False; ++#endif ++ + if (!str1 || !str2 || !p) { + return False; + } +@@ -4910,6 +4938,10 @@ static bool api_WPrintDestGetInfo(struct + struct spoolss_DevmodeContainer devmode_ctr; + union spoolss_PrinterInfo info; + ++#ifndef PRINTER_SUPPORT ++ return False; ++#endif ++ + if (!str1 || !str2 || !p) { + return False; + } +@@ -5046,6 +5078,10 @@ static bool api_WPrintDestEnum(struct sm + union spoolss_PrinterInfo *info; + uint32_t count; + ++#ifndef PRINTER_SUPPORT ++ return False; ++#endif ++ + if (!str1 || !str2 || !p) { + return False; + } +@@ -5149,6 +5185,10 @@ static bool api_WPrintDriverEnum(struct + int succnt; + struct pack_desc desc; + ++#ifndef PRINTER_SUPPORT ++ return False; ++#endif ++ + if (!str1 || !str2 || !p) { + return False; + } +@@ -5213,6 +5253,10 @@ static bool api_WPrintQProcEnum(struct s + int succnt; + struct pack_desc desc; + ++#ifndef PRINTER_SUPPORT ++ return False; ++#endif ++ + if (!str1 || !str2 || !p) { + return False; + } +@@ -5277,6 +5321,10 @@ static bool api_WPrintPortEnum(struct sm + int succnt; + struct pack_desc desc; + ++#ifndef PRINTER_SUPPORT ++ return False; ++#endif ++ + if (!str1 || !str2 || !p) { + return False; + } +--- a/source3/smbd/server_exit.c ++++ b/source3/smbd/server_exit.c +@@ -198,7 +198,9 @@ static void exit_server_common(enum serv + rpc_eventlog_shutdown(); + rpc_ntsvcs_shutdown(); + rpc_svcctl_shutdown(); ++#ifdef PRINTER_SUPPORT + rpc_spoolss_shutdown(); ++#endif + + rpc_srvsvc_shutdown(); + rpc_winreg_shutdown(); +--- a/source3/smbd/open.c ++++ b/source3/smbd/open.c +@@ -2430,6 +2430,9 @@ static NTSTATUS open_file_ntcreate(conne + * Most of the passed parameters are ignored. + */ + ++#ifndef PRINTER_SUPPORT ++ return NT_STATUS_ACCESS_DENIED; ++#endif + if (pinfo) { + *pinfo = FILE_WAS_CREATED; + } +--- a/source3/smbd/close.c ++++ b/source3/smbd/close.c +@@ -727,6 +727,9 @@ static NTSTATUS close_normal_file(struct + } + + if (fsp->print_file) { ++#ifndef PRINTER_SUPPORT ++ return NT_STATUS_OK; ++#endif + /* FIXME: return spool errors */ + print_spool_end(fsp, close_type); + file_free(req, fsp); +--- a/source3/smbd/fileio.c ++++ b/source3/smbd/fileio.c +@@ -318,6 +318,10 @@ ssize_t write_file(struct smb_request *r + uint32_t t; + int ret; + ++#ifndef PRINTER_SUPPORT ++ return -1; ++#endif ++ + ret = print_spool_write(fsp, data, n, pos, &t); + if (ret) { + errno = ret; +--- a/source3/smbd/smb2_create.c ++++ b/source3/smbd/smb2_create.c +@@ -633,7 +633,10 @@ static struct tevent_req *smbd_smb2_crea + } + + status = file_new(smb1req, smb1req->conn, &result); +- if(!NT_STATUS_IS_OK(status)) { ++#ifdef PRINTER_SUPPORT ++ if(!NT_STATUS_IS_OK(status)) ++#endif ++ { + tevent_req_nterror(req, status); + return tevent_req_post(req, ev); + } +--- a/source3/smbd/process.c ++++ b/source3/smbd/process.c +@@ -2895,8 +2895,10 @@ static bool housekeeping_fn(const struct + + change_to_root_user(); + ++#ifdef PRINTER_SUPPORT + /* update printer queue caches if necessary */ + update_monitored_printq_cache(sconn->msg_ctx); ++#endif + + /* check if we need to reload services */ + check_reload(sconn, time_mono(NULL)); +--- a/source3/smbd/server.c ++++ b/source3/smbd/server.c +@@ -1679,6 +1679,7 @@ extern void build_options(bool screen); + start_fssd(ev_ctx, msg_ctx); + } + ++#ifdef PRINTER_SUPPORT + if (!lp__disable_spoolss() && + (rpc_spoolss_daemon() != RPC_DAEMON_DISABLED)) { + bool bgq = lp_parm_bool(-1, "smbd", "backgroundqueue", true); +@@ -1699,6 +1700,7 @@ extern void build_options(bool screen); + if (!printing_subsystem_init(ev_ctx, msg_ctx, false, false)) { + exit(1); + } ++#endif + } + + if (!is_daemon) { +@@ -1731,12 +1733,14 @@ extern void build_options(bool screen); + if (!open_sockets_smbd(parent, ev_ctx, msg_ctx, ports)) + exit_server("open_sockets_smbd() failed"); + ++#ifdef PRINTER_SUPPORT + /* do a printer update now that all messaging has been set up, + * before we allow clients to start connecting */ + if (!lp__disable_spoolss() && + (rpc_spoolss_daemon() != RPC_DAEMON_DISABLED)) { + printing_subsystem_update(ev_ctx, msg_ctx, false); + } ++#endif + + TALLOC_FREE(frame); + /* make sure we always have a valid stackframe */ +--- a/source3/printing/pcap.c ++++ b/source3/printing/pcap.c +@@ -132,6 +132,7 @@ void pcap_cache_reload(struct tevent_con + void (*post_cache_fill_fn)(struct tevent_context *, + struct messaging_context *)) + { ++#ifdef PRINTER_SUPPORT + const char *pcap_name = lp_printcapname(); + bool pcap_reloaded = False; + bool post_cache_fill_fn_handled = false; +@@ -204,6 +205,7 @@ done: + pcap_cache_destroy_specific(&pcache); + + return; ++#endif + } + + diff --git a/package/lean/samba4x/patches/220-remove_services.patch b/package/lean/samba4x/patches/220-remove_services.patch new file mode 100644 index 000000000..34b6f36b5 --- /dev/null +++ b/package/lean/samba4x/patches/220-remove_services.patch @@ -0,0 +1,46 @@ +--- a/source3/rpc_server/rpc_service_setup.c ++++ b/source3/rpc_server/rpc_service_setup.c +@@ -560,6 +560,7 @@ bool dcesrv_ep_setup(struct tevent_conte + } + #endif + ++#ifdef EXTRA_SERVICES + ok = rpc_setup_svcctl(ev_ctx, msg_ctx); + if (!ok) { + goto done; +@@ -574,6 +575,7 @@ bool dcesrv_ep_setup(struct tevent_conte + if (!ok) { + goto done; + } ++#endif + + ok = rpc_setup_initshutdown(ev_ctx, msg_ctx); + if (!ok) { +--- a/source3/smbd/server_exit.c ++++ b/source3/smbd/server_exit.c +@@ -195,9 +195,11 @@ static void exit_server_common(enum serv + #endif + rpc_netdfs_shutdown(); + rpc_initshutdown_shutdown(); ++#ifdef EXTRA_SERVICES + rpc_eventlog_shutdown(); + rpc_ntsvcs_shutdown(); + rpc_svcctl_shutdown(); ++#endif + #ifdef PRINTER_SUPPORT + rpc_spoolss_shutdown(); + #endif +--- a/source3/rpcclient/rpcclient.c ++++ b/source3/rpcclient/rpcclient.c +@@ -631,9 +631,11 @@ static struct cmd_set *rpcclient_command + shutdown_commands, + test_commands, + wkssvc_commands, ++#ifdef EXTRA_SERVICES + ntsvcs_commands, + drsuapi_commands, + eventlog_commands, ++#endif + winreg_commands, + fss_commands, + witness_commands, diff --git a/package/lean/samba4x/patches/230-remove_winreg_support.patch b/package/lean/samba4x/patches/230-remove_winreg_support.patch new file mode 100644 index 000000000..7124d461e --- /dev/null +++ b/package/lean/samba4x/patches/230-remove_winreg_support.patch @@ -0,0 +1,101 @@ +--- a/source3/rpc_server/rpc_service_setup.c ++++ b/source3/rpc_server/rpc_service_setup.c +@@ -396,10 +396,12 @@ static bool eventlog_init_cb(void *ptr) + talloc_get_type_abort(ptr, struct messaging_context); + bool ok; + ++#ifdef WINREG_SUPPORT + ok = eventlog_init_winreg(msg_ctx); + if (!ok) { + return false; + } ++#endif + + return true; + } +@@ -506,10 +508,12 @@ bool dcesrv_ep_setup(struct tevent_conte + return false; + } + ++#ifdef WINREG_SUPPORT + ok = rpc_setup_winreg(ev_ctx, msg_ctx); + if (!ok) { + goto done; + } ++#endif + + ok = rpc_setup_srvsvc(ev_ctx, msg_ctx); + if (!ok) { +--- a/source3/smbd/server_exit.c ++++ b/source3/smbd/server_exit.c +@@ -205,7 +205,9 @@ static void exit_server_common(enum serv + #endif + + rpc_srvsvc_shutdown(); ++#ifdef WINREG_SUPPORT + rpc_winreg_shutdown(); ++#endif + + rpc_netlogon_shutdown(); + rpc_samr_shutdown(); +--- a/source3/rpc_server/svcctl/srv_svcctl_nt.c ++++ b/source3/rpc_server/svcctl/srv_svcctl_nt.c +@@ -96,9 +96,11 @@ bool init_service_op_table( void ) + svcctl_ops[i].ops = &netlogon_svc_ops; + i++; + ++#ifdef WINREG_SUPPORT + svcctl_ops[i].name = talloc_strdup( svcctl_ops, "RemoteRegistry" ); + svcctl_ops[i].ops = &winreg_svc_ops; + i++; ++#endif + + svcctl_ops[i].name = talloc_strdup( svcctl_ops, "WINS" ); + svcctl_ops[i].ops = &wins_svc_ops; +--- a/source3/services/svc_winreg_glue.c ++++ b/source3/services/svc_winreg_glue.c +@@ -88,6 +88,10 @@ struct security_descriptor *svcctl_get_s + NTSTATUS status; + WERROR result = WERR_OK; + ++#ifndef WINREG_SUPPORT ++ return NULL; ++#endif ++ + key = talloc_asprintf(mem_ctx, + "%s\\%s\\Security", + TOP_LEVEL_SERVICES_KEY, name); +@@ -161,6 +165,10 @@ bool svcctl_set_secdesc(struct messaging + NTSTATUS status; + WERROR result = WERR_OK; + ++#ifndef WINREG_SUPPORT ++ return false; ++#endif ++ + tmp_ctx = talloc_stackframe(); + if (tmp_ctx == NULL) { + return false; +@@ -272,6 +280,10 @@ const char *svcctl_get_string_value(TALL + NTSTATUS status; + WERROR result = WERR_OK; + ++#ifndef WINREG_SUPPORT ++ return NULL; ++#endif ++ + tmp_ctx = talloc_stackframe(); + if (tmp_ctx == NULL) { + return NULL; +--- a/source3/rpcclient/rpcclient.c ++++ b/source3/rpcclient/rpcclient.c +@@ -636,7 +636,9 @@ static struct cmd_set *rpcclient_command + drsuapi_commands, + eventlog_commands, + #endif ++#ifdef WINREG_SUPPORT + winreg_commands, ++#endif + fss_commands, + witness_commands, + clusapi_commands, diff --git a/package/lean/samba4x/patches/270-remove_registry_backend.patch b/package/lean/samba4x/patches/270-remove_registry_backend.patch new file mode 100644 index 000000000..1a91b250a --- /dev/null +++ b/package/lean/samba4x/patches/270-remove_registry_backend.patch @@ -0,0 +1,43 @@ +--- a/source3/lib/smbconf/smbconf_init.c ++++ b/source3/lib/smbconf/smbconf_init.c +@@ -68,9 +68,12 @@ sbcErr smbconf_init(TALLOC_CTX *mem_ctx, + } + } + ++#ifdef REGISTRY_BACKEND + if (strequal(backend, "registry") || strequal(backend, "reg")) { + err = smbconf_init_reg(mem_ctx, conf_ctx, path); +- } else if (strequal(backend, "file") || strequal(backend, "txt")) { ++ } else ++#endif ++ if (strequal(backend, "file") || strequal(backend, "txt")) { + err = smbconf_init_txt(mem_ctx, conf_ctx, path); + } else if (sep == NULL) { + /* +--- a/source3/lib/netapi/serverinfo.c ++++ b/source3/lib/netapi/serverinfo.c +@@ -557,7 +557,10 @@ static WERROR NetServerSetInfo_l_1005(st + return WERR_INVALID_PARAM; + } + +- if (!lp_config_backend_is_registry()) { ++#ifdef REGISTRY_BACKEND ++ if (!lp_config_backend_is_registry()) ++#endif ++ { + libnetapi_set_error_string(ctx, + "Configuration manipulation requested but not " + "supported by backend"); +--- a/source3/smbd/server.c ++++ b/source3/smbd/server.c +@@ -1599,8 +1599,10 @@ extern void build_options(bool screen); + exit_daemon("Samba cannot init server id", EACCES); + } + ++#ifdef REGISTRY_BACKEND + if (!W_ERROR_IS_OK(registry_init_full())) + exit_daemon("Samba cannot init registry", EACCES); ++#endif + + /* Open the share_info.tdb here, so we don't have to open + after the fork on every single connection. This is a small diff --git a/package/lean/samba4x/patches/280-strip_srvsvc.patch b/package/lean/samba4x/patches/280-strip_srvsvc.patch new file mode 100644 index 000000000..f88c27415 --- /dev/null +++ b/package/lean/samba4x/patches/280-strip_srvsvc.patch @@ -0,0 +1,146 @@ +--- a/source3/smbd/lanman.c ++++ b/source3/smbd/lanman.c +@@ -2206,6 +2206,10 @@ static bool api_RNetShareAdd(struct smbd + struct srvsvc_NetShareInfo2 info2; + struct dcerpc_binding_handle *b; + ++#ifndef SRVSVC_SUPPORT ++ return False; ++#endif ++ + if (!str1 || !str2 || !p) { + return False; + } +@@ -3582,10 +3586,7 @@ static bool api_RNetServerGetInfo(struct + NTSTATUS status; + WERROR werr; + TALLOC_CTX *mem_ctx = talloc_tos(); +- struct rpc_pipe_client *cli = NULL; +- union srvsvc_NetSrvInfo info; + int errcode; +- struct dcerpc_binding_handle *b; + + if (!str1 || !str2 || !p) { + return False; +@@ -3648,42 +3649,9 @@ static bool api_RNetServerGetInfo(struct + p = *rdata; + p2 = p + struct_len; + +- status = rpc_pipe_open_interface(mem_ctx, &ndr_table_srvsvc, +- conn->session_info, +- conn->sconn->remote_address, +- conn->sconn->msg_ctx, +- &cli); +- if (!NT_STATUS_IS_OK(status)) { +- DEBUG(0,("api_RNetServerGetInfo: could not connect to srvsvc: %s\n", +- nt_errstr(status))); +- errcode = W_ERROR_V(ntstatus_to_werror(status)); +- goto out; +- } +- +- b = cli->binding_handle; +- +- status = dcerpc_srvsvc_NetSrvGetInfo(b, mem_ctx, +- NULL, +- 101, +- &info, +- &werr); +- if (!NT_STATUS_IS_OK(status)) { +- errcode = W_ERROR_V(ntstatus_to_werror(status)); +- goto out; +- } +- if (!W_ERROR_IS_OK(werr)) { +- errcode = W_ERROR_V(werr); +- goto out; +- } +- +- if (info.info101 == NULL) { +- errcode = W_ERROR_V(WERR_INVALID_PARAM); +- goto out; +- } +- + if (uLevel != 20) { + size_t len = 0; +- status = srvstr_push(NULL, 0, p, info.info101->server_name, 16, ++ status = srvstr_push(NULL, 0, p, lp_netbios_name(), 16, + STR_ASCII|STR_UPPER|STR_TERMINATE, &len); + if (!NT_STATUS_IS_OK(status)) { + errcode = W_ERROR_V(ntstatus_to_werror(status)); +@@ -3692,27 +3660,10 @@ static bool api_RNetServerGetInfo(struct + } + p += 16; + if (uLevel > 0) { +- SCVAL(p,0,info.info101->version_major); +- SCVAL(p,1,info.info101->version_minor); +- SIVAL(p,2,info.info101->server_type); +- +- if (mdrcnt == struct_len) { +- SIVAL(p,6,0); +- } else { +- SIVAL(p,6,PTR_DIFF(p2,*rdata)); +- if (mdrcnt - struct_len <= 0) { +- return false; +- } +- push_ascii(p2, +- info.info101->comment, +- MIN(mdrcnt - struct_len, +- MAX_SERVER_STRING_LENGTH), +- STR_TERMINATE); +- p2 = skip_string(*rdata,*rdata_len,p2); +- if (!p2) { +- return False; +- } +- } ++ SCVAL(p,0,SAMBA_MAJOR_NBT_ANNOUNCE_VERSION); ++ SCVAL(p,1,SAMBA_MINOR_NBT_ANNOUNCE_VERSION); ++ SIVAL(p,2,lp_default_server_announce()); ++ SIVAL(p,6,0); + } + + if (uLevel > 1) { +@@ -5405,6 +5356,10 @@ static bool api_RNetSessionEnum(struct s + uint32_t totalentries, resume_handle = 0; + uint32_t count = 0; + ++#ifndef SRVSVC_SUPPORT ++ return False; ++#endif ++ + if (!str1 || !str2 || !p) { + return False; + } +--- a/source3/rpc_server/srvsvc/srv_srvsvc_nt.c ++++ b/source3/rpc_server/srvsvc/srv_srvsvc_nt.c +@@ -1724,6 +1724,10 @@ WERROR _srvsvc_NetShareSetInfo(struct pi + TALLOC_CTX *ctx = p->mem_ctx; + union srvsvc_NetShareInfo *info = r->in.info; + ++#ifndef FULL_SRVSVC ++ return WERR_ACCESS_DENIED; ++#endif ++ + DEBUG(5,("_srvsvc_NetShareSetInfo: %d\n", __LINE__)); + + if (!r->in.share_name) { +@@ -1968,6 +1972,10 @@ WERROR _srvsvc_NetShareAdd(struct pipes_ + SMB_STRUCT_STAT st; + TALLOC_CTX *ctx = p->mem_ctx; + ++#ifndef FULL_SRVSVC ++ return WERR_ACCESS_DENIED; ++#endif ++ + DEBUG(5,("_srvsvc_NetShareAdd: %d\n", __LINE__)); + + if (r->out.parm_error) { +@@ -2159,6 +2167,10 @@ WERROR _srvsvc_NetShareDel(struct pipes_ + bool is_disk_op; + TALLOC_CTX *ctx = p->mem_ctx; + ++#ifndef FULL_SRVSVC ++ return WERR_ACCESS_DENIED; ++#endif ++ + DEBUG(5,("_srvsvc_NetShareDel: %d\n", __LINE__)); + + if (!r->in.share_name) { diff --git a/package/lean/samba4x/patches/300-assert_debug_level.patch b/package/lean/samba4x/patches/300-assert_debug_level.patch new file mode 100644 index 000000000..66fe8ee82 --- /dev/null +++ b/package/lean/samba4x/patches/300-assert_debug_level.patch @@ -0,0 +1,11 @@ +--- a/lib/util/fault.h ++++ b/lib/util/fault.h +@@ -34,7 +34,7 @@ + #define SMB_ASSERT(b) \ + do { \ + if (!(b)) { \ +- DEBUG(0,("PANIC: assert failed at %s(%d): %s\n", \ ++ DEBUG(3,("PANIC: assert failed at %s(%d): %s\n", \ + __FILE__, __LINE__, #b)); \ + smb_panic("assert failed: " #b); \ + } \ diff --git a/package/lean/samba4x/patches/320-debug_level_checks.patch b/package/lean/samba4x/patches/320-debug_level_checks.patch new file mode 100644 index 000000000..7758de7c1 --- /dev/null +++ b/package/lean/samba4x/patches/320-debug_level_checks.patch @@ -0,0 +1,22 @@ +--- a/lib/util/debug.h ++++ b/lib/util/debug.h +@@ -51,7 +51,7 @@ bool dbghdr( int level, const char *loca + * Redefine DEBUGLEVEL because so we don't have to change every source file + * that *unnecessarily* references it. + */ +-#define DEBUGLEVEL DEBUGLEVEL_CLASS[DBGC_ALL] ++#define DEBUGLEVEL 0 + + /* + * Define all new debug classes here. A class is represented by an entry in +--- a/source3/nmbd/asyncdns.c ++++ b/source3/nmbd/asyncdns.c +@@ -86,7 +86,7 @@ static void asyncdns_process(void) + struct query_record r; + unstring qname; + +- DEBUGLEVEL = -1; ++ DEBUGLEVEL_CLASS[DBGC_ALL] = -1; + + while (1) { + NTSTATUS status; diff --git a/package/lean/samba4x/patches/390-remove-auth-winbind.patch b/package/lean/samba4x/patches/390-remove-auth-winbind.patch new file mode 100644 index 000000000..49bc3f3d0 --- /dev/null +++ b/package/lean/samba4x/patches/390-remove-auth-winbind.patch @@ -0,0 +1,20 @@ +--- a/source3/auth/auth.c ++++ b/source3/auth/auth.c +@@ -476,7 +476,7 @@ NTSTATUS make_auth_context_subsystem(TAL + case ROLE_DOMAIN_MEMBER: + DEBUG(5,("Making default auth method list for server role = 'domain member'\n")); + auth_method_list = str_list_make_v3( +- talloc_tos(), "guest sam winbind:ntdomain", ++ talloc_tos(), "guest sam", + NULL); + break; + case ROLE_DOMAIN_BDC: +@@ -484,7 +484,7 @@ NTSTATUS make_auth_context_subsystem(TAL + DEBUG(5,("Making default auth method list for DC\n")); + auth_method_list = str_list_make_v3( + talloc_tos(), +- "guest sam winbind:trustdomain", ++ "guest sam", + NULL); + break; + case ROLE_STANDALONE: diff --git a/package/lean/samba4x/patches/800-ldap-sasl.patch b/package/lean/samba4x/patches/800-ldap-sasl.patch new file mode 100644 index 000000000..bd950349f --- /dev/null +++ b/package/lean/samba4x/patches/800-ldap-sasl.patch @@ -0,0 +1,76 @@ +--- a/source3/lib/smbldap.c ++++ b/source3/lib/smbldap.c +@@ -876,7 +876,15 @@ static int rebindproc_connect_with_state + Could we get a referral to a machine that we don't want to give our + username and password to? */ + +- rc = ldap_simple_bind_s(ldap_struct, ldap_state->bind_dn, ldap_state->bind_secret); ++ if (ldap_state->bind_secret) ++ rc = ldap_simple_bind_s(ldap_struct, ldap_state->bind_dn, ldap_state->bind_secret); ++ else { ++ struct berval *servercredp=NULL; ++ ++ rc = ldap_sasl_bind_s(ldap_struct, NULL, "EXTERNAL", NULL, NULL, NULL, &servercredp); ++ if (rc == LDAP_SASL_BIND_IN_PROGRESS) ++ rc = ldap_sasl_bind_s(ldap_struct, NULL, "EXTERNAL", servercredp, NULL, NULL, &servercredp); ++ } + + /* only set the last rebind timestamp when we did rebind after a + * non-read LDAP operation. That way we avoid the replication sleep +@@ -983,7 +991,15 @@ static int smbldap_connect_system(struct + rc = ldap_state->bind_callback(ldap_struct, ldap_state, ldap_state->bind_callback_data); + unbecome_root(); + } else { +- rc = ldap_simple_bind_s(ldap_struct, ldap_state->bind_dn, ldap_state->bind_secret); ++ if (ldap_state->bind_secret) ++ rc = ldap_simple_bind_s(ldap_struct, ldap_state->bind_dn, ldap_state->bind_secret); ++ else { ++ struct berval *servercredp=NULL; ++ ++ rc = ldap_sasl_bind_s(ldap_struct, NULL, "EXTERNAL", NULL, NULL, NULL, &servercredp); ++ if (rc == LDAP_SASL_BIND_IN_PROGRESS) ++ rc = ldap_sasl_bind_s(ldap_struct, NULL, "EXTERNAL", servercredp, NULL, NULL, &servercredp); ++ } + } + + if (rc != LDAP_SUCCESS) { +--- a/source3/passdb/pdb_ldap.c ++++ b/source3/passdb/pdb_ldap.c +@@ -6430,16 +6430,21 @@ static NTSTATUS pdb_init_ldapsam_common( + } + + if (!fetch_ldap_pw(&bind_dn, &bind_secret)) { +- DEBUG(0, ("pdb_init_ldapsam_common: Failed to retrieve LDAP password from secrets.tdb\n")); +- return NT_STATUS_NO_MEMORY; ++ DEBUG(1, ("pdb_init_ldapsam_common: Failed to retrieve password from secrets.tdb. Switching to SASL\n")); + } + + nt_status = smbldap_init(*pdb_method, pdb_get_tevent_context(), + location, false, bind_dn, bind_secret, + &ldap_state->smbldap_state); +- memset(bind_secret, '\0', strlen(bind_secret)); +- SAFE_FREE(bind_secret); +- SAFE_FREE(bind_dn); ++ ++ if (bind_secret) { ++ memset(bind_secret, '\0', strlen(bind_secret)); ++ SAFE_FREE(bind_secret); ++ } ++ ++ if (bind_dn) ++ SAFE_FREE(bind_dn); ++ + if ( !NT_STATUS_IS_OK(nt_status) ) { + return nt_status; + } +--- a/source3/passdb/secrets.c ++++ b/source3/passdb/secrets.c +@@ -333,7 +333,7 @@ bool fetch_ldap_pw(char **dn, char** pw) + + data=(char *)secrets_fetch(old_style_key, &size); + if ((data == NULL) || (size < sizeof(old_style_pw))) { +- DEBUG(0,("fetch_ldap_pw: neither ldap secret retrieved!\n")); ++ DEBUG(1,("fetch_ldap_pw: neither ldap secret retrieved!\n")); + SAFE_FREE(old_style_key); + SAFE_FREE(*dn); + SAFE_FREE(data); diff --git a/package/lean/samba4x/patches/810-ldap-determine-suffix-automatically.patch b/package/lean/samba4x/patches/810-ldap-determine-suffix-automatically.patch new file mode 100644 index 000000000..c56903253 --- /dev/null +++ b/package/lean/samba4x/patches/810-ldap-determine-suffix-automatically.patch @@ -0,0 +1,77 @@ +--- a/source3/param/loadparm.c ++++ b/source3/param/loadparm.c +@@ -4487,3 +4487,17 @@ unsigned int * get_flags(void) + + return flags_list; + } ++ ++bool lp_ldap_suffix_initial() ++{ ++ if (Globals.ldap_suffix == NULL) ++ return true; ++ if (strlen(Globals.ldap_suffix) == 0) ++ return true; ++ return false; ++} ++ ++void lp_set_ldap_suffix(const char *suffix) ++{ ++ lpcfg_string_set(Globals.ctx, &Globals.ldap_suffix, suffix); ++} +--- a/source3/include/proto.h ++++ b/source3/include/proto.h +@@ -1028,6 +1028,8 @@ char* lp_perfcount_module(TALLOC_CTX *ct + void widelinks_warning(int snum); + const char *lp_ncalrpc_dir(void); + void _lp_set_server_role(int server_role); ++bool lp_ldap_suffix_initial(); ++void lp_set_ldap_suffix(const char *suffix); + + /* The following definitions come from param/loadparm_ctx.c */ + +--- a/source3/passdb/pdb_ldap_util.c ++++ b/source3/passdb/pdb_ldap_util.c +@@ -247,6 +247,34 @@ static NTSTATUS add_new_domain_info(stru + } + + /********************************************************************** ++ Autodetermine LDAP suffix ++ **********************************************************************/ ++void find_ldap_suffix(struct smbldap_state *ldap_state) ++{ ++ const char *namingCtx[] = { "namingContexts", NULL }; ++ LDAPMessage *entry = NULL, *result = NULL; ++ int rc; ++ ++ if (!lp_ldap_suffix_initial()) ++ return; ++ ++ rc = smbldap_search(ldap_state, "", LDAP_SCOPE_BASE, "(objectClass=*)", namingCtx, 0, &result); ++ if (rc != LDAP_SUCCESS) ++ return; ++ ++ entry = ldap_first_entry(ldap_state->ldap_struct, result); ++ if (entry) { ++ char **values = NULL; ++ values = ldap_get_values(ldap_state->ldap_struct, entry, namingCtx[0]); ++ if (values) { ++ lp_set_ldap_suffix(values[0]); ++ ldap_value_free(values); ++ } ++ } ++ ldap_msgfree(result); ++} ++ ++/********************************************************************** + Search for the domain info entry + *********************************************************************/ + +@@ -261,6 +289,8 @@ NTSTATUS smbldap_search_domain_info(stru + int count; + char *escape_domain_name; + ++ find_ldap_suffix(ldap_state); ++ + escape_domain_name = escape_ldap_string(talloc_tos(), domain_name); + if (!escape_domain_name) { + DEBUG(0, ("Out of memory!\n")); diff --git a/package/lean/samba4x/patches/900-musl-remove-getgrent_r-getpwent_r.patch b/package/lean/samba4x/patches/900-musl-remove-getgrent_r-getpwent_r.patch new file mode 100644 index 000000000..df0effaf1 --- /dev/null +++ b/package/lean/samba4x/patches/900-musl-remove-getgrent_r-getpwent_r.patch @@ -0,0 +1,60 @@ +--- a/source4/torture/local/nss_tests.c ++++ b/source4/torture/local/nss_tests.c +@@ -346,28 +346,6 @@ static bool test_enum_r_passwd(struct to + torture_comment(tctx, "Testing setpwent\n"); + setpwent(); + +- while (1) { +- torture_comment(tctx, "Testing getpwent_r\n"); +- +-#ifdef SOLARIS_GETPWENT_R +- ret = getpwent_r(&pwd, buffer, sizeof(buffer)); +-#else /* SOLARIS_GETPWENT_R */ +- ret = getpwent_r(&pwd, buffer, sizeof(buffer), &pwdp); +-#endif /* SOLARIS_GETPWENT_R */ +- if (ret != 0) { +- if (ret != ENOENT) { +- torture_comment(tctx, "got %d return code\n", ret); +- } +- break; +- } +- print_passwd(&pwd); +- if (pwd_array_p && num_pwd_p) { +- pwd_array = talloc_realloc(tctx, pwd_array, struct passwd, num_pwd+1); +- torture_assert(tctx, pwd_array, "out of memory"); +- copy_passwd(tctx, &pwd, &pwd_array[num_pwd]); +- num_pwd++; +- } +- } + + torture_comment(tctx, "Testing endpwent\n"); + endpwent(); +@@ -544,28 +522,6 @@ static bool test_enum_r_group(struct tor + torture_comment(tctx, "Testing setgrent\n"); + setgrent(); + +- while (1) { +- torture_comment(tctx, "Testing getgrent_r\n"); +- +-#ifdef SOLARIS_GETGRENT_R +- ret = getgrent_r(&grp, buffer, sizeof(buffer)); +-#else /* SOLARIS_GETGRENT_R */ +- ret = getgrent_r(&grp, buffer, sizeof(buffer), &grpp); +-#endif /* SOLARIS_GETGRENT_R */ +- if (ret != 0) { +- if (ret != ENOENT) { +- torture_comment(tctx, "got %d return code\n", ret); +- } +- break; +- } +- print_group(&grp); +- if (grp_array_p && num_grp_p) { +- grp_array = talloc_realloc(tctx, grp_array, struct group, num_grp+1); +- torture_assert(tctx, grp_array, "out of memory"); +- copy_group(tctx, &grp, &grp_array[num_grp]); +- num_grp++; +- } +- } + + torture_comment(tctx, "Testing endgrent\n"); + endgrent(); diff --git a/package/lean/samba4x/patches/911-musl-NETDB-fix.patch b/package/lean/samba4x/patches/911-musl-NETDB-fix.patch new file mode 100644 index 000000000..3ccc28cce --- /dev/null +++ b/package/lean/samba4x/patches/911-musl-NETDB-fix.patch @@ -0,0 +1,15 @@ +--- a/nsswitch/wins.c ++++ b/nsswitch/wins.c +@@ -39,5 +39,12 @@ static pthread_mutex_t wins_nss_mutex = + #define INADDRSZ 4 + #endif + ++#if !defined(NETDB_INTERNAL) ++# define NETDB_INTERNAL -1 /* See errno. */ ++#endif ++#if !defined(NETDB_SUCCESS) ++# define NETDB_SUCCESS 0 /* No problem. */ ++#endif ++ + NSS_STATUS _nss_wins_gethostbyname_r(const char *hostname, struct hostent *he, + char *buffer, size_t buflen, int *h_errnop); diff --git a/package/lean/samba4x/patches/912-msgsock-nvram-fix.patch b/package/lean/samba4x/patches/912-msgsock-nvram-fix.patch new file mode 100644 index 000000000..8e9d6fb95 --- /dev/null +++ b/package/lean/samba4x/patches/912-msgsock-nvram-fix.patch @@ -0,0 +1,46 @@ +--- a/source3/lib/messages.c ++++ b/source3/lib/messages.c +@@ -221,7 +221,7 @@ struct messaging_context *messaging_init + return NULL; + } + +- priv_path = private_path("msg.sock"); ++ priv_path = lock_path("msg.sock"); + if (priv_path == NULL) { + TALLOC_FREE(ctx); + return NULL; +@@ -393,6 +393,7 @@ struct server_id messaging_server_id(const struct messaging_context *msg_ctx) + NTSTATUS messaging_reinit(struct messaging_context *msg_ctx) + { + int ret; ++ char *lck_path; + + TALLOC_FREE(msg_ctx->msg_dgm_ref); + +@@ -400,9 +401,14 @@ NTSTATUS messaging_reinit(struct messaging_context *msg_ctx) + .pid = getpid(), .vnn = msg_ctx->id.vnn + }; + ++ lck_path = lock_path("msg.lock"); ++ if (lck_path == NULL) { ++ return NT_STATUS_NO_MEMORY; ++ } ++ + msg_ctx->msg_dgm_ref = messaging_dgm_ref( + msg_ctx, msg_ctx->event_ctx, &msg_ctx->id.unique_id, +- private_path("msg.sock"), lock_path("msg.lock"), ++ lock_path("msg.sock"), lck_path, + messaging_recv_cb, msg_ctx, &ret); + + if (msg_ctx->msg_dgm_ref == NULL) { +--- a/source4/lib/messaging/messaging.c ++++ b/source4/lib/messaging/messaging.c +@@ -323,7 +323,7 @@ struct imessaging_context *imessaging_in + goto fail; + } + +- msg->sock_dir = lpcfg_private_path(msg, lp_ctx, "msg.sock"); ++ msg->sock_dir = lpcfg_lock_path(msg, lp_ctx, "msg.sock"); + if (msg->sock_dir == NULL) { + goto fail; + }