The branch, v4-14-test has been updated via b5cbbf0542c s3: smbd: Fix openat_pathref_fsp() to cope with FIFO's in the filesystem. via 1bb8ed2b619 s3: smbd: Add fifo test for the DISABLE_OPATH case. via 97dc8c0dccc s3: smbd: In create_conn_struct_cwd(), don't TALLOC_FREE() an unallocated pointer on error. via b00fed3b698 s3: mdssvc: Correctly disconnect the VFS connection inside the mds_ctx destructor. via 446f89510f2 winbind: ensure wb_parent_idmap_setup_send() gets called in winbindd_allocate_uid_send() via 7d1dd87a653 winbindd: call wb_parent_idmap_setup_send() in wb_queryuser_send() via 274236ff3db vfs_gpfs: add sys_proc_fd_path() fallback to vfs_gpfs_fset_dos_attributes() via 08f18b66716 vfs_gpfs: remove ENOSYS fallback from vfs_gpfs_fset_dos_attributes() via 4312b6c17da vfs_gpfs: add path based fallback for gpfswrap_fstat_x() on pathref handles via d98e8e0e3f8 vfs_gpfs: check for O_PATH support in gpfswrap_fstat_x() via 4a17f42d00b vfs_gpfs: make vfs_gpfs_connect() a no-op on IPC shares via 994c64d3098 vfs_gpfs: don't check for struct gpfs_config_data in vfs_gpfs_[l]stat() via a4a57724b92 vfs_gpfs: call SMB_VFS_NEXT_CONNECT() before running some module initialization code via 34c20fe3a16 registry: check for running as root in clustering mode via 0e85755f383 s3/lib/dbwrap: check if global_messaging_context() succeeded from a7d66e00fa8 s3: smbd: Fix smbd crash on dangling symlink with posix connection calling several non-posix info levels.
https://git.samba.org/?p=samba.git;a=shortlog;h=v4-14-test - Log ----------------------------------------------------------------- commit b5cbbf0542c5f176b8dd07c326430d37e06b3412 Author: Jeremy Allison <j...@samba.org> Date: Thu Sep 2 14:40:53 2021 -0700 s3: smbd: Fix openat_pathref_fsp() to cope with FIFO's in the filesystem. Remove skip test for the DISABLE_OPATH case. BUG: https://bugzilla.samba.org/show_bug.cgi?id=14816 RN: Fix pathref open of a filesystem fifo in the DISABLE_OPATH build Signed-off-by: Jeremy Allison <j...@samba.org> Reviewed-by: Ralph Boehme <s...@samba.org> Autobuild-User(master): Ralph Böhme <s...@samba.org> Autobuild-Date(master): Mon Sep 6 09:51:54 UTC 2021 on sn-devel-184 (cherry picked from commit 2f2c53c4f8f59a497bc33a24e5e0fc15ea076876) Autobuild-User(v4-14-test): Jule Anger <jan...@samba.org> Autobuild-Date(v4-14-test): Tue Sep 7 10:48:16 UTC 2021 on sn-devel-184 commit 1bb8ed2b6192bfe6343037fafd0d1bf940db9302 Author: Jeremy Allison <j...@samba.org> Date: Thu Sep 2 15:32:27 2021 -0700 s3: smbd: Add fifo test for the DISABLE_OPATH case. Currently we hang when trying to list a directory containing a fifo when configured with DISABLE_OPATH. BUG: https://bugzilla.samba.org/show_bug.cgi?id=14816 Signed-off-by: Jeremy Allison <j...@samba.org> Reviewed-by: Ralph Boehme <s...@samba.org> (cherry picked from commit a54d9ffc87ebe602a0e7c48e35643ed2ff1a00bc) commit 97dc8c0dcccbcecd3a8f8f3872b47d3a3c6e8036 Author: Jeremy Allison <j...@samba.org> Date: Mon Aug 23 17:42:40 2021 -0700 s3: smbd: In create_conn_struct_cwd(), don't TALLOC_FREE() an unallocated pointer on error. Just return the status - if create_conn_struct_as_root() fails the connection struct never gets returned. BUG: https://bugzilla.samba.org/show_bug.cgi?id=14809 Signed-off-by: Jeremy Allison <j...@samba.org> Reviewed-by: Ralph Boehme <s...@samba.org> Autobuild-User(master): Ralph Böhme <s...@samba.org> Autobuild-Date(master): Wed Aug 25 17:09:23 UTC 2021 on sn-devel-184 (cherry picked from commit 857045f3a236dea125200dd09279d677e513682b) commit b00fed3b698cc78a377d71e0574c878e262c4808 Author: Jeremy Allison <j...@samba.org> Date: Mon Aug 23 17:40:42 2021 -0700 s3: mdssvc: Correctly disconnect the VFS connection inside the mds_ctx destructor. BUG: https://bugzilla.samba.org/show_bug.cgi?id=14809 Signed-off-by: Jeremy Allison <j...@samba.org> Reviewed-by: Ralph Boehme <s...@samba.org> (cherry picked from commit b4d8c62c4e8191e05fd03dd096a0bc989e224ed3) commit 446f89510f2e55a551e2975a6cbf01c6a023ba0c Author: Ralph Boehme <s...@samba.org> Date: Fri Aug 20 15:04:49 2021 +0200 winbind: ensure wb_parent_idmap_setup_send() gets called in winbindd_allocate_uid_send() BUG: https://bugzilla.samba.org/show_bug.cgi?id=14804 RN: winbindd can crash because idmap child state is not fully initialized Signed-off-by: Ralph Boehme <s...@samba.org> Reviewed-by: Volker Lendecke <v...@samba.org> Autobuild-User(master): Volker Lendecke <v...@samba.org> Autobuild-Date(master): Thu Sep 2 15:20:06 UTC 2021 on sn-devel-184 (cherry picked from commit d0f6d54354b02f5591706814fbd1e4844788fdfa) commit 7d1dd87a6538f8c7f1e4938b0ff52cbd231fff90 Author: Ralph Boehme <s...@samba.org> Date: Tue Aug 31 17:04:56 2021 +0200 winbindd: call wb_parent_idmap_setup_send() in wb_queryuser_send() BUG: https://bugzilla.samba.org/show_bug.cgi?id=14804 Signed-off-by: Ralph Boehme <s...@samba.org> Reviewed-by: Volker Lendecke <v...@samba.org> (cherry picked from commit 39c2ec72cb77945c3eb611fb1d7d7e9aad52bdfd) commit 274236ff3db014f8b2003870ccd520bb5738b3a5 Author: Ralph Boehme <s...@samba.org> Date: Thu Jul 1 16:08:02 2021 +0200 vfs_gpfs: add sys_proc_fd_path() fallback to vfs_gpfs_fset_dos_attributes() gpfs_set_winattrs() is a modifying operation, my expectation thus is that it is not allowed on pathref (O_PATH) handles even though a recent Linux kernel commit 44a3b87444058b2cb055092cdebc63858707bf66 allowed calling utimensat() on pathref handles. BUG: https://bugzilla.samba.org/show_bug.cgi?id=14771 RN: Some VFS operations on pathref (O_PATH) handles fail on GPFS Signed-off-by: Ralph Boehme <s...@samba.org> Reviewed-by: Christof Schmitt <c...@samba.org> (cherry picked from commit 882a466ea5f45e5e2197f2408ccd560383e13c3f) commit 08f18b66716030bc1b7cb4eacc6af6a32563793b Author: Ralph Boehme <s...@samba.org> Date: Fri Aug 13 11:39:05 2021 +0200 vfs_gpfs: remove ENOSYS fallback from vfs_gpfs_fset_dos_attributes() This API call has existed for a long time, so we can safely assume that this always works. BUG: https://bugzilla.samba.org/show_bug.cgi?id=14771 Pair-Programmed-With: Christof Schmitt <c...@samba.org> Signed-off-by: Ralph Boehme <s...@samba.org> Signed-off-by: Christof Schmitt <c...@samba.org> (cherry picked from commit 3679f54f178ba6ddb940cc66f701e9b3a1dd543d) commit 4312b6c17dac27e0c90ceab52b0a61311ef8d618 Author: Ralph Boehme <s...@samba.org> Date: Thu Jul 29 19:28:14 2021 +0200 vfs_gpfs: add path based fallback for gpfswrap_fstat_x() on pathref handles BUG: https://bugzilla.samba.org/show_bug.cgi?id=14771 Signed-off-by: Ralph Boehme <s...@samba.org> Reviewed-by: Christof Schmitt <c...@samba.org> (cherry picked from commit fde1b98143568fc816165502583f72e73b5d6b71) commit d98e8e0e3f8e819d03a7e6a58c699f29476e3b13 Author: Ralph Boehme <s...@samba.org> Date: Thu Jul 29 15:53:04 2021 +0200 vfs_gpfs: check for O_PATH support in gpfswrap_fstat_x() BUG: https://bugzilla.samba.org/show_bug.cgi?id=14771 Signed-off-by: Ralph Boehme <s...@samba.org> Reviewed-by: Christof Schmitt <c...@samba.org> (cherry picked from commit 730f8c49a9bc8333f0b722ad65e4e587421c21ec) commit 4a17f42d00b20cf31c28c564e95937c7f457722c Author: Ralph Boehme <s...@samba.org> Date: Fri Aug 6 12:05:44 2021 +0200 vfs_gpfs: make vfs_gpfs_connect() a no-op on IPC shares We don't ever expect any filesystem IO operations to be called on an IPC shares, so there's no need to initialize the module here. BUG: https://bugzilla.samba.org/show_bug.cgi?id=14771 Signed-off-by: Ralph Boehme <s...@samba.org> Reviewed-by: Christof Schmitt <c...@samba.org> (cherry picked from commit 1a3ac7a940fbb4ad8575ee3b0c56c9de2bf4b1f6) commit 994c64d309819f3e4f4822fd6c66ab12c3b7cb8f Author: Stefan Metzmacher <me...@samba.org> Date: Wed Aug 11 16:23:24 2021 +0200 vfs_gpfs: don't check for struct gpfs_config_data in vfs_gpfs_[l]stat() This is unused and the config object won't be avilable for IPC$ anymore with the next commit. BUG: https://bugzilla.samba.org/show_bug.cgi?id=14771 Signed-off-by: Stefan Metzmacher <me...@samba.org> Reviewed-by: Ralph Boehme <s...@samba.org> Reviewed-by: Christof Schmitt <c...@samba.org> (cherry picked from commit 070dce224bbe190266682c5e362bc2b0ed798ecc) commit a4a57724b929e9429fcab7ebae96ba0d6f1d7c52 Author: Ralph Boehme <s...@samba.org> Date: Fri Aug 6 12:03:38 2021 +0200 vfs_gpfs: call SMB_VFS_NEXT_CONNECT() before running some module initialization code No change in behaviour. Prepares for a subsequent commit that checks for IPC shares. BUG: https://bugzilla.samba.org/show_bug.cgi?id=14771 Signed-off-by: Ralph Boehme <s...@samba.org> Reviewed-by: Christof Schmitt <c...@samba.org> (cherry picked from commit 145e739c440d39651d4f3d30682035ab868488ba) commit 34c20fe3a169424149179090b4dd72b8e6c8ad9a Author: Ralph Boehme <s...@samba.org> Date: Sat Aug 7 10:52:28 2021 +0000 registry: check for running as root in clustering mode BUG: https://bugzilla.samba.org/show_bug.cgi?id=14787 RN: net conf list crashes when run as normal user Signed-off-by: Ralph Boehme <s...@samba.org> Reviewed-by: Andreas Schneider <a...@samba.org> Autobuild-User(master): Ralph Böhme <s...@samba.org> Autobuild-Date(master): Tue Aug 17 11:23:15 UTC 2021 on sn-devel-184 (cherry picked from commit 4809f4a6ee971bcd9767839c729b636b7582fc02) commit 0e85755f383fc59c981358f98d0fa68a9a0e276d Author: Ralph Boehme <s...@samba.org> Date: Sat Aug 7 10:51:38 2021 +0000 s3/lib/dbwrap: check if global_messaging_context() succeeded The subsequent messaging_ctdb_connection() will fail an assert if messaging is not up and running, maybe it's a bit better to add a check if global_messaging_context() actually succeeded. BUG: https://bugzilla.samba.org/show_bug.cgi?id=14787 Signed-off-by: Ralph Boehme <s...@samba.org> Reviewed-by: Andreas Schneider <a...@samba.org> (cherry picked from commit fd19cae8d2f21977d8285efd3f29e2b480d241e9) ----------------------------------------------------------------------- Summary of changes: source3/lib/dbwrap/dbwrap_open.c | 4 + source3/modules/vfs_gpfs.c | 177 ++++++++++++++++++++++++++----- source3/registry/reg_backend_db.c | 9 ++ source3/rpc_server/mdssvc/mdssvc.c | 5 + source3/script/tests/test_fifo.sh | 83 +++++++++++++++ source3/selftest/tests.py | 3 + source3/smbd/files.c | 4 + source3/smbd/msdfs.c | 7 +- source3/winbindd/wb_queryuser.c | 30 +++++- source3/winbindd/winbindd_allocate_uid.c | 44 +++++++- 10 files changed, 326 insertions(+), 40 deletions(-) create mode 100755 source3/script/tests/test_fifo.sh Changeset truncated at 500 lines: diff --git a/source3/lib/dbwrap/dbwrap_open.c b/source3/lib/dbwrap/dbwrap_open.c index 1d8c40af75e..52c8a94aeff 100644 --- a/source3/lib/dbwrap/dbwrap_open.c +++ b/source3/lib/dbwrap/dbwrap_open.c @@ -149,6 +149,10 @@ struct db_context *db_open(TALLOC_CTX *mem_ctx, * to be initialized. */ msg_ctx = global_messaging_context(); + if (msg_ctx == NULL) { + DBG_ERR("Failed to initialize messaging\n"); + return NULL; + } conn = messaging_ctdb_connection(); if (conn == NULL) { diff --git a/source3/modules/vfs_gpfs.c b/source3/modules/vfs_gpfs.c index 172194dbead..8f4791f78d3 100644 --- a/source3/modules/vfs_gpfs.c +++ b/source3/modules/vfs_gpfs.c @@ -55,6 +55,9 @@ struct gpfs_config_data { bool acl; bool settimes; bool recalls; + struct { + bool gpfs_fstat_x; + } pathref_ok; }; struct gpfs_fsp_extension { @@ -1648,6 +1651,9 @@ static NTSTATUS vfs_gpfs_fget_dos_attributes(struct vfs_handle_struct *handle, uint32_t *dosmode) { struct gpfs_config_data *config; + int fd = fsp_get_pathref_fd(fsp); + char buf[PATH_MAX]; + const char *p = NULL; struct gpfs_iattr64 iattr = { }; unsigned int litemask; struct timespec ts; @@ -1663,7 +1669,22 @@ static NTSTATUS vfs_gpfs_fget_dos_attributes(struct vfs_handle_struct *handle, return SMB_VFS_NEXT_FGET_DOS_ATTRIBUTES(handle, fsp, dosmode); } - ret = gpfswrap_fstat_x(fsp_get_pathref_fd(fsp), &litemask, &iattr, sizeof(iattr)); + if (fsp->fsp_flags.is_pathref && !config->pathref_ok.gpfs_fstat_x) { + if (fsp->fsp_flags.have_proc_fds) { + p = sys_proc_fd_path(fd, buf, sizeof(buf)); + if (p == NULL) { + return NT_STATUS_NO_MEMORY; + } + } else { + p = fsp->fsp_name->base_name; + } + } + + if (p != NULL) { + ret = gpfswrap_stat_x(p, &litemask, &iattr, sizeof(iattr)); + } else { + ret = gpfswrap_fstat_x(fd, &litemask, &iattr, sizeof(iattr)); + } if (ret == -1 && errno == ENOSYS) { return SMB_VFS_NEXT_FGET_DOS_ATTRIBUTES(handle, fsp, dosmode); } @@ -1680,8 +1701,17 @@ static NTSTATUS vfs_gpfs_fget_dos_attributes(struct vfs_handle_struct *handle, set_effective_capability(DAC_OVERRIDE_CAPABILITY); - ret = gpfswrap_fstat_x(fsp_get_pathref_fd(fsp), &litemask, - &iattr, sizeof(iattr)); + if (p != NULL) { + ret = gpfswrap_stat_x(p, + &litemask, + &iattr, + sizeof(iattr)); + } else { + ret = gpfswrap_fstat_x(fd, + &litemask, + &iattr, + sizeof(iattr)); + } if (ret == -1) { saved_errno = errno; } @@ -1766,16 +1796,48 @@ static NTSTATUS vfs_gpfs_fset_dos_attributes(struct vfs_handle_struct *handle, } attrs.winAttrs = vfs_gpfs_dosmode_to_winattrs(dosmode); - ret = gpfswrap_set_winattrs(fsp_get_io_fd(fsp), - GPFS_WINATTR_SET_ATTRS, &attrs); - if (ret == -1 && errno == ENOSYS) { - return SMB_VFS_NEXT_FSET_DOS_ATTRIBUTES(handle, fsp, dosmode); + if (!fsp->fsp_flags.is_pathref) { + ret = gpfswrap_set_winattrs(fsp_get_io_fd(fsp), + GPFS_WINATTR_SET_ATTRS, &attrs); + if (ret == -1) { + DBG_WARNING("Setting winattrs failed for %s: %s\n", + fsp_str_dbg(fsp), strerror(errno)); + return map_nt_error_from_unix(errno); + } + return NT_STATUS_OK; + } + + if (fsp->fsp_flags.have_proc_fds) { + int fd = fsp_get_pathref_fd(fsp); + const char *p = NULL; + char buf[PATH_MAX]; + + p = sys_proc_fd_path(fd, buf, sizeof(buf)); + if (p == NULL) { + return NT_STATUS_NO_MEMORY; + } + + ret = gpfswrap_set_winattrs_path(p, + GPFS_WINATTR_SET_ATTRS, + &attrs); + if (ret == -1) { + DBG_WARNING("Setting winattrs failed for [%s][%s]: %s\n", + p, fsp_str_dbg(fsp), strerror(errno)); + return map_nt_error_from_unix(errno); + } + return NT_STATUS_OK; } + /* + * This is no longer a handle based call. + */ + ret = gpfswrap_set_winattrs_path(fsp->fsp_name->base_name, + GPFS_WINATTR_SET_ATTRS, + &attrs); if (ret == -1) { - DBG_WARNING("Setting winattrs failed for %s: %s\n", - fsp->fsp_name->base_name, strerror(errno)); + DBG_WARNING("Setting winattrs failed for [%s]: %s\n", + fsp_str_dbg(fsp), strerror(errno)); return map_nt_error_from_unix(errno); } @@ -1831,11 +1893,6 @@ static int vfs_gpfs_stat(struct vfs_handle_struct *handle, struct smb_filename *smb_fname) { int ret; - struct gpfs_config_data *config; - - SMB_VFS_HANDLE_GET_DATA(handle, config, - struct gpfs_config_data, - return -1); ret = SMB_VFS_NEXT_STAT(handle, smb_fname); if (ret == -1 && errno == EACCES) { @@ -1850,11 +1907,6 @@ static int vfs_gpfs_lstat(struct vfs_handle_struct *handle, struct smb_filename *smb_fname) { int ret; - struct gpfs_config_data *config; - - SMB_VFS_HANDLE_GET_DATA(handle, config, - struct gpfs_config_data, - return -1); ret = SMB_VFS_NEXT_LSTAT(handle, smb_fname); if (ret == -1 && errno == EACCES) { @@ -2079,6 +2131,68 @@ static ssize_t vfs_gpfs_sendfile(vfs_handle_struct *handle, int tofd, return SMB_VFS_NEXT_SENDFILE(handle, tofd, fsp, hdr, offset, n); } +#ifdef O_PATH +static int vfs_gpfs_check_pathref_fstat_x(struct gpfs_config_data *config, + struct connection_struct *conn) +{ + struct gpfs_iattr64 iattr = {0}; + unsigned int litemask; + int saved_errno; + int fd; + int ret; + + fd = open(conn->connectpath, O_PATH); + if (fd == -1) { + DBG_ERR("openat() of share with O_PATH failed: %s\n", + strerror(errno)); + return -1; + } + + ret = gpfswrap_fstat_x(fd, &litemask, &iattr, sizeof(iattr)); + if (ret == 0) { + close(fd); + config->pathref_ok.gpfs_fstat_x = true; + return 0; + } + + saved_errno = errno; + ret = close(fd); + if (ret != 0) { + DBG_ERR("close failed: %s\n", strerror(errno)); + return -1; + } + + if (saved_errno != EBADF) { + DBG_ERR("gpfswrap_fstat_x() of O_PATH handle failed: %s\n", + strerror(saved_errno)); + return -1; + } + + return 0; +} +#endif + +static int vfs_gpfs_check_pathref(struct gpfs_config_data *config, + struct connection_struct *conn) +{ +#ifndef O_PATH + /* + * This code path leaves all struct gpfs_config_data.pathref_ok members + * initialized to false. + */ + return 0; +#else + int ret; + + ret = vfs_gpfs_check_pathref_fstat_x(config, conn); + if (ret != 0) { + return -1; + } + + return 0; +#endif +} + static int vfs_gpfs_connect(struct vfs_handle_struct *handle, const char *service, const char *user) { @@ -2086,6 +2200,15 @@ static int vfs_gpfs_connect(struct vfs_handle_struct *handle, int ret; bool check_fstype; + ret = SMB_VFS_NEXT_CONNECT(handle, service, user); + if (ret < 0) { + return ret; + } + + if (IS_IPC(handle->conn)) { + return 0; + } + gpfswrap_lib_init(0); config = talloc_zero(handle->conn, struct gpfs_config_data); @@ -2095,16 +2218,10 @@ static int vfs_gpfs_connect(struct vfs_handle_struct *handle, return -1; } - ret = SMB_VFS_NEXT_CONNECT(handle, service, user); - if (ret < 0) { - TALLOC_FREE(config); - return ret; - } - check_fstype = lp_parm_bool(SNUM(handle->conn), "gpfs", "check_fstype", true); - if (check_fstype && !IS_IPC(handle->conn)) { + if (check_fstype) { const char *connectpath = handle->conn->connectpath; struct statfs buf = { 0 }; @@ -2165,6 +2282,14 @@ static int vfs_gpfs_connect(struct vfs_handle_struct *handle, config->recalls = lp_parm_bool(SNUM(handle->conn), "gpfs", "recalls", true); + ret = vfs_gpfs_check_pathref(config, handle->conn); + if (ret != 0) { + DBG_ERR("vfs_gpfs_check_pathref() on [%s] failed\n", + handle->conn->connectpath); + TALLOC_FREE(config); + return -1; + } + SMB_VFS_HANDLE_SET_DATA(handle, config, NULL, struct gpfs_config_data, return -1); diff --git a/source3/registry/reg_backend_db.c b/source3/registry/reg_backend_db.c index c870dc57ed6..423b310fe8a 100644 --- a/source3/registry/reg_backend_db.c +++ b/source3/registry/reg_backend_db.c @@ -733,6 +733,15 @@ WERROR regdb_init(void) return WERR_OK; } + /* + * Clustered Samba can only work as root because we need messaging to + * talk to ctdb which only works as root. + */ + if (lp_clustering() && geteuid() != 0) { + DBG_ERR("Cluster mode requires running as root.\n"); + return WERR_ACCESS_DENIED; + } + db_path = state_path(talloc_tos(), "registry.tdb"); if (db_path == NULL) { return WERR_NOT_ENOUGH_MEMORY; diff --git a/source3/rpc_server/mdssvc/mdssvc.c b/source3/rpc_server/mdssvc/mdssvc.c index 715de272d32..a983a882294 100644 --- a/source3/rpc_server/mdssvc/mdssvc.c +++ b/source3/rpc_server/mdssvc/mdssvc.c @@ -1568,6 +1568,11 @@ static int mds_ctx_destructor_cb(struct mds_ctx *mds_ctx) } TALLOC_FREE(mds_ctx->ino_path_map); + if (mds_ctx->conn != NULL) { + SMB_VFS_DISCONNECT(mds_ctx->conn); + conn_free(mds_ctx->conn); + } + ZERO_STRUCTP(mds_ctx); return 0; diff --git a/source3/script/tests/test_fifo.sh b/source3/script/tests/test_fifo.sh new file mode 100755 index 00000000000..11741dcc038 --- /dev/null +++ b/source3/script/tests/test_fifo.sh @@ -0,0 +1,83 @@ +#!/bin/sh +# +# Check smbclient can list a directory containing a fifo. +# + +if [ $# -lt 7 ]; then +cat <<EOF +Usage: $0 SERVER DOMAIN USERNAME PASSWORD PREFIX TARGET_ENV SMBCLIENT +EOF +exit 1; +fi + +SERVER=${1} +DOMAIN=${2} +USERNAME=${3} +PASSWORD=${4} +PREFIX=${5} +TARGET_ENV=${6} +SMBCLIENT=${7} +shift 7 +SMBCLIENT="$VALGRIND ${SMBCLIENT}" +ADDARGS="$@" + +incdir=`dirname $0`/../../../testprogs/blackbox +. $incdir/subunit.sh + +failed=0 + +# Test that listing a share with a directory containing a fifo succeeds. +# +# BUG: https://bugzilla.samba.org/show_bug.cgi?id=14816 +# +test_fifo() +{ + local fifo_dir_path="$PREFIX/$TARGET_ENV/share/fifodir" + local fifo_path="$fifo_dir_path/fifo_name" + + local tmpfile=$PREFIX/smbclient.in.$$ + + cat > $tmpfile <<EOF +cd fifodir +ls +quit +EOF + + # Create fifo directory. + mkdir -p $fifo_dir_path + # Create fifo underneath. + mkfifo $fifo_path + + local cmd='CLI_FORCE_INTERACTIVE=yes $SMBCLIENT //$SERVER/$1 -U$USERNAME%$PASSWORD $ADDARGS < $tmpfile 2>&1' + eval echo "$cmd" + out=`eval $cmd` + ret=$? + + # Remove fifo and containing dir. + rm $fifo_path + rmdir $fifo_dir_path + rm -f $tmpfile + + # Check for smbclient error. + if [ $ret != 0 ] ; then + echo "Failed accessing share containing dir with fifo $ret" + echo "$out" + return 1 + fi + + # Check for smbclient timeout (server hung). + echo "$out" | grep 'NT_STATUS_' + ret=$? + if [ $ret -eq 0 ] ; then + # Client was disconnected as server timed out. + echo "$out" + return 1 + fi + + return 0 +} + +testit "list directory containing a fifo" \ + test_fifo tmp || failed=`expr $failed + 1` + +exit $failed diff --git a/source3/selftest/tests.py b/source3/selftest/tests.py index b40d02d6c1d..660b228e0b4 100755 --- a/source3/selftest/tests.py +++ b/source3/selftest/tests.py @@ -526,6 +526,9 @@ for env in ["fileserver"]: '-u', '$USERNAME', '-p', '$PASSWORD', '-l', '$LOCAL_PATH/tarmode2', '-d', 'smbclient_tar.SMB3', '-b', smbclient3, '--subunit', '--', configuration, '-mSMB3']) + plantestsuite("samba3.blackbox.fifo", env, + [os.path.join(samba3srcdir, "script/tests/test_fifo.sh"), + '$SERVER', '$DOMAIN', 'gooduser', '$PASSWORD', '$PREFIX', env, smbclient3]) for env in ["fileserver:local"]: plantestsuite("samba3.blackbox.net_usershare", env, [os.path.join(samba3srcdir, "script/tests/test_net_usershare.sh"), '$SERVER', '$SERVER_IP', '$USERNAME', '$PASSWORD', smbclient3]) diff --git a/source3/smbd/files.c b/source3/smbd/files.c index 78629eb1d94..83624b4f8c1 100644 --- a/source3/smbd/files.c +++ b/source3/smbd/files.c @@ -503,6 +503,10 @@ NTSTATUS openat_pathref_fsp(const struct files_struct *dirfsp, } } + if (S_ISFIFO(smb_fname->st.st_ex_mode)) { + open_flags |= O_NONBLOCK; + } + status = fd_openat(dirfsp, smb_fname, fsp, open_flags, 0); if (!NT_STATUS_IS_OK(status)) { if (NT_STATUS_EQUAL(status, NT_STATUS_NOT_FOUND) || diff --git a/source3/smbd/msdfs.c b/source3/smbd/msdfs.c index 3a1dd11d9eb..3645f5d21d5 100644 --- a/source3/smbd/msdfs.c +++ b/source3/smbd/msdfs.c @@ -525,12 +525,7 @@ NTSTATUS create_conn_struct_cwd(TALLOC_CTX *mem_ctx, path, session_info); unbecome_root(); - if (!NT_STATUS_IS_OK(status)) { - TALLOC_FREE(c); - return status; - } - - return NT_STATUS_OK; + return status; } static void shuffle_strlist(char **list, int count) diff --git a/source3/winbindd/wb_queryuser.c b/source3/winbindd/wb_queryuser.c index 9db51909c02..f5bc96f03f6 100644 --- a/source3/winbindd/wb_queryuser.c +++ b/source3/winbindd/wb_queryuser.c @@ -25,10 +25,12 @@ struct wb_queryuser_state { struct tevent_context *ev; - struct wbint_userinfo *info; + struct wbint_userinfo *info; + const struct wb_parent_idmap_config *idmap_cfg; bool tried_dclookup; }; +static void wb_queryuser_idmap_setup_done(struct tevent_req *subreq); static void wb_queryuser_got_uid(struct tevent_req *subreq); static void wb_queryuser_got_domain(struct tevent_req *subreq); static void wb_queryuser_got_dc(struct tevent_req *subreq); @@ -60,13 +62,35 @@ struct tevent_req *wb_queryuser_send(TALLOC_CTX *mem_ctx, sid_copy(&info->user_sid, user_sid); + subreq = wb_parent_idmap_setup_send(state, state->ev); + if (tevent_req_nomem(subreq, req)) { + return tevent_req_post(req, ev); + } + tevent_req_set_callback(subreq, wb_queryuser_idmap_setup_done, req); + return req; +} + +static void wb_queryuser_idmap_setup_done(struct tevent_req *subreq) +{ + struct tevent_req *req = tevent_req_callback_data( + subreq, struct tevent_req); + struct wb_queryuser_state *state = tevent_req_data( + req, struct wb_queryuser_state); + NTSTATUS status; + + status = wb_parent_idmap_setup_recv(subreq, &state->idmap_cfg); + TALLOC_FREE(subreq); + if (tevent_req_nterror(req, status)) { + return; + } + subreq = wb_sids2xids_send( state, state->ev, &state->info->user_sid, 1); if (tevent_req_nomem(subreq, req)) { - return tevent_req_post(req, ev); -- Samba Shared Repository