From 6bcd64a4f14332de3259204b78c5b68988e98b6f Mon Sep 17 00:00:00 2001 From: Tim Beale Date: Tue, 4 Dec 2018 16:25:10 +1300 Subject: 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 Reviewed-by: Douglas Bagnall --- source3/libsmb/pylibsmb.c | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) (limited to 'source3/libsmb') 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, -- cgit v1.2.1