[SCM] Samba Shared Repository - branch v4-5-test updated

Karolin Seeger kseeger at samba.org
Mon Jan 9 12:39:06 UTC 2017


The branch, v4-5-test has been updated
       via  4d37a14 s3: torture: Add test for cli_ftruncate calling cli_smb2_ftruncate.
       via  aa69068 s3: libsmb: Add cli_smb2_ftruncate(), plumb into cli_ftruncate().
       via  ca1885a ctdbd_conn: remove unused fde from struct ctdbd_connection
       via  4e6e513 ctdbd_conn: fix a resource leak
       via  d9e5812 selftest: Do not include system krb5.conf in selftest
       via  1d22840 s3:libads: Include system /etc/krb5.conf if we use MIT Kerberos
       via  66fce30 s3:param: Add an 'include system krb5 conf' option
       via  e76e188 s3/smbd: remove a misleading error message
       via  586f8b7 vfs_fruit: fix fruit:resource option spelling, but not behaviour
      from  adbab18 winbindd: Use idmap cache in xids2sids

https://git.samba.org/?p=samba.git;a=shortlog;h=v4-5-test


- Log -----------------------------------------------------------------
commit 4d37a14effb3b23c02e48dbc09f1761778211193
Author: Jeremy Allison <jra at samba.org>
Date:   Tue Jan 3 15:37:03 2017 -0800

    s3: torture: Add test for cli_ftruncate calling cli_smb2_ftruncate.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=12479
    
    Back-port from cherry pick from commit b92cac857823ac2d29133fba2fde57cf58805b45)
    
    Signed-off-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Uri Simchoni <uri at samba.org>
    
    Autobuild-User(v4-5-test): Karolin Seeger <kseeger at samba.org>
    Autobuild-Date(v4-5-test): Mon Jan  9 13:38:17 CET 2017 on sn-devel-144

commit aa690681b99500bff992783a24684aca692f25c3
Author: Jeremy Allison <jra at samba.org>
Date:   Wed Dec 21 13:55:50 2016 -0800

    s3: libsmb: Add cli_smb2_ftruncate(), plumb into cli_ftruncate().
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=12479
    
    Signed-off-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Uri Simchoni <uri at samba.org>
    (cherry picked from commit e0f1ed9f450851bf5b7fec84577b50047309db3f)

commit ca1885ad0bd2b4abb222b530a9892f3d16a44539
Author: Ralph Boehme <slow at samba.org>
Date:   Tue Dec 27 15:41:51 2016 +0100

    ctdbd_conn: remove unused fde from struct ctdbd_connection
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=12485
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: David Disseldorp <ddiss at samba.org>

commit 4e6e513b32a9ac43a176407ded3a7c08fac72cdc
Author: Ralph Boehme <slow at samba.org>
Date:   Tue Dec 27 09:19:16 2016 +0100

    ctdbd_conn: fix a resource leak
    
    When reinitializing the ctdb messaging subsystem we must free the ctdb
    connection fde.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=12485
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: David Disseldorp <ddiss at samba.org>

commit d9e58121d3caac1d5ed8de950243aba71805aea2
Author: Andreas Schneider <asn at samba.org>
Date:   Thu Dec 1 08:18:58 2016 +0100

    selftest: Do not include system krb5.conf in selftest
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=12441
    
    Signed-off-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Alexander Bokovoy <ab at samba.org>

commit 1d2284067ecf08a1370e8cfa1c2fc1c76058206f
Author: Andreas Schneider <asn at samba.org>
Date:   Wed Nov 23 14:40:42 2016 +0100

    s3:libads: Include system /etc/krb5.conf if we use MIT Kerberos
    
    The system /etc/krb5.conf defines some defaults like:
    
        default_ccache_name = KEYRING:persistent:%{uid}
    
    We need to respect that so should include it in our own created
    krb5.conf file.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=12441
    
    Signed-off-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Alexander Bokovoy <ab at samba.org>
    (cherry picked from commit 4ef772be3a7259b48253643392574fab28c37916)

commit 66fce30b0be0b24432e8a1c59cbf55f6a14e5402
Author: Andreas Schneider <asn at samba.org>
Date:   Wed Nov 23 14:39:47 2016 +0100

    s3:param: Add an 'include system krb5 conf' option
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=12441
    
    Signed-off-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Alexander Bokovoy <ab at samba.org>
    (cherry picked from commit f464f69b33b40c81d6ee57bebf9d59837431739b)

commit e76e188c38068b35ae2a1cbba8472394b4a10cc9
Author: Ralph Boehme <slow at samba.org>
Date:   Fri Sep 16 12:48:39 2016 +0200

    s3/smbd: remove a misleading error message
    
    It can happen that we get 0 cleanup events, so remove this error
    message.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=12396
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Andreas Schneider <asn at samba.org>
    
    Autobuild-User(master): Ralph Böhme <slow at samba.org>
    Autobuild-Date(master): Fri Sep 16 16:43:16 CEST 2016 on sn-devel-144

commit 586f8b73b6c189cb825ce2e8817230ca57f87d35
Author: Ralph Boehme <slow at samba.org>
Date:   Tue Nov 8 12:35:12 2016 +0100

    vfs_fruit: fix fruit:resource option spelling, but not behaviour
    
    IMPORTANT
    =========
    
    this is a backport of commit 7d4b4a429955cf7fd43f3ac83990c5386ac8cd76
    that only uses the spelling corrections of comments and the tests
    without changing any behaviour. This greatly simplifies the backport.
    
    Changing the option names in the tests without fixing the code means
    that this patchset can't be used to run autobuild...
    
    ORIGINAL COMMIT MESSAGE
    =======================
    
    Fix all occurences of bad spelling of "resource" as "res*s*ource" (two
    s).
    
    One of the places where this was wrong was when parsing parametric
    options in the VFS connect() function in the module. As a result any
    setting of
    
      fruit:resource=something
    
    in smb.conf was silently ignored and the default ("file") was active.
    
    In Samba 4.6 we accept both the wrong and the correct spelling, in Samba
    4.7 the bad spelling will be removed.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=12412
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    (adopted from commit 7d4b4a429955cf7fd43f3ac83990c5386ac8cd76)

-----------------------------------------------------------------------

Summary of changes:
 docs-xml/manpages/vfs_fruit.8.xml                  |    8 +-
 .../smbdotconf/winbind/includesystemkrb5conf.xml   |   15 +
 lib/torture/torture.h                              |   10 +
 python/samba/tests/docs.py                         |    3 +-
 selftest/selftest.pl                               |    1 +
 selftest/target/Samba3.pm                          |   27 +-
 selftest/target/Samba4.pm                          |    2 +-
 source3/include/MacExtensions.h                    |    3 +
 source3/lib/ctdbd_conn.c                           |    2 -
 source3/lib/messages_ctdbd.c                       |    2 +
 source3/libads/kerberos.c                          |   13 +-
 source3/libsmb/cli_smb2_fnum.c                     |   65 +
 source3/libsmb/cli_smb2_fnum.h                     |    3 +
 source3/libsmb/clifile.c                           |    8 +-
 source3/modules/vfs_catia.c                        | 1052 ++++++
 source3/modules/vfs_fruit.c                        | 3479 ++++++++++++++------
 source3/modules/vfs_streams_xattr.c                |    6 +-
 source3/param/loadparm.c                           |    1 +
 source3/selftest/tests.py                          |    9 +-
 source3/smbd/smbd_cleanupd.c                       |    1 -
 source3/torture/proto.h                            |    1 +
 source3/torture/test_smb2.c                        |  160 +
 source3/torture/torture.c                          |    1 +
 source4/torture/vfs/fruit.c                        |  398 ++-
 source4/torture/vfs/vfs.c                          |   37 +-
 25 files changed, 4258 insertions(+), 1049 deletions(-)
 create mode 100644 docs-xml/smbdotconf/winbind/includesystemkrb5conf.xml


Changeset truncated at 500 lines:

diff --git a/docs-xml/manpages/vfs_fruit.8.xml b/docs-xml/manpages/vfs_fruit.8.xml
index a0b3893..c31aa75 100644
--- a/docs-xml/manpages/vfs_fruit.8.xml
+++ b/docs-xml/manpages/vfs_fruit.8.xml
@@ -168,9 +168,13 @@
 
 	      <para>Controls how the set of illegal NTFS ASCII
 	      character, commonly used by OS X clients, are stored in
-	      the filesystem:</para>
+	      the filesystem.</para>
 
-	      <itemizedlist>
+	      <para><emphasis>Important:</emphasis> this is known to not fully
+	      work with <emphasis>fruit:metadata=stream</emphasis> or
+	      <emphasis>fruit:resource=stream</emphasis>.</para>
+
+ 	      <itemizedlist>
 
 		<listitem><para><command>private (default)</command> -
 		store characters as encoded by the OS X client: mapped
diff --git a/docs-xml/smbdotconf/winbind/includesystemkrb5conf.xml b/docs-xml/smbdotconf/winbind/includesystemkrb5conf.xml
new file mode 100644
index 0000000..3e53292
--- /dev/null
+++ b/docs-xml/smbdotconf/winbind/includesystemkrb5conf.xml
@@ -0,0 +1,15 @@
+<samba:parameter name="include system krb5 conf"
+                 context="G"
+                 type="boolean"
+                 xmlns:samba="http://www.samba.org/samba/DTD/samba-doc">
+<description>
+	<para>
+		Setting this parameter to <value type="example">no</value> will prevent
+		winbind to include the system /etc/krb5.conf file into the krb5.conf file
+		it creates. See also <smbconfoption name="create krb5 conf"/>. This option
+		only applies to Samba built with MIT Kerberos.
+	</para>
+
+</description>
+<value type="default">yes</value>
+</samba:parameter>
diff --git a/lib/torture/torture.h b/lib/torture/torture.h
index 45332b2..f889211 100644
--- a/lib/torture/torture.h
+++ b/lib/torture/torture.h
@@ -357,6 +357,16 @@ void torture_result(struct torture_context *test,
 	} \
 	} while(0)
 
+#define torture_assert_mem_equal_goto(torture_ctx,got,expected,len,ret,label,cmt) \
+	do { const void *__got = (got), *__expected = (expected); \
+	if (memcmp(__got, __expected, len) != 0) { \
+		torture_result(torture_ctx, TORTURE_FAIL, \
+			       __location__": "#got" of len %d did not match "#expected": %s", (int)len, cmt); \
+		return false; \
+		goto label; \
+	} \
+	} while(0)
+
 static inline void torture_dump_data_str_cb(const char *buf, void *private_data)
 {
 	char **dump = (char **)private_data;
diff --git a/python/samba/tests/docs.py b/python/samba/tests/docs.py
index 238b5c7..22e0225 100644
--- a/python/samba/tests/docs.py
+++ b/python/samba/tests/docs.py
@@ -107,7 +107,8 @@ class SmbDotConfTests(TestCase):
                          'queuepause command','lpresume command', 'lppause command',
                          'lprm command', 'lpq command', 'print command', 'template homedir',
                          'spoolss: os_major', 'spoolss: os_minor', 'spoolss: os_build',
-                         'max open files', 'fss: prune stale', 'fss: sequence timeout'])
+                         'max open files', 'fss: prune stale', 'fss: sequence timeout',
+                         'include system krb5 conf'])
 
     def setUp(self):
         super(SmbDotConfTests, self).setUp()
diff --git a/selftest/selftest.pl b/selftest/selftest.pl
index 1284e77..4a63a87 100755
--- a/selftest/selftest.pl
+++ b/selftest/selftest.pl
@@ -596,6 +596,7 @@ sub write_clientconf($$$)
 	tls cafile = ${cacert}
 	tls crlfile = ${cacrl_pem}
 	tls verify peer = no_check
+	include system krb5 conf = no
 ";
 	close(CF);
 }
diff --git a/selftest/target/Samba3.pm b/selftest/target/Samba3.pm
index eb1e083..9a06733 100755
--- a/selftest/target/Samba3.pm
+++ b/selftest/target/Samba3.pm
@@ -1429,6 +1429,7 @@ sub provision($$$$$$$$)
 	winbind enum users = yes
 	winbind enum groups = yes
 	winbind separator = /
+	include system krb5 conf = no
 
 #	min receivefile size = 4000
 
@@ -1609,11 +1610,35 @@ sub provision($$$$$$$$)
 	path = $shrdir
 	vfs objects = catia fruit streams_xattr acl_xattr
 	ea support = yes
-	fruit:ressource = file
+	fruit:resource = file
 	fruit:metadata = netatalk
 	fruit:locking = netatalk
 	fruit:encoding = native
 
+[vfs_fruit_metadata_stream]
+	path = $shrdir
+	vfs objects = fruit streams_xattr acl_xattr
+	ea support = yes
+	fruit:resource = file
+	fruit:metadata = stream
+
+[vfs_fruit_stream_depot]
+	path = $shrdir
+	vfs objects = fruit streams_depot acl_xattr
+	ea support = yes
+	fruit:resource = stream
+	fruit:metadata = stream
+
+[vfs_wo_fruit]
+	path = $shrdir
+	vfs objects = streams_xattr acl_xattr
+	ea support = yes
+
+[vfs_wo_fruit_stream_depot]
+	path = $shrdir
+	vfs objects = streams_depot acl_xattr
+	ea support = yes
+
 [badname-tmp]
 	path = $badnames_shrdir
 	guest ok = yes
diff --git a/selftest/target/Samba4.pm b/selftest/target/Samba4.pm
index f1de4b9..ffa104f 100755
--- a/selftest/target/Samba4.pm
+++ b/selftest/target/Samba4.pm
@@ -910,7 +910,7 @@ sub provision($$$$$$$$$$)
 	path = $ctx->{share}
 	vfs objects = catia fruit streams_xattr acl_xattr
 	ea support = yes
-	fruit:ressource = file
+	fruit:resource = file
 	fruit:metadata = netatalk
 	fruit:locking = netatalk
 	fruit:encoding = native
diff --git a/source3/include/MacExtensions.h b/source3/include/MacExtensions.h
index 23dcde9..e17d39b 100644
--- a/source3/include/MacExtensions.h
+++ b/source3/include/MacExtensions.h
@@ -51,6 +51,9 @@
 #define AFP_Version			0x00000100
 #define AFP_BackupTime		0x80000000
 #define AFP_FinderSize		32
+
+#define AFP_OFF_FinderInfo	16
+
 /*
 ** Orginal AFP_AfpInfo stream used by NT 
 ** We needed a way to store the create date so SAMBA
diff --git a/source3/lib/ctdbd_conn.c b/source3/lib/ctdbd_conn.c
index 118f3a0..d16796f 100644
--- a/source3/lib/ctdbd_conn.c
+++ b/source3/lib/ctdbd_conn.c
@@ -50,7 +50,6 @@ struct ctdbd_connection {
 	uint64_t rand_srvid;
 	struct ctdbd_srvid_cb *callbacks;
 	int fd;
-	struct tevent_fd *fde;
 	int timeout;
 };
 
@@ -394,7 +393,6 @@ static int ctdb_read_req(struct ctdbd_connection *conn, uint32_t reqid,
 
 static int ctdbd_connection_destructor(struct ctdbd_connection *c)
 {
-	TALLOC_FREE(c->fde);
 	if (c->fd != -1) {
 		close(c->fd);
 		c->fd = -1;
diff --git a/source3/lib/messages_ctdbd.c b/source3/lib/messages_ctdbd.c
index 5964894..bee2685 100644
--- a/source3/lib/messages_ctdbd.c
+++ b/source3/lib/messages_ctdbd.c
@@ -183,6 +183,8 @@ static int messaging_ctdbd_init_internal(struct messaging_context *msg_ctx,
 	int ret, ctdb_fd;
 
 	if (reinit) {
+		TALLOC_FREE(ctx->fde);
+
 		ret = ctdbd_reinit_connection(ctx,
 					      lp_ctdbd_socket(),
 					      lp_ctdb_timeout(),
diff --git a/source3/libads/kerberos.c b/source3/libads/kerberos.c
index 53407fa..2872b00 100644
--- a/source3/libads/kerberos.c
+++ b/source3/libads/kerberos.c
@@ -829,6 +829,7 @@ bool create_local_private_krb5_conf_for_domain(const char *realm,
 	char *realm_upper = NULL;
 	bool result = false;
 	char *aes_enctypes = NULL;
+	const char *include_system_krb5 = "";
 	mode_t mask;
 
 	if (!lp_create_krb5_conf()) {
@@ -897,6 +898,12 @@ bool create_local_private_krb5_conf_for_domain(const char *realm,
 	}
 #endif
 
+#if !defined(SAMBA4_USES_HEIMDAL)
+	if (lp_include_system_krb5_conf()) {
+		include_system_krb5 = "include /etc/krb5.conf";
+	}
+#endif
+
 	file_contents = talloc_asprintf(fname,
 					"[libdefaults]\n\tdefault_realm = %s\n"
 					"\tdefault_tgs_enctypes = %s RC4-HMAC DES-CBC-CRC DES-CBC-MD5\n"
@@ -904,9 +911,11 @@ bool create_local_private_krb5_conf_for_domain(const char *realm,
 					"\tpreferred_enctypes = %s RC4-HMAC DES-CBC-CRC DES-CBC-MD5\n"
 					"\tdns_lookup_realm = false\n\n"
 					"[realms]\n\t%s = {\n"
-					"%s\t}\n",
+					"%s\t}\n"
+					"%s\n",
 					realm_upper, aes_enctypes, aes_enctypes, aes_enctypes,
-					realm_upper, kdc_ip_string);
+					realm_upper, kdc_ip_string,
+					include_system_krb5);
 
 	if (!file_contents) {
 		goto done;
diff --git a/source3/libsmb/cli_smb2_fnum.c b/source3/libsmb/cli_smb2_fnum.c
index 876eb14..f51a39c 100644
--- a/source3/libsmb/cli_smb2_fnum.c
+++ b/source3/libsmb/cli_smb2_fnum.c
@@ -3143,3 +3143,68 @@ NTSTATUS cli_smb2_shadow_copy_data(TALLOC_CTX *mem_ctx,
 	TALLOC_FREE(frame);
 	return status;
 }
+
+/***************************************************************
+ Wrapper that allows SMB2 to truncate a file.
+ Synchronous only.
+***************************************************************/
+
+NTSTATUS cli_smb2_ftruncate(struct cli_state *cli,
+			uint16_t fnum,
+			uint64_t newsize)
+{
+	NTSTATUS status;
+	DATA_BLOB inbuf = data_blob_null;
+	struct smb2_hnd *ph = NULL;
+	TALLOC_CTX *frame = talloc_stackframe();
+
+	if (smbXcli_conn_has_async_calls(cli->conn)) {
+		/*
+		 * Can't use sync call while an async call is in flight
+		 */
+		status = NT_STATUS_INVALID_PARAMETER;
+		goto fail;
+	}
+
+	if (smbXcli_conn_protocol(cli->conn) < PROTOCOL_SMB2_02) {
+		status = NT_STATUS_INVALID_PARAMETER;
+		goto fail;
+	}
+
+	status = map_fnum_to_smb2_handle(cli,
+					fnum,
+					&ph);
+	if (!NT_STATUS_IS_OK(status)) {
+		goto fail;
+	}
+
+	inbuf = data_blob_talloc_zero(frame, 8);
+	if (inbuf.data == NULL) {
+		status = NT_STATUS_NO_MEMORY;
+		goto fail;
+	}
+
+	SBVAL(inbuf.data, 0, newsize);
+
+	/* setinfo on the handle with info_type SMB2_SETINFO_FILE (1),
+	   level 20 (SMB_FILE_END_OF_FILE_INFORMATION - 1000). */
+
+	status = smb2cli_set_info(cli->conn,
+				cli->timeout,
+				cli->smb2.session,
+				cli->smb2.tcon,
+				1, /* in_info_type */
+					/* in_file_info_class */
+				SMB_FILE_END_OF_FILE_INFORMATION - 1000,
+				&inbuf, /* in_input_buffer */
+				0, /* in_additional_info */
+				ph->fid_persistent,
+				ph->fid_volatile);
+
+  fail:
+
+	cli->raw_status = status;
+
+	TALLOC_FREE(frame);
+	return status;
+}
diff --git a/source3/libsmb/cli_smb2_fnum.h b/source3/libsmb/cli_smb2_fnum.h
index 0436c68..d8a517c 100644
--- a/source3/libsmb/cli_smb2_fnum.h
+++ b/source3/libsmb/cli_smb2_fnum.h
@@ -190,4 +190,7 @@ NTSTATUS cli_smb2_shadow_copy_data(TALLOC_CTX *mem_ctx,
 			bool get_names,
 			char ***pnames,
 			int *pnum_names);
+NTSTATUS cli_smb2_ftruncate(struct cli_state *cli,
+			uint16_t fnum,
+			uint64_t newsize);
 #endif /* __SMB2CLI_FNUM_H__ */
diff --git a/source3/libsmb/clifile.c b/source3/libsmb/clifile.c
index fca7c91..b8cdbca 100644
--- a/source3/libsmb/clifile.c
+++ b/source3/libsmb/clifile.c
@@ -2946,11 +2946,17 @@ NTSTATUS cli_ftruncate_recv(struct tevent_req *req)
 
 NTSTATUS cli_ftruncate(struct cli_state *cli, uint16_t fnum, uint64_t size)
 {
-	TALLOC_CTX *frame = talloc_stackframe();
+	TALLOC_CTX *frame = NULL;
 	struct tevent_context *ev = NULL;
 	struct tevent_req *req = NULL;
 	NTSTATUS status = NT_STATUS_OK;
 
+	if (smbXcli_conn_protocol(cli->conn) >= PROTOCOL_SMB2_02) {
+		return cli_smb2_ftruncate(cli, fnum, size);
+	}
+
+	frame = talloc_stackframe();
+
 	if (smbXcli_conn_has_async_calls(cli->conn)) {
 		/*
 		 * Can't use sync call while an async call is in flight
diff --git a/source3/modules/vfs_catia.c b/source3/modules/vfs_catia.c
index f4c77d9..56d6447 100644
--- a/source3/modules/vfs_catia.c
+++ b/source3/modules/vfs_catia.c
@@ -1114,6 +1114,1036 @@ catia_setxattr(vfs_handle_struct *handle, const char *path,
 	return ret;
 }
 
+static int catia_fstat(vfs_handle_struct *handle,
+		       files_struct *fsp,
+		       SMB_STRUCT_STAT *sbuf)
+{
+	char *fname = NULL;
+	char *tmp_fname = NULL;
+	char *base_fname = NULL;
+	char *tmp_base_fname = NULL;
+	int ret = -1;
+	NTSTATUS status;
+
+	status = catia_string_replace_allocate(handle->conn,
+					       fsp->fsp_name->base_name,
+					       &fname, vfs_translate_to_unix);
+	if (!NT_STATUS_IS_OK(status)) {
+		errno = map_errno_from_nt_status(status);
+		goto done;
+	}
+
+	if (fsp->base_fsp != NULL) {
+		status = catia_string_replace_allocate(
+			handle->conn,
+			fsp->base_fsp->fsp_name->base_name,
+			&base_fname, vfs_translate_to_unix);
+		if (!NT_STATUS_IS_OK(status)) {
+			errno = map_errno_from_nt_status(status);
+			goto done;
+		}
+
+		tmp_base_fname = fsp->base_fsp->fsp_name->base_name;
+		fsp->base_fsp->fsp_name->base_name = base_fname;
+	}
+
+	tmp_fname = fsp->fsp_name->base_name;
+	fsp->fsp_name->base_name = fname;
+
+	ret = SMB_VFS_NEXT_FSTAT(handle, fsp, sbuf);
+
+	fsp->fsp_name->base_name = tmp_fname;
+	if (fsp->base_fsp != NULL) {
+		fsp->base_fsp->fsp_name->base_name = tmp_base_fname;
+	}
+
+done:
+	TALLOC_FREE(fname);
+	TALLOC_FREE(base_fname);
+
+	return ret;
+}
+
+static ssize_t catia_pread(vfs_handle_struct *handle,
+			   files_struct *fsp, void *data,
+			   size_t n, off_t offset)
+{
+	char *fname = NULL;
+	char *tmp_fname = NULL;
+	char *base_fname = NULL;
+	char *tmp_base_fname = NULL;
+	int ret = -1;
+	NTSTATUS status;
+
+	status = catia_string_replace_allocate(handle->conn,
+					       fsp->fsp_name->base_name,
+					       &fname, vfs_translate_to_unix);
+	if (!NT_STATUS_IS_OK(status)) {
+		errno = map_errno_from_nt_status(status);
+		goto done;
+	}
+
+	if (fsp->base_fsp != NULL) {
+		status = catia_string_replace_allocate(
+			handle->conn,
+			fsp->base_fsp->fsp_name->base_name,
+			&base_fname, vfs_translate_to_unix);
+		if (!NT_STATUS_IS_OK(status)) {
+			errno = map_errno_from_nt_status(status);
+			goto done;
+		}
+
+		tmp_base_fname = fsp->base_fsp->fsp_name->base_name;
+		fsp->base_fsp->fsp_name->base_name = base_fname;
+	}
+
+	tmp_fname = fsp->fsp_name->base_name;
+	fsp->fsp_name->base_name = fname;
+
+	ret = SMB_VFS_NEXT_PREAD(handle, fsp, data, n, offset);
+
+	fsp->fsp_name->base_name = tmp_fname;
+	if (fsp->base_fsp != NULL) {
+		fsp->base_fsp->fsp_name->base_name = tmp_base_fname;
+	}
+
+done:
+	TALLOC_FREE(fname);
+	TALLOC_FREE(base_fname);
+
+	return ret;
+}
+
+static ssize_t catia_pwrite(vfs_handle_struct *handle,
+			    files_struct *fsp, const void *data,
+			    size_t n, off_t offset)
+{
+	char *fname = NULL;
+	char *tmp_fname = NULL;
+	char *base_fname = NULL;
+	char *tmp_base_fname = NULL;
+	int ret = -1;
+	NTSTATUS status;
+
+	status = catia_string_replace_allocate(handle->conn,
+					       fsp->fsp_name->base_name,
+					       &fname, vfs_translate_to_unix);
+	if (!NT_STATUS_IS_OK(status)) {
+		errno = map_errno_from_nt_status(status);
+		goto done;
+	}
+
+	if (fsp->base_fsp != NULL) {
+		status = catia_string_replace_allocate(
+			handle->conn,
+			fsp->base_fsp->fsp_name->base_name,
+			&base_fname, vfs_translate_to_unix);
+		if (!NT_STATUS_IS_OK(status)) {
+			errno = map_errno_from_nt_status(status);
+			goto done;
+		}
+
+		tmp_base_fname = fsp->base_fsp->fsp_name->base_name;
+		fsp->base_fsp->fsp_name->base_name = base_fname;
+	}
+
+	tmp_fname = fsp->fsp_name->base_name;
+	fsp->fsp_name->base_name = fname;
+
+	ret = SMB_VFS_NEXT_PWRITE(handle, fsp, data, n, offset);
+
+	fsp->fsp_name->base_name = tmp_fname;
+	if (fsp->base_fsp != NULL) {
+		fsp->base_fsp->fsp_name->base_name = tmp_base_fname;
+	}
+
+done:
+	TALLOC_FREE(fname);
+	TALLOC_FREE(base_fname);
+
+	return ret;


-- 
Samba Shared Repository



More information about the samba-cvs mailing list