s3:pylibsmb: Add flags used by .list() to SMB Py bindings
authorTim Beale <timbeale@catalyst.net.nz>
Thu, 13 Dec 2018 21:30:38 +0000 (10:30 +1300)
committerTim Beale <timbeale@samba.org>
Mon, 7 Jan 2019 21:48:28 +0000 (22:48 +0100)
These flags are exposed by the s4 code. Python code that calls .list()
checks the returned attribs/mode for the directory listing, e.g. to work
out whether something is a sub-directory:

  if item['attrib'] & libsmb.FILE_ATTRIBUTE_DIRECTORY...

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

Signed-off-by: Tim Beale <timbeale@catalyst.net.nz>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
source3/libsmb/pylibsmb.c

index 1c1216f..4322c2b 100644 (file)
@@ -1565,5 +1565,25 @@ MODULE_INIT_FUNC(libsmb)
        }
        Py_INCREF(&py_cli_state_type);
        PyModule_AddObject(m, "Conn", (PyObject *)&py_cli_state_type);
+
+#define ADD_FLAGS(val) PyModule_AddObject(m, #val, PyInt_FromLong(val))
+
+       ADD_FLAGS(FILE_ATTRIBUTE_READONLY);
+       ADD_FLAGS(FILE_ATTRIBUTE_HIDDEN);
+       ADD_FLAGS(FILE_ATTRIBUTE_SYSTEM);
+       ADD_FLAGS(FILE_ATTRIBUTE_VOLUME);
+       ADD_FLAGS(FILE_ATTRIBUTE_DIRECTORY);
+       ADD_FLAGS(FILE_ATTRIBUTE_ARCHIVE);
+       ADD_FLAGS(FILE_ATTRIBUTE_DEVICE);
+       ADD_FLAGS(FILE_ATTRIBUTE_NORMAL);
+       ADD_FLAGS(FILE_ATTRIBUTE_TEMPORARY);
+       ADD_FLAGS(FILE_ATTRIBUTE_SPARSE);
+       ADD_FLAGS(FILE_ATTRIBUTE_REPARSE_POINT);
+       ADD_FLAGS(FILE_ATTRIBUTE_COMPRESSED);
+       ADD_FLAGS(FILE_ATTRIBUTE_OFFLINE);
+       ADD_FLAGS(FILE_ATTRIBUTE_NONINDEXED);
+       ADD_FLAGS(FILE_ATTRIBUTE_ENCRYPTED);
+       ADD_FLAGS(FILE_ATTRIBUTE_ALL_MASK);
+
        return m;
 }