[SCM] Samba Shared Repository - branch master updated
Uri Simchoni
uri at samba.org
Wed Aug 10 09:26:04 UTC 2016
The branch, master has been updated
via ce82bf0 selftest: add a test for new "inherit owner" option
via 1dfd8df smbd: add an option to inherit only the UNIX owner
via ebb3b34 selftest: add a test for "inherit owner" parameter
via 2a8ccc0 libgpo: Correctly use the 'server' parameter after parsing it out of the GPO path.
via 27ebf64 s3: libsmb: Protect cli_connect_nb_send() from being passed a NULL hostname and dest_ss.
via c0246b4 ctdb-ib: Fix DEBUG log messages
via f1a8fb1 ctdb-recovery-helper: Fix format-nonliteral warning
via 5176354 ctdb-daemon: Fix format-nonliteral warning
via fa0015d ctdb-daemon: Fix format-nonliteral warning
via d682ee9 ctdb-daemon: Fix format-nonliteral warning
via b201859 ctdb-common: Fix format-nonliteral warning
from 415a3a5 ctdb-tests: Log errors if the test fails
https://git.samba.org/?p=samba.git;a=shortlog;h=master
- Log -----------------------------------------------------------------
commit ce82bf09fe2170e7277af044c887180b5fcdc703
Author: Uri Simchoni <uri at samba.org>
Date: Wed Aug 10 05:00:23 2016 +0300
selftest: add a test for new "inherit owner" option
Add a test for the "unix only" option of "inherit owner"
smb.conf parameter.
Signed-off-by: Uri Simchoni <uri at samba.org>
Reviewed-by: Jeremy Allison <jra at samba.org>
Autobuild-User(master): Uri Simchoni <uri at samba.org>
Autobuild-Date(master): Wed Aug 10 11:25:52 CEST 2016 on sn-devel-144
commit 1dfd8df23d63f786788bc24ebb71039feaf34d91
Author: Uri Simchoni <uri at samba.org>
Date: Tue Aug 2 09:37:00 2016 +0300
smbd: add an option to inherit only the UNIX owner
This can be used to emulate folder quotas, as explained in the
modified manpage.
Signed-off-by: Uri Simchoni <uri at samba.org>
Reviewed-by: Jeremy Allison <jra at samba.org>
commit ebb3b34ec5d323692e59dad1bf8559920eee1fcf
Author: Uri Simchoni <uri at samba.org>
Date: Wed Aug 10 04:58:45 2016 +0300
selftest: add a test for "inherit owner" parameter
Signed-off-by: Uri Simchoni <uri at samba.org>
Reviewed-by: Jeremy Allison <jra at samba.org>
commit 2a8ccc0841184c2df9fc19f8452009b92071c115
Author: Jeremy Allison <jra at samba.org>
Date: Tue Aug 9 11:57:20 2016 -0700
libgpo: Correctly use the 'server' parameter after parsing it out of the GPO path.
BUG: https://bugzilla.samba.org/show_bug.cgi?id=12135
Signed-off-by: Jeremy Allison <jra at samba.org>
Reviewed-by: Uri Simchoni <uri at samba.org>
commit 27ebf64b347a770e0d1ad4f1db645cb1b8dd5861
Author: Jeremy Allison <jra at samba.org>
Date: Mon Aug 8 16:53:21 2016 -0700
s3: libsmb: Protect cli_connect_nb_send() from being passed a NULL hostname and dest_ss.
BUG: https://bugzilla.samba.org/show_bug.cgi?id=12135
Signed-off-by: Jeremy Allison <jra at samba.org>
Reviewed-by: Uri Simchoni <uri at samba.org>
commit c0246b4cc2c351dced44d28021ee4139bdf7b288
Author: Amitay Isaacs <amitay at gmail.com>
Date: Tue Aug 2 18:22:13 2016 +1000
ctdb-ib: Fix DEBUG log messages
https://bugzilla.samba.org/show_bug.cgi?id=12137
Signed-off-by: Amitay Isaacs <amitay at gmail.com>
Reviewed-by: Uri Simchoni <uri at samba.org>
commit f1a8fb11dda578f194063cdcf2c5dca7000b272b
Author: Amitay Isaacs <amitay at gmail.com>
Date: Tue Aug 2 19:04:17 2016 +1000
ctdb-recovery-helper: Fix format-nonliteral warning
... and printf format errors.
BUG: https://bugzilla.samba.org/show_bug.cgi?id=12137
Signed-off-by: Amitay Isaacs <amitay at gmail.com>
Reviewed-by: Uri Simchoni <uri at samba.org>
commit 5176354d1279f0e3c216c58ea8637579d9a6a389
Author: Amitay Isaacs <amitay at gmail.com>
Date: Tue Aug 2 19:00:54 2016 +1000
ctdb-daemon: Fix format-nonliteral warning
BUG: https://bugzilla.samba.org/show_bug.cgi?id=12137
Signed-off-by: Amitay Isaacs <amitay at gmail.com>
Reviewed-by: Uri Simchoni <uri at samba.org>
commit fa0015d9adbd3c98957dc61d04b7ffcaa6703e0f
Author: Amitay Isaacs <amitay at gmail.com>
Date: Tue Aug 2 18:58:51 2016 +1000
ctdb-daemon: Fix format-nonliteral warning
BUG: https://bugzilla.samba.org/show_bug.cgi?id=12137
Signed-off-by: Amitay Isaacs <amitay at gmail.com>
Reviewed-by: Uri Simchoni <uri at samba.org>
commit d682ee99810caac489c20d8b673ff4b12a17d75f
Author: Amitay Isaacs <amitay at gmail.com>
Date: Tue Aug 2 18:54:31 2016 +1000
ctdb-daemon: Fix format-nonliteral warning
BUG: https://bugzilla.samba.org/show_bug.cgi?id=12137
Signed-off-by: Amitay Isaacs <amitay at gmail.com>
Reviewed-by: Uri Simchoni <uri at samba.org>
commit b201859372189b6e7d57e078a813861a1533aaf4
Author: Amitay Isaacs <amitay at gmail.com>
Date: Tue Aug 2 18:31:14 2016 +1000
ctdb-common: Fix format-nonliteral warning
BUG: https://bugzilla.samba.org/show_bug.cgi?id=12137
Signed-off-by: Amitay Isaacs <amitay at gmail.com>
Reviewed-by: Uri Simchoni <uri at samba.org>
-----------------------------------------------------------------------
Summary of changes:
ctdb/common/common.h | 3 +-
ctdb/ib/ibwrapper.c | 20 ++--
ctdb/include/ctdb_private.h | 5 +-
ctdb/server/ctdb_recovery_helper.c | 6 +-
ctdb/server/eventscript.c | 8 ++
docs-xml/smbdotconf/security/inheritowner.xml | 41 ++++++-
lib/param/loadparm.h | 7 ++
lib/param/param_table.c | 6 +
libgpo/gpo_fetch.c | 2 +-
selftest/target/Samba3.pm | 9 ++
source3/libsmb/cliconnect.c | 6 +-
source3/script/tests/test_inherit_owner.sh | 157 ++++++++++++++++++++++++++
source3/selftest/tests.py | 3 +
source3/smbd/open.c | 7 +-
source3/smbd/posix_acls.c | 8 ++
15 files changed, 266 insertions(+), 22 deletions(-)
create mode 100755 source3/script/tests/test_inherit_owner.sh
Changeset truncated at 500 lines:
diff --git a/ctdb/common/common.h b/ctdb/common/common.h
index b89a84c..113816d 100644
--- a/ctdb/common/common.h
+++ b/ctdb/common/common.h
@@ -76,7 +76,8 @@ int ctdb_fetch_with_header_func(struct ctdb_call_info *call);
const char *ctdb_errstr(struct ctdb_context *ctdb);
-void ctdb_set_error(struct ctdb_context *ctdb, const char *fmt, ...);
+void ctdb_set_error(struct ctdb_context *ctdb, const char *fmt, ...)
+ PRINTF_ATTRIBUTE(2,3);
void ctdb_fatal(struct ctdb_context *ctdb, const char *msg);
diff --git a/ctdb/ib/ibwrapper.c b/ctdb/ib/ibwrapper.c
index b10aaf5..f7334b5 100644
--- a/ctdb/ib/ibwrapper.c
+++ b/ctdb/ib/ibwrapper.c
@@ -340,7 +340,7 @@ static int ibw_refill_cq_recv(struct ibw_conn *conn)
rc = ibv_post_recv(pconn->cm_id->qp, &wr, &bad_wr);
if (rc) {
sprintf(ibw_lasterr, "refill/ibv_post_recv failed with %d\n", rc);
- DEBUG(DEBUG_ERR, (ibw_lasterr));
+ DEBUG(DEBUG_ERR, ("%s", ibw_lasterr));
return -2;
}
@@ -374,7 +374,7 @@ static int ibw_fill_cq(struct ibw_conn *conn)
rc = ibv_post_recv(pconn->cm_id->qp, &wr, &bad_wr);
if (rc) {
sprintf(ibw_lasterr, "fill/ibv_post_recv failed with %d\n", rc);
- DEBUG(DEBUG_ERR, (ibw_lasterr));
+ DEBUG(DEBUG_ERR, ("%s", ibw_lasterr));
return -2;
}
}
@@ -651,7 +651,7 @@ static void ibw_event_handler_verbs(struct tevent_context *ev,
error:
ibv_ack_cq_events(pconn->cq, 1);
- DEBUG(DEBUG_ERR, (ibw_lasterr));
+ DEBUG(DEBUG_ERR, ("%s", ibw_lasterr));
if (conn->state!=IBWC_ERROR) {
conn->state = IBWC_ERROR;
@@ -991,7 +991,7 @@ struct ibw_ctx *ibw_init(struct ibw_initattr *attr, int nattr,
return ctx;
/* don't put code here */
cleanup:
- DEBUG(DEBUG_ERR, (ibw_lasterr));
+ DEBUG(DEBUG_ERR, ("%s", ibw_lasterr));
if (ctx)
talloc_free(ctx);
@@ -1029,7 +1029,7 @@ int ibw_bind(struct ibw_ctx *ctx, struct sockaddr_in *my_addr)
rc = rdma_bind_addr(pctx->cm_id, (struct sockaddr *) my_addr);
if (rc) {
sprintf(ibw_lasterr, "rdma_bind_addr error %d\n", rc);
- DEBUG(DEBUG_ERR, (ibw_lasterr));
+ DEBUG(DEBUG_ERR, ("%s", ibw_lasterr));
return rc;
}
DEBUG(DEBUG_DEBUG, ("rdma_bind_addr successful\n"));
@@ -1046,7 +1046,7 @@ int ibw_listen(struct ibw_ctx *ctx, int backlog)
rc = rdma_listen(pctx->cm_id, backlog);
if (rc) {
sprintf(ibw_lasterr, "rdma_listen failed: %d\n", rc);
- DEBUG(DEBUG_ERR, (ibw_lasterr));
+ DEBUG(DEBUG_ERR, ("%s", ibw_lasterr));
return rc;
}
@@ -1068,7 +1068,7 @@ int ibw_accept(struct ibw_ctx *ctx, struct ibw_conn *conn, void *conn_userdata)
rc = rdma_accept(pconn->cm_id, &conn_param);
if (rc) {
sprintf(ibw_lasterr, "rdma_accept failed %d\n", rc);
- DEBUG(DEBUG_ERR, (ibw_lasterr));
+ DEBUG(DEBUG_ERR, ("%s", ibw_lasterr));
return -1;;
}
@@ -1115,7 +1115,7 @@ int ibw_connect(struct ibw_conn *conn, struct sockaddr_in *serv_addr, void *conn
rc = rdma_resolve_addr(pconn->cm_id, NULL, (struct sockaddr *) serv_addr, 2000);
if (rc) {
sprintf(ibw_lasterr, "rdma_resolve_addr error %d\n", rc);
- DEBUG(DEBUG_ERR, (ibw_lasterr));
+ DEBUG(DEBUG_ERR, ("%s", ibw_lasterr));
talloc_free(conn);
return -1;
}
@@ -1142,7 +1142,7 @@ int ibw_disconnect(struct ibw_conn *conn)
rc = rdma_disconnect(pconn->cm_id);
if (rc) {
sprintf(ibw_lasterr, "ibw_disconnect failed with %d\n", rc);
- DEBUG(DEBUG_ERR, (ibw_lasterr));
+ DEBUG(DEBUG_ERR, ("%s", ibw_lasterr));
return rc;
}
break;
@@ -1280,7 +1280,7 @@ static int ibw_send_packet(struct ibw_conn *conn, void *buf, struct ibw_wr *p, u
return 0;
error:
- DEBUG(DEBUG_ERR, (ibw_lasterr));
+ DEBUG(DEBUG_ERR, ("%s", ibw_lasterr));
return -1;
}
diff --git a/ctdb/include/ctdb_private.h b/ctdb/include/ctdb_private.h
index cf30efd..532ae0a 100644
--- a/ctdb/include/ctdb_private.h
+++ b/ctdb/include/ctdb_private.h
@@ -601,11 +601,12 @@ int ctdb_control_getnodesfile(struct ctdb_context *ctdb, uint32_t opcode,
void ctdb_shutdown_sequence(struct ctdb_context *ctdb, int exit_code);
int switch_from_server_to_client(struct ctdb_context *ctdb,
- const char *fmt, ...);
+ const char *fmt, ...) PRINTF_ATTRIBUTE(2,3);
/* From server/ctdb_fork.c */
-void ctdb_set_child_info(TALLOC_CTX *mem_ctx, const char *child_name_fmt, ...);
+void ctdb_set_child_info(TALLOC_CTX *mem_ctx, const char *child_name_fmt,
+ ...) PRINTF_ATTRIBUTE(2,3);
void ctdb_track_child(struct ctdb_context *ctdb, pid_t pid);
diff --git a/ctdb/server/ctdb_recovery_helper.c b/ctdb/server/ctdb_recovery_helper.c
index 6b487b9..9e142cd 100644
--- a/ctdb/server/ctdb_recovery_helper.c
+++ b/ctdb/server/ctdb_recovery_helper.c
@@ -40,6 +40,8 @@ static int recover_timeout = 30;
#define TIMEOUT() timeval_current_ofs(recover_timeout, 0)
+static void LOG(const char *fmt, ...) PRINTF_ATTRIBUTE(1,2);
+
static void LOG(const char *fmt, ...)
{
va_list ap;
@@ -1683,7 +1685,7 @@ static void recover_db_transaction_started(struct tevent_req *subreq)
state->count,
err_list, &pnn);
if (ret2 != 0) {
- LOG("control TRANSACTION_DB failed for db=%s,"
+ LOG("control TRANSACTION_DB failed for db=%s on node %u,"
" ret=%d\n", state->db_name, pnn, ret2);
} else {
LOG("control TRANSACTION_DB failed for db=%s,"
@@ -1777,7 +1779,7 @@ static void recover_db_wipedb_done(struct tevent_req *subreq)
" ret=%d\n", state->db_name, pnn, ret2);
} else {
LOG("control WIPEDB failed for db %s, ret=%d\n",
- state->db_name, pnn, ret);
+ state->db_name, ret);
}
tevent_req_error(req, ret);
return;
diff --git a/ctdb/server/eventscript.c b/ctdb/server/eventscript.c
index 17e4f35..bd5bc0d 100644
--- a/ctdb/server/eventscript.c
+++ b/ctdb/server/eventscript.c
@@ -709,6 +709,14 @@ static int ctdb_event_script_callback_v(struct ctdb_context *ctdb,
void *private_data,
enum ctdb_event call,
const char *fmt, va_list ap)
+ PRINTF_ATTRIBUTE(6,0);
+
+static int ctdb_event_script_callback_v(struct ctdb_context *ctdb,
+ const void *mem_ctx,
+ void (*callback)(struct ctdb_context *, int, void *),
+ void *private_data,
+ enum ctdb_event call,
+ const char *fmt, va_list ap)
{
struct ctdb_event_script_state *state;
diff --git a/docs-xml/smbdotconf/security/inheritowner.xml b/docs-xml/smbdotconf/security/inheritowner.xml
index ab7da57..2a7a4b8 100644
--- a/docs-xml/smbdotconf/security/inheritowner.xml
+++ b/docs-xml/smbdotconf/security/inheritowner.xml
@@ -1,6 +1,7 @@
<samba:parameter name="inherit owner"
context="S"
- type="boolean"
+ type="enum"
+ enumlist="enum_inherit_owner_vals"
xmlns:samba="http://www.samba.org/samba/DTD/samba-doc">
<description>
<para>The ownership of new files and directories
@@ -8,11 +9,47 @@
This option allows the Samba administrator to specify that
the ownership for new files and directories should be controlled
by the ownership of the parent directory.</para>
-
+
+ <para>Valid options are:</para>
+ <itemizedlist>
+ <listitem><para><constant>no</constant> -
+ Both the Windows (SID) owner and the UNIX (uid) owner of the file are
+ governed by the identity of the user that created the file.
+ </para></listitem>
+
+ <listitem><para><constant>windows and unix</constant> -
+ The Windows (SID) owner and the UNIX (uid) owner of new files and
+ directories are set to the respective owner of the parent directory.
+ </para></listitem>
+
+ <listitem><para><constant>yes</constant> - a synonym for
+ <constant>windows and unix</constant>.
+ </para></listitem>
+
+ <listitem><para><constant>unix only</constant> -
+ Only the UNIX owner is set to the UNIX owner of the parent directory.
+ </para></listitem>
+ </itemizedlist>
+
<para>Common scenarios where this behavior is useful is in
implementing drop-boxes, where users can create and edit files but
not delete them and ensuring that newly created files in a user's
roaming profile directory are actually owned by the user.</para>
+
+ <para>The <constant>unix only</constant> option effectively
+ breaks the tie between the Windows owner of a file and the
+ UNIX owner. As a logical consequence, in this mode,
+ setting the the Windows owner of a file does not modify the UNIX
+ owner. Using this mode should typically be combined with a
+ backing store that can emulate the full NT ACL model without
+ affecting the POSIX permissions, such as the acl_xattr
+ VFS module, coupled with
+ <smbconfoption name="acl_xattr:ignore system acls">yes</smbconfoption>.
+ This can be used to emulate folder quotas, when files are
+ exposed only via SMB (without UNIX extensions).
+ The UNIX owner of a directory is locally set
+ and inherited by all subdirectories and files, and they all
+ consume the same quota.</para>
</description>
<related>inherit permissions</related>
diff --git a/lib/param/loadparm.h b/lib/param/loadparm.h
index d8f6975..f9fb7d8 100644
--- a/lib/param/loadparm.h
+++ b/lib/param/loadparm.h
@@ -229,6 +229,13 @@ enum mapreadonly_options {MAP_READONLY_NO, MAP_READONLY_YES, MAP_READONLY_PERMIS
/* case handling */
enum case_handling {CASE_LOWER,CASE_UPPER};
+/* inherit owner options */
+enum inheritowner_options {
+ INHERIT_OWNER_NO,
+ INHERIT_OWNER_WINDOWS_AND_UNIX,
+ INHERIT_OWNER_UNIX_ONLY
+};
+
/*
* Default passwd chat script.
*/
diff --git a/lib/param/param_table.c b/lib/param/param_table.c
index c8520d2..4b5234a 100644
--- a/lib/param/param_table.c
+++ b/lib/param/param_table.c
@@ -308,6 +308,12 @@ static const struct enum_list enum_case[] = {
{-1, NULL}
};
+static const struct enum_list enum_inherit_owner_vals[] = {
+ {INHERIT_OWNER_NO, "no"},
+ {INHERIT_OWNER_WINDOWS_AND_UNIX, "windows and unix"},
+ {INHERIT_OWNER_WINDOWS_AND_UNIX, "yes"},
+ {INHERIT_OWNER_UNIX_ONLY, "unix only"},
+ {-1, NULL}};
/* Note: We do not initialise the defaults union - it is not allowed in ANSI C
*
diff --git a/libgpo/gpo_fetch.c b/libgpo/gpo_fetch.c
index 97ecd62..836bc23 100644
--- a/libgpo/gpo_fetch.c
+++ b/libgpo/gpo_fetch.c
@@ -166,7 +166,7 @@ NTSTATUS gpo_fetch_files(TALLOC_CTX *mem_ctx,
/* for now reuse the existing ds connection */
- result = gpo_connect_server(ads, ads->server.ldap_server, service, &cli);
+ result = gpo_connect_server(ads, server, service, &cli);
NT_STATUS_NOT_OK_RETURN(result);
result = gpo_prepare_local_store(mem_ctx, cache_dir, unix_path);
diff --git a/selftest/target/Samba3.pm b/selftest/target/Samba3.pm
index e8f35e3..a0996a8 100755
--- a/selftest/target/Samba3.pm
+++ b/selftest/target/Samba3.pm
@@ -671,6 +671,15 @@ sub setup_fileserver($$)
path = $share_dir
comment = ignore system acls
acl_xattr:ignore system acls = yes
+[inherit_owner]
+ path = $share_dir
+ comment = inherit owner
+ inherit owner = yes
+[inherit_owner_u]
+ path = $share_dir
+ comment = inherit only unix owner
+ inherit owner = unix only
+ acl_xattr:ignore system acls = yes
";
my $vars = $self->provision($path,
diff --git a/source3/libsmb/cliconnect.c b/source3/libsmb/cliconnect.c
index ebba8f2..33759d9 100644
--- a/source3/libsmb/cliconnect.c
+++ b/source3/libsmb/cliconnect.c
@@ -3108,11 +3108,15 @@ static struct tevent_req *cli_connect_nb_send(
}
state->desthost = host;
- } else {
+ } else if (dest_ss != NULL) {
state->desthost = print_canonical_sockaddr(state, dest_ss);
if (tevent_req_nomem(state->desthost, req)) {
return tevent_req_post(req, ev);
}
+ } else {
+ /* No host or dest_ss given. Error out. */
+ tevent_req_error(req, EINVAL);
+ return tevent_req_post(req, ev);
}
subreq = cli_connect_sock_send(state, ev, host, name_type, dest_ss,
diff --git a/source3/script/tests/test_inherit_owner.sh b/source3/script/tests/test_inherit_owner.sh
new file mode 100755
index 0000000..5146d40
--- /dev/null
+++ b/source3/script/tests/test_inherit_owner.sh
@@ -0,0 +1,157 @@
+#!/bin/sh
+
+# this tests "inherit owner" config parameter
+# currently needs to run in SMB1 mode, because it uses UNIX
+# extensions to fetch the UNIX owner of a file.
+
+if [ $# -lt 9 ]; then
+cat <<EOF
+Usage: $0 SERVER USERNAME PASSWORD PREFIX SMBCLIENT SMBCACLS SHARE INH_WIN INH_UNIX <additional args>
+EOF
+exit 1;
+fi
+
+SERVER="$1"
+USERNAME="$2"
+PASSWORD="$3"
+PREFIX="$4"
+SMBCLIENT="$5"
+SMBCACLS="$6"
+SHARE="$7"
+INH_WIN="$8"
+INH_UNIX="$9"
+shift 9
+ADDARGS="$*"
+SMBCLIENT="$VALGRIND ${SMBCLIENT} ${ADDARGS}"
+SMBCACLS="$VALGRIND ${SMBCACLS} ${ADDARGS}"
+
+incdir=`dirname $0`/../../../testprogs/blackbox
+. $incdir/subunit.sh
+
+create_file() {
+ local share=$1
+ local fname=$2
+ local rem_dirname=$(dirname $fname)
+ local bname=$(basename $fname)
+ touch $PREFIX/$bname
+ $SMBCLIENT //$SERVER/$share -U $USERNAME%$PASSWORD -c "cd $rem_dirname; rm $bname" 2>/dev/null
+ $SMBCLIENT //$SERVER/$share -U $USERNAME%$PASSWORD -c "cd $rem_dirname; ls" 2>/dev/null | grep "$bname" && exit 1
+ $SMBCLIENT //$SERVER/$share -U $USERNAME%$PASSWORD -c "lcd $PREFIX; cd $rem_dirname; put $bname" 2>/dev/null || exit 1
+}
+
+create_dir() {
+ local share=$1
+ local dname=$2
+ local rem_dirname=$(dirname $dname)
+ local bname=$(basename $dname)
+ $SMBCLIENT //$SERVER/$share -U $USERNAME%$PASSWORD -c "cd $rem_dirname; rmdir $bname" 2>/dev/null
+ $SMBCLIENT //$SERVER/$share -U $USERNAME%$PASSWORD -c "cd $rem_dirname; ls" 2>/dev/null | grep "$dname" && exit 1
+ $SMBCLIENT //$SERVER/$share -U $USERNAME%$PASSWORD -c "cd $rem_dirname; mkdir $bname" 2>/dev/null || exit 1
+}
+
+cleanup_file() {
+ local share=$1
+ local fname=$2
+ local rem_dirname=$(dirname $fname)
+ local bname=$(basename $fname)
+ $SMBCLIENT //$SERVER/$share -U $USERNAME%$PASSWORD -c "cd $rem_dirname; rm $bname" 2>/dev/null || exit 1
+}
+
+cleanup_dir() {
+ local share=$1
+ local dname=$2
+ local rem_dirname=$(dirname $dname)
+ local bname=$(basename $dname)
+ $SMBCLIENT //$SERVER/$share -U $USERNAME%$PASSWORD -c "cd $rem_dirname; rmdir $bname" 2>/dev/null || exit 1
+}
+
+set_win_owner() {
+ local share=$1
+ local fname=$2
+ local owner=$3
+ $SMBCACLS //$SERVER/$share $fname -U $USERNAME%$PASSWORD -C $owner 2>/dev/null || exit 1
+}
+
+unix_owner_id_is() {
+ local share=$1
+ local fname=$2
+ local expected_id=$3
+ local actual_id
+ actual_id=$($SMBCLIENT //$SERVER/$share -U $USERNAME%$PASSWORD -c "getfacl $fname" 2>/dev/null | sed -rn 's/^# owner: (.*)/\1/p')
+ if ! test "x$actual_id" = "x$expected_id" ; then
+ echo "Actual uid of $share/$fname is [$actual_id] expected [$expected_id]"
+ exit 1
+ fi
+}
+
+get_unix_id() {
+ local user=$1
+ local ent
+ ent=$(getent passwd $user) || exit 1
+ echo "$ent" | awk -F: '{print $3}'
+}
+
+win_owner_is() {
+ local share=$1
+ local fname=$2
+ local expected_owner=$3
+ local actual_owner
+ actual_owner=$($SMBCACLS //$SERVER/$share $fname -U $USERNAME%$PASSWORD 2>/dev/null | sed -rn 's/^OWNER:(.*)/\1/p')
+ if ! test "x$actual_owner" = "x$expected_owner" ; then
+ echo "Actual owner of $share/$fname is [$actual_owner] expected [$expected_owner]"
+ exit 1
+ fi
+}
+
+default_uid=$(get_unix_id $USERNAME)
+alt_uid=$(get_unix_id force_user)
+
+if [ "$INH_WIN" = "0" ] && [ "$INH_UNIX" = "0" ] ; then
+ #default - file owned by creator, change-owner modifies both
+ WIN_OWNER_AFTER_CREATE="$SERVER/$USERNAME"
+ UNIX_OWNER_AFTER_CREATE=$(get_unix_id $USERNAME)
+ WIN_OWNER_AFTER_CHOWN="$SERVER/smbget_user"
+ UNIX_OWNER_AFTER_CHOWN=$(get_unix_id smbget_user)
+ TEST_LABEL="default"
+elif [ "$INH_WIN" = "1" ] && [ "$INH_UNIX" = "1" ] ; then
+ #inherit owner=windows and unix - file owned by parent
+ #owner, change-owner modifies both
+ WIN_OWNER_AFTER_CREATE="$SERVER/force_user"
+ UNIX_OWNER_AFTER_CREATE=$(get_unix_id force_user)
+ WIN_OWNER_AFTER_CHOWN="$SERVER/smbget_user"
+ UNIX_OWNER_AFTER_CHOWN=$(get_unix_id smbget_user)
+ TEST_LABEL="both"
+elif [ "$INH_WIN" = "0" ] && [ "$INH_UNIX" = "1" ] ; then
+ #inherit owner=unix only - windows owner is creator,
+ #unix owner inherited, upon change-owner only windows
+ #owner is changed
+ WIN_OWNER_AFTER_CREATE="$SERVER/$USERNAME"
+ UNIX_OWNER_AFTER_CREATE=$(get_unix_id force_user)
+ WIN_OWNER_AFTER_CHOWN="$SERVER/smbget_user"
+ UNIX_OWNER_AFTER_CHOWN=$(get_unix_id force_user)
+ TEST_LABEL="unix"
+else
+ echo "Unknown combination INH_WIN=$INH_WIN INH_UNIX=$INH_UNIX"
+ exit 1
+fi
+
+# SETUP
+testit "$TEST_LABEL - setup root dir" create_dir tmp tmp.$$
+testit "$TEST_LABEL - assign default ACL" $SMBCACLS //$SERVER/tmp tmp.$$ -U $USERNAME%$PASSWORD -S "REVISION:1,OWNER:$SERVER\force_user,GROUP:$SERVER\domusers,ACL:Everyone:ALLOWED/0x3/FULL" 2>/dev/null
+# END SETUP
+
+testit "$TEST_LABEL - create subdir under root" create_dir $SHARE tmp.$$/subdir
+testit "$TEST_LABEL - verify subdir win owner" win_owner_is $SHARE tmp.$$/subdir "$WIN_OWNER_AFTER_CREATE"
+testit "$TEST_LABEL - verify subdir unix owner" unix_owner_id_is $SHARE tmp.$$/subdir $UNIX_OWNER_AFTER_CREATE
+testit "$TEST_LABEL - create file under root" create_file $SHARE tmp.$$/afile
+testit "$TEST_LABEL - verify file win owner" win_owner_is $SHARE tmp.$$/afile "$WIN_OWNER_AFTER_CREATE"
+testit "$TEST_LABEL - verify file unix owner" unix_owner_id_is $SHARE tmp.$$/afile $UNIX_OWNER_AFTER_CREATE
+testit "$TEST_LABEL - change dir owner" set_win_owner $SHARE tmp.$$/subdir "$SERVER\smbget_user"
+testit "$TEST_LABEL - verify subdir win owner after change" win_owner_is $SHARE tmp.$$/subdir "$WIN_OWNER_AFTER_CHOWN"
+testit "$TEST_LABEL - verify subdir unix owner after change" unix_owner_id_is $SHARE tmp.$$/subdir $UNIX_OWNER_AFTER_CHOWN
+testit "$TEST_LABEL - change file owner" set_win_owner $SHARE tmp.$$/afile "$SERVER\smbget_user"
+testit "$TEST_LABEL - verify file win owner after change" win_owner_is $SHARE tmp.$$/afile "$WIN_OWNER_AFTER_CHOWN"
+testit "$TEST_LABEL - verify file unix owner after change" unix_owner_id_is $SHARE tmp.$$/afile $UNIX_OWNER_AFTER_CHOWN
+testit "$TEST_LABEL - cleanup subdir" cleanup_dir $SHARE tmp.$$/subdir
+testit "$TEST_LABEL - cleanup file" cleanup_file $SHARE tmp.$$/afile
+testit "$TEST_LABEL - cleanup root" cleanup_dir $SHARE tmp.$$
diff --git a/source3/selftest/tests.py b/source3/selftest/tests.py
index 4736ebc..23fb37d 100755
--- a/source3/selftest/tests.py
+++ b/source3/selftest/tests.py
@@ -193,6 +193,9 @@ for env in ["fileserver"]:
plantestsuite("samba3.blackbox.netshareenum (%s)" % env, env, [os.path.join(samba3srcdir, "script/tests/test_shareenum.sh"), '$SERVER', '$USERNAME', '$PASSWORD', rpcclient])
plantestsuite("samba3.blackbox.acl_xattr (%s)" % env, env, [os.path.join(samba3srcdir, "script/tests/test_acl_xattr.sh"), '$SERVER', '$USERNAME', '$PASSWORD', '$PREFIX', smbclient3, smbcacls])
plantestsuite("samba3.blackbox.smb2.not_casesensitive (%s)" % env, env, [os.path.join(samba3srcdir, "script/tests/test_smb2_not_casesensitive.sh"), '//$SERVER/tmp', '$SERVER_IP', '$USERNAME', '$PASSWORD', '$LOCAL_PATH', smbclient3])
+ plantestsuite("samba3.blackbox.inherit_owner.default(%s)" % env, env, [os.path.join(samba3srcdir, "script/tests/test_inherit_owner.sh"), '$SERVER', '$USERNAME', '$PASSWORD', '$PREFIX', smbclient3, smbcacls, 'tmp', '0', '0', '-m', 'NT1'])
--
Samba Shared Repository
More information about the samba-cvs
mailing list