1
0
mirror of https://github.com/samba-team/samba.git synced 2025-01-10 01:18:15 +03:00

tests: Test FSCTL_DELETE_REPARSE_POINT

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
This commit is contained in:
Volker Lendecke 2024-05-06 16:35:25 +02:00 committed by Jeremy Allison
parent d80a884f54
commit 97c79d47dd
2 changed files with 64 additions and 0 deletions

View File

@ -261,6 +261,69 @@ class ReparsePoints(samba.tests.libsmb.LibsmbTests):
conn.delete_on_close(fd1, 1)
conn.close(fd1)
def test_delete_reparse_point(self):
conn = self.connection()
filename = 'reparse'
self.clean_file(conn, filename)
fd = conn.create(
filename,
DesiredAccess=sec.SEC_FILE_WRITE_ATTRIBUTE,
CreateDisposition=libsmb.FILE_CREATE)
b = reparse_symlink.put(0x80000025, 0, b'asdfasdfasdfasdfasdfasdf')
conn.fsctl(fd, libsmb.FSCTL_SET_REPARSE_POINT, b, 0)
conn.close(fd)
(fd,cr,_) = conn.create_ex(
filename,
DesiredAccess=sec.SEC_FILE_WRITE_ATTRIBUTE|sec.SEC_STD_DELETE,
CreateOptions=libsmb.FILE_OPEN_REPARSE_POINT,
CreateDisposition=libsmb.FILE_OPEN)
self.assertEqual(cr['file_attributes'] &
libsmb.FILE_ATTRIBUTE_REPARSE_POINT,
libsmb.FILE_ATTRIBUTE_REPARSE_POINT)
b = reparse_symlink.put(0x80000026, 0, b'')
with self.assertRaises(NTSTATUSError) as e:
conn.fsctl(fd, libsmb.FSCTL_DELETE_REPARSE_POINT, b, 0)
self.assertEqual(e.exception.args[0],
ntstatus.NT_STATUS_IO_REPARSE_TAG_MISMATCH)
b = reparse_symlink.put(0x80000026, 0, b' ')
with self.assertRaises(NTSTATUSError) as e:
conn.fsctl(fd, libsmb.FSCTL_DELETE_REPARSE_POINT, b, 0)
self.assertEqual(e.exception.args[0],
ntstatus.NT_STATUS_IO_REPARSE_DATA_INVALID)
b = reparse_symlink.put(0x80000025, 0, b' ')
with self.assertRaises(NTSTATUSError) as e:
conn.fsctl(fd, libsmb.FSCTL_DELETE_REPARSE_POINT, b, 0)
self.assertEqual(e.exception.args[0],
ntstatus.NT_STATUS_IO_REPARSE_DATA_INVALID)
b = reparse_symlink.put(0x80000025, 0, b'')
conn.fsctl(fd, libsmb.FSCTL_DELETE_REPARSE_POINT, b, 0)
with self.assertRaises(NTSTATUSError) as e:
conn.fsctl(fd, libsmb.FSCTL_DELETE_REPARSE_POINT, b, 0)
self.assertEqual(e.exception.args[0],
ntstatus.NT_STATUS_NOT_A_REPARSE_POINT)
conn.close(fd)
(fd,cr,_) = conn.create_ex(
filename,
DesiredAccess=sec.SEC_FILE_WRITE_ATTRIBUTE|sec.SEC_STD_DELETE,
CreateDisposition=libsmb.FILE_OPEN)
self.assertEqual(cr['file_attributes'] &
libsmb.FILE_ATTRIBUTE_REPARSE_POINT,
0)
conn.delete_on_close(fd, 1)
conn.close(fd)
if __name__ == '__main__':
import unittest
unittest.main()

View File

@ -1,2 +1,3 @@
^samba.tests.reparsepoints.samba.tests.reparsepoints.ReparsePoints.test_create_reparse_directory
^samba.tests.reparsepoints.samba.tests.reparsepoints.ReparsePoints.test_create_reparse_nonempty_directory
^samba.tests.reparsepoints.samba.tests.reparsepoints.ReparsePoints.test_delete_reparse_point