[SCM] Samba Shared Repository - branch master updated

Jeremy Allison jra at samba.org
Fri Jul 12 21:37:01 UTC 2024


The branch, master has been updated
       via  bbe2c82f620 smbd: Show blk and chr devices as nfs reparse points
       via  cd7889deb87 smbd: Report sockets as NFS style reparse points
       via  3326ffa8d02 smbd: Factor out fsctl_get_reparse_point_int
       via  51ded0ae7ce smbd: Show sockets as reparse points in fdos_mode
       via  1b9f1690c47 tests: Sockets should be shown as NFS reparse points
       via  fb7a7cd73ba tests: Factor out do_test_nfs_reparse
       via  57b6a8539f5 smbd: Report FIFOs as NFS style reparse points
       via  b311f4eca3b smbd: Turn an if-statement getting reparse points into a switch
       via  a03f339e96c smbd: Show fifos as reparse points in fdos_mode
       via  f1440cebf2d smbd: Turn file type handling in fdos_mode into a switch
       via  e4e5242b27e smbd: Add DBG to return tag for SMB_FILE_ATTRIBUTE_TAG_INFORMATION
       via  597f785620e tests: FIFOs should be shown as NFS reparse points
       via  4a294d5ab03 tests: Run reparsepoint tests in fileserver_smb1
       via  e76b7578dbb vfs: xattr calls give EBADF for sockets
      from  e450ff685b5 pidl: Wireshark: Another C99 type conversion

https://git.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit bbe2c82f620e692272f6292ff86b4a2167e0d6c4
Author: Volker Lendecke <vl at samba.org>
Date:   Mon Jul 8 11:23:14 2024 +0200

    smbd: Show blk and chr devices as nfs reparse points
    
    Can't test these in selftest, we can't create devices and I don't want
    us to depend on /dev to exist. Tested manually on a system where
    /dev/null exists:
    
    Try "help" to get a list of possible commands.
    smb: \> allinfo null
    altname: null
    create_time:    Fri Jun 21 02:45:59 PM 2024 CEST
    access_time:    Fri Jun 21 02:45:59 PM 2024 CEST
    write_time:     Fri Jun 21 02:45:59 PM 2024 CEST
    change_time:    Fri Jun 21 02:45:59 PM 2024 CEST
    attributes:  (480)
    stream: [::$DATA], 0 bytes
    0x80000014 (IO_REPARSE_TAG_NFS)
     0x524843 (NFS_SPECFILE_CHR)
     1/3
    smb: \>
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    
    Autobuild-User(master): Jeremy Allison <jra at samba.org>
    Autobuild-Date(master): Fri Jul 12 21:36:16 UTC 2024 on atb-devel-224

commit cd7889deb8713f03d493acb93400270357e6f65e
Author: Volker Lendecke <vl at samba.org>
Date:   Sun Jul 7 20:39:30 2024 +0200

    smbd: Report sockets as NFS style reparse points
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 3326ffa8d02b04abf91d1b5a03f18fbaf8fde633
Author: Volker Lendecke <vl at samba.org>
Date:   Sun Jul 7 20:37:49 2024 +0200

    smbd: Factor out fsctl_get_reparse_point_int
    
    We'll use it for the other special files as well
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 51ded0ae7ceeaad893fc6f691a9c22db0780eed3
Author: Volker Lendecke <vl at samba.org>
Date:   Mon Jul 8 10:25:05 2024 +0200

    smbd: Show sockets as reparse points in fdos_mode
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 1b9f1690c479ac3ae6540d573942391399a41e7f
Author: Volker Lendecke <vl at samba.org>
Date:   Sun Jul 7 20:28:59 2024 +0200

    tests: Sockets should be shown as NFS reparse points
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit fb7a7cd73ba44f72f412128033ae061382b1bd87
Author: Volker Lendecke <vl at samba.org>
Date:   Sun Jul 7 20:21:12 2024 +0200

    tests: Factor out do_test_nfs_reparse
    
    Will be used for sockets next
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 57b6a8539f570195b1b33e2757e4c93bd9666359
Author: Volker Lendecke <vl at samba.org>
Date:   Fri Jul 5 17:58:55 2024 +0200

    smbd: Report FIFOs as NFS style reparse points
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit b311f4eca3b6da65ef9527597cab5965bb6c683c
Author: Volker Lendecke <vl at samba.org>
Date:   Fri Jul 5 17:31:19 2024 +0200

    smbd: Turn an if-statement getting reparse points into a switch
    
    There will be more cases soon
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit a03f339e96c9cb07f216a578a792a71067afaf4e
Author: Volker Lendecke <vl at samba.org>
Date:   Fri Jul 5 17:57:44 2024 +0200

    smbd: Show fifos as reparse points in fdos_mode
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit f1440cebf2d038f366e844c1427f2b47c239c455
Author: Volker Lendecke <vl at samba.org>
Date:   Fri Jul 5 17:56:40 2024 +0200

    smbd: Turn file type handling in fdos_mode into a switch
    
    There will be more cases soon
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit e4e5242b27e5b8c160ddfb90237cc51389f012a4
Author: Volker Lendecke <vl at samba.org>
Date:   Fri Jul 5 17:30:49 2024 +0200

    smbd: Add DBG to return tag for SMB_FILE_ATTRIBUTE_TAG_INFORMATION
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 597f785620eea3ed26e9ea2f77bb0fc119f6cfad
Author: Volker Lendecke <vl at samba.org>
Date:   Mon Jun 17 12:45:18 2024 +0200

    tests: FIFOs should be shown as NFS reparse points
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 4a294d5ab03f199c520c337372d0df4a798c40e0
Author: Volker Lendecke <vl at samba.org>
Date:   Fri Jul 5 18:03:10 2024 +0200

    tests: Run reparsepoint tests in fileserver_smb1
    
    We'll need posix extensions soon
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit e76b7578dbbc6c9f2f7b115daea224abc2cbb536
Author: Volker Lendecke <vl at samba.org>
Date:   Mon Jul 8 19:37:01 2024 +0200

    vfs: xattr calls give EBADF for sockets
    
    This is required for make test with disabled O_PATH
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

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

Summary of changes:
 python/samba/tests/reparsepoints.py |  44 +++++++++++++
 source3/modules/util_reparse.c      | 119 +++++++++++++++++++++++++++++++++++-
 source3/modules/vfs_fake_acls.c     |  10 +--
 source3/selftest/tests.py           |   2 +-
 source3/smbd/dosmode.c              |  12 +++-
 source3/smbd/smb2_trans2.c          |   2 +
 6 files changed, 181 insertions(+), 8 deletions(-)


Changeset truncated at 500 lines:

diff --git a/python/samba/tests/reparsepoints.py b/python/samba/tests/reparsepoints.py
index bf96def422d..a8d506d48d6 100644
--- a/python/samba/tests/reparsepoints.py
+++ b/python/samba/tests/reparsepoints.py
@@ -20,6 +20,7 @@ from samba import (ntstatus,NTSTATUSError)
 from samba.dcerpc import security as sec
 from samba import reparse_symlink
 import samba.tests.libsmb
+import stat
 
 class ReparsePoints(samba.tests.libsmb.LibsmbTests):
 
@@ -36,6 +37,19 @@ class ReparsePoints(samba.tests.libsmb.LibsmbTests):
             force_smb1=smb1)
         return conn
 
+    def connection_posix(self):
+        share = samba.tests.env_get_var_value("SHARENAME", allow_missing=True)
+        if not share:
+            share = "posix_share"
+        conn = libsmb.Conn(
+            self.server_ip,
+            share,
+            self.lp,
+            self.creds,
+            force_smb1=True)
+        conn.smb1_posix()
+        return conn
+
     def clean_file(self, conn, filename):
         try:
             conn.unlink(filename)
@@ -368,6 +382,36 @@ class ReparsePoints(samba.tests.libsmb.LibsmbTests):
         conn.delete_on_close(fd, 1)
         conn.close(fd)
 
+    def do_test_nfs_reparse(self, filename, filetype, nfstype):
+        """Test special file reparse tag"""
+        smb2 = self.connection()
+        smb1 = self.connection_posix()
+
+        self.clean_file(smb2, filename)
+        smb1.mknod(filename, filetype | 0o755)
+
+        fd = smb2.create(
+            filename,
+            DesiredAccess=sec.SEC_FILE_READ_ATTRIBUTE|sec.SEC_STD_DELETE,
+            CreateOptions=libsmb.FILE_OPEN_REPARSE_POINT,
+            CreateDisposition=libsmb.FILE_OPEN)
+        smb2.delete_on_close(fd, 1)
+
+        info = smb2.qfileinfo(fd, libsmb.FSCC_FILE_ATTRIBUTE_TAG_INFORMATION);
+        self.assertEqual(info['tag'], libsmb.IO_REPARSE_TAG_NFS)
+
+        reparse = smb2.fsctl(fd, libsmb.FSCTL_GET_REPARSE_POINT, b'', 1024)
+        (tag, ) = reparse_symlink.get(reparse)
+        self.assertEqual(tag, nfstype)
+
+    def test_fifo_reparse(self):
+        """Test FIFO reparse tag"""
+        self.do_test_nfs_reparse('fifo', stat.S_IFIFO, 'NFS_SPECFILE_FIFO')
+
+    def test_sock_reparse(self):
+        """Test SOCK reparse tag"""
+        self.do_test_nfs_reparse('sock', stat.S_IFSOCK, 'NFS_SPECFILE_SOCK')
+
 if __name__ == '__main__':
     import unittest
     unittest.main()
diff --git a/source3/modules/util_reparse.c b/source3/modules/util_reparse.c
index fce3603e780..2694410be4f 100644
--- a/source3/modules/util_reparse.c
+++ b/source3/modules/util_reparse.c
@@ -73,6 +73,87 @@ fail:
 	return status;
 }
 
+static NTSTATUS fsctl_get_reparse_point_int(
+	struct files_struct *fsp,
+	const struct reparse_data_buffer *reparse_data,
+	TALLOC_CTX *ctx,
+	uint8_t **_out_data,
+	uint32_t max_out_len,
+	uint32_t *_out_len)
+{
+	uint8_t *out_data = NULL;
+	ssize_t out_len;
+
+	out_len = reparse_data_buffer_marshall(reparse_data, NULL, 0);
+	if (out_len == -1) {
+		return NT_STATUS_INSUFFICIENT_RESOURCES;
+	}
+	if (max_out_len < out_len) {
+		return NT_STATUS_BUFFER_TOO_SMALL;
+	}
+
+	out_data = talloc_array(ctx, uint8_t, out_len);
+	if (out_data == NULL) {
+		return NT_STATUS_NO_MEMORY;
+	}
+
+	reparse_data_buffer_marshall(reparse_data, out_data, out_len);
+
+	*_out_data = out_data;
+	*_out_len = out_len;
+
+	return NT_STATUS_OK;
+}
+
+static NTSTATUS fsctl_get_reparse_point_fifo(struct files_struct *fsp,
+					     TALLOC_CTX *ctx,
+					     uint8_t **_out_data,
+					     uint32_t max_out_len,
+					     uint32_t *_out_len)
+{
+	struct reparse_data_buffer reparse_data = {
+		.tag = IO_REPARSE_TAG_NFS,
+		.parsed.nfs.type = NFS_SPECFILE_FIFO,
+	};
+
+	return fsctl_get_reparse_point_int(
+		fsp, &reparse_data, ctx, _out_data, max_out_len, _out_len);
+}
+
+static NTSTATUS fsctl_get_reparse_point_sock(struct files_struct *fsp,
+					     TALLOC_CTX *ctx,
+					     uint8_t **_out_data,
+					     uint32_t max_out_len,
+					     uint32_t *_out_len)
+{
+	struct reparse_data_buffer reparse_data = {
+		.tag = IO_REPARSE_TAG_NFS,
+		.parsed.nfs.type = NFS_SPECFILE_SOCK,
+	};
+
+	return fsctl_get_reparse_point_int(
+		fsp, &reparse_data, ctx, _out_data, max_out_len, _out_len);
+}
+
+static NTSTATUS fsctl_get_reparse_point_dev(struct files_struct *fsp,
+					    uint64_t nfs_type,
+					    dev_t rdev,
+					    TALLOC_CTX *ctx,
+					    uint8_t **_out_data,
+					    uint32_t max_out_len,
+					    uint32_t *_out_len)
+{
+	struct reparse_data_buffer reparse_data = {
+		.tag = IO_REPARSE_TAG_NFS,
+		.parsed.nfs.type = nfs_type,
+		.parsed.nfs.data.dev.major = unix_dev_major(rdev),
+		.parsed.nfs.data.dev.minor = unix_dev_minor(rdev),
+	};
+
+	return fsctl_get_reparse_point_int(
+		fsp, &reparse_data, ctx, _out_data, max_out_len, _out_len);
+}
+
 NTSTATUS fsctl_get_reparse_point(struct files_struct *fsp,
 				 TALLOC_CTX *mem_ctx,
 				 uint32_t *_reparse_tag,
@@ -93,10 +174,46 @@ NTSTATUS fsctl_get_reparse_point(struct files_struct *fsp,
 		return NT_STATUS_NOT_A_REPARSE_POINT;
 	}
 
-	if (S_ISREG(fsp->fsp_name->st.st_ex_mode)) {
+	switch (fsp->fsp_name->st.st_ex_mode & S_IFMT) {
+	case S_IFREG:
 		DBG_DEBUG("%s is a regular file\n", fsp_str_dbg(fsp));
 		status = fsctl_get_reparse_point_reg(
 			fsp, mem_ctx, &out_data, max_out_len, &out_len);
+		break;
+	case S_IFIFO:
+		DBG_DEBUG("%s is a fifo\n", fsp_str_dbg(fsp));
+		status = fsctl_get_reparse_point_fifo(
+			fsp, mem_ctx, &out_data, max_out_len, &out_len);
+		break;
+	case S_IFSOCK:
+		DBG_DEBUG("%s is a socket\n", fsp_str_dbg(fsp));
+		status = fsctl_get_reparse_point_sock(
+			fsp, mem_ctx, &out_data, max_out_len, &out_len);
+		break;
+	case S_IFBLK:
+		DBG_DEBUG("%s is a block device\n", fsp_str_dbg(fsp));
+		status = fsctl_get_reparse_point_dev(
+			fsp,
+			NFS_SPECFILE_BLK,
+			fsp->fsp_name->st.st_ex_rdev,
+			mem_ctx,
+			&out_data,
+			max_out_len,
+			&out_len);
+		break;
+	case S_IFCHR:
+		DBG_DEBUG("%s is a character device\n", fsp_str_dbg(fsp));
+		status = fsctl_get_reparse_point_dev(
+			fsp,
+			NFS_SPECFILE_CHR,
+			fsp->fsp_name->st.st_ex_rdev,
+			mem_ctx,
+			&out_data,
+			max_out_len,
+			&out_len);
+		break;
+	default:
+		break;
 	}
 
 	if (!NT_STATUS_IS_OK(status)) {
diff --git a/source3/modules/vfs_fake_acls.c b/source3/modules/vfs_fake_acls.c
index fefe6c5483e..69cae8ce21d 100644
--- a/source3/modules/vfs_fake_acls.c
+++ b/source3/modules/vfs_fake_acls.c
@@ -47,7 +47,7 @@ static int fake_acls_fuid(vfs_handle_struct *handle,
 	uint8_t uid_buf[4];
 
 	size = SMB_VFS_NEXT_FGETXATTR(handle, fsp, FAKE_UID, uid_buf, sizeof(uid_buf));
-	if (size == -1 && errno == ENOATTR) {
+	if (size == -1 && ((errno == ENOATTR) || (errno == EBADF))) {
 		return 0;
 	}
 	if (size != 4) {
@@ -65,7 +65,7 @@ static int fake_acls_fgid(vfs_handle_struct *handle,
 	uint8_t gid_buf[4];
 
 	size = SMB_VFS_NEXT_FGETXATTR(handle, fsp, FAKE_GID, gid_buf, sizeof(gid_buf));
-	if (size == -1 && errno == ENOATTR) {
+	if (size == -1 && ((errno == ENOATTR) || (errno == EBADF))) {
 		return 0;
 	}
 	if (size != 4) {
@@ -335,7 +335,7 @@ static SMB_ACL_T fake_acls_sys_acl_get_fd(struct vfs_handle_struct *handle,
 		length = SMB_VFS_NEXT_FGETXATTR(handle, fsp, name, blob.data, blob.length);
 		blob.length = length;
 	} while (length == -1 && errno == ERANGE);
-	if (length == -1 && errno == ENOATTR) {
+	if (length == -1 && ((errno == ENOATTR) || (errno == EBADF))) {
 		TALLOC_FREE(frame);
 		return NULL;
 	}
@@ -391,7 +391,7 @@ static int fake_acls_sys_acl_delete_def_fd(vfs_handle_struct *handle,
 	}
 
 	ret = SMB_VFS_NEXT_FREMOVEXATTR(handle, fsp, name);
-	if (ret == -1 && errno == ENOATTR) {
+	if (ret == -1 && ((errno == ENOATTR) || (errno == EBADF))) {
 		ret = 0;
 		errno = 0;
 	}
@@ -628,7 +628,7 @@ static int fake_acls_fchmod(vfs_handle_struct *handle,
 				talloc_tos());
 	if (the_acl == NULL) {
 		TALLOC_FREE(frame);
-		if (errno == ENOATTR) {
+		if (((errno == ENOATTR) || (errno == EBADF))) {
 			/* No ACL on this file. Just passthrough. */
 			return 0;
 		}
diff --git a/source3/selftest/tests.py b/source3/selftest/tests.py
index 773c8598eb3..790551245ac 100755
--- a/source3/selftest/tests.py
+++ b/source3/selftest/tests.py
@@ -1927,6 +1927,6 @@ if have_cluster_support:
              "-N 1000 -o 2000"])
 
 planpythontestsuite("fileserver_smb1", "samba.tests.smb3unix")
-planpythontestsuite("fileserver", "samba.tests.reparsepoints")
+planpythontestsuite("fileserver_smb1", "samba.tests.reparsepoints")
 planpythontestsuite("fileserver_smb1", "samba.tests.smb2symlink")
 planpythontestsuite("fileserver_smb1", "samba.tests.smb1posix")
diff --git a/source3/smbd/dosmode.c b/source3/smbd/dosmode.c
index d7999775c26..c5eeb68f2c6 100644
--- a/source3/smbd/dosmode.c
+++ b/source3/smbd/dosmode.c
@@ -713,8 +713,18 @@ uint32_t fdos_mode(struct files_struct *fsp)
 		return 0;
 	}
 
-	if (S_ISLNK(fsp->fsp_name->st.st_ex_mode)) {
+	switch (fsp->fsp_name->st.st_ex_mode & S_IFMT) {
+	case S_IFLNK:
 		return FILE_ATTRIBUTE_NORMAL;
+		break;
+	case S_IFIFO:
+	case S_IFSOCK:
+	case S_IFBLK:
+	case S_IFCHR:
+		return FILE_ATTRIBUTE_NORMAL | FILE_ATTRIBUTE_REPARSE_POINT;
+		break;
+	default:
+		break;
 	}
 
 	if (fsp->fsp_name->st.cached_dos_attributes != FILE_ATTRIBUTE_INVALID) {
diff --git a/source3/smbd/smb2_trans2.c b/source3/smbd/smb2_trans2.c
index cb7390133fe..b57cb295a7c 100644
--- a/source3/smbd/smb2_trans2.c
+++ b/source3/smbd/smb2_trans2.c
@@ -3690,6 +3690,8 @@ NTSTATUS smbd_do_qfilepathinfo(connection_struct *conn,
 
 			(void)fsctl_get_reparse_tag(fsp, &tag);
 
+			DBG_DEBUG("tag=%"PRIu32"\n", tag);
+
 			SIVAL(pdata, 0, mode);
 			SIVAL(pdata, 4, tag);
 			data_size = 8;


-- 
Samba Shared Repository



More information about the samba-cvs mailing list