s3:pylibsmb: Don't return '.'/'..' in .list()
authorTim Beale <timbeale@catalyst.net.nz>
Tue, 4 Dec 2018 03:03:35 +0000 (16:03 +1300)
committerTim Beale <timbeale@samba.org>
Mon, 7 Jan 2019 00:23:07 +0000 (01:23 +0100)
The source4 .list() API wasn't doing this. This makes source3 and source4
have *almost* equivalent functionality, so we can start usign the
source3 API in the tests.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=13676

Signed-off-by: Tim Beale <timbeale@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
python/samba/tests/smb.py
source3/libsmb/pylibsmb.c

index 497f57d8e65fa6f9f809637b5ba44448509e8f06..b951a4bc38882f7c4ae0da7621b98a93a528583a 100644 (file)
@@ -64,7 +64,7 @@ class SMBTests(samba.tests.TestCase):
 
     def test_list(self):
         # check a basic listing returns the items we expect
-        ls = [f['name'] for f in self.conn.list(addom)]
+        ls = [f['name'] for f in self.smb_conn.list(addom)]
         self.assertIn('scripts', ls,
                       msg='"scripts" directory not found in sysvol')
         self.assertIn('Policies', ls,
@@ -75,11 +75,11 @@ class SMBTests(samba.tests.TestCase):
                          msg='Current dir (.) found in directory listing')
 
         # using a '*' mask should be the same as using no mask
-        ls_wildcard = [f['name'] for f in self.conn.list(addom, "*")]
+        ls_wildcard = [f['name'] for f in self.smb_conn.list(addom, "*")]
         self.assertEqual(ls, ls_wildcard)
 
         # applying a mask should only return items that match that mask
-        ls_pol = [f['name'] for f in self.conn.list(addom, "Pol*")]
+        ls_pol = [f['name'] for f in self.smb_conn.list(addom, "Pol*")]
         expected = ["Policies"]
         self.assertEqual(ls_pol, expected)
 
index 2b5c8dce83b9d87a03e63f86d79ed315ced4ed01..15c051f40b5541483d7be724f8e1158eaa8e1d14 100644 (file)
@@ -907,6 +907,11 @@ static NTSTATUS list_helper(const char *mntpoint, struct file_info *finfo,
        PyObject *file = NULL;
        int ret;
 
+       /* suppress '.' and '..' in the results we return */
+       if (ISDOT(finfo->name) || ISDOTDOT(finfo->name)) {
+               return NT_STATUS_OK;
+       }
+
        file = Py_BuildValue("{s:s,s:i}",
                             "name", finfo->name,
                             "mode", (int)finfo->mode);