summaryrefslogtreecommitdiff
path: root/source3/libsmb
diff options
context:
space:
mode:
authorTim Beale <timbeale@catalyst.net.nz>2018-12-04 16:25:10 +1300
committerTim Beale <timbeale@samba.org>2019-01-07 01:23:08 +0100
commit6bcd64a4f14332de3259204b78c5b68988e98b6f (patch)
treeb45b1b918c8da377f178dea83de961f834e3b330 /source3/libsmb
parent5f1ed29d6b7388e5ce0ad0023daa39cb8c4cb4dc (diff)
downloadsamba-6bcd64a4f14332de3259204b78c5b68988e98b6f.tar.gz
s3:pylibsmb: Make s3 and s4 listings return the same dict
Make the python dictionary generated by the s3 .list() use the same keys as the current source4 dict. The reason for using the source4 dict is that other python code depends on these keys (e.g. ntacls.py), whereas the source3 API is currently unused. 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>
Diffstat (limited to 'source3/libsmb')
-rw-r--r--source3/libsmb/pylibsmb.c20
1 files changed, 17 insertions, 3 deletions
diff --git a/source3/libsmb/pylibsmb.c b/source3/libsmb/pylibsmb.c
index 15c051f40b5..64da3891783 100644
--- a/source3/libsmb/pylibsmb.c
+++ b/source3/libsmb/pylibsmb.c
@@ -912,9 +912,18 @@ static NTSTATUS list_helper(const char *mntpoint, struct file_info *finfo,
return NT_STATUS_OK;
}
- file = Py_BuildValue("{s:s,s:i}",
+ /*
+ * Build a dictionary representing the file info.
+ * Note: Windows does not always return short_name (so it may be None)
+ */
+ file = Py_BuildValue("{s:s,s:i,s:s,s:O,s:l}",
"name", finfo->name,
- "mode", (int)finfo->mode);
+ "attrib", (int)finfo->mode,
+ "short_name", finfo->short_name,
+ "size", PyLong_FromUnsignedLongLong(finfo->size),
+ "mtime",
+ convert_timespec_to_time_t(finfo->mtime_ts));
+
if (file == NULL) {
return NT_STATUS_NO_MEMORY;
}
@@ -1184,7 +1193,12 @@ static PyMethodDef py_cli_state_methods[] = {
"directory contents as a dictionary\n"
"\t\tDEFAULT_ATTRS: FILE_ATTRIBUTE_SYSTEM | "
"FILE_ATTRIBUTE_DIRECTORY | FILE_ATTRIBUTE_ARCHIVE\n\n"
- "\t\tList contents of a directory." },
+ "\t\tList contents of a directory. The keys are, \n"
+ "\t\t\tname: Long name of the directory item\n"
+ "\t\t\tshort_name: Short name of the directory item\n"
+ "\t\t\tsize: File size in bytes\n"
+ "\t\t\tattrib: Attributes\n"
+ "\t\t\tmtime: Modification time\n" },
{ "get_oplock_break", (PyCFunction)py_cli_get_oplock_break,
METH_VARARGS, "Wait for an oplock break" },
{ "unlink", (PyCFunction)py_smb_unlink,