1
0
mirror of https://github.com/samba-team/samba.git synced 2025-02-02 09:47:23 +03:00

pysmbd: add "session_info" arg tp py_smbd_create_file()

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
This commit is contained in:
Ralph Boehme 2019-12-17 14:58:57 +01:00
parent 7121d47579
commit ee5bf29662
3 changed files with 25 additions and 5 deletions

View File

@ -573,7 +573,7 @@ def backup_offline(src_service_path, dest_tarfile_path, samdb_conn, smb_conf_pat
src = os.path.join(dirpath, filename)
dst = os.path.join(dst_dirpath, filename)
# create an empty file with metadata
smbd.create_file(dst, service)
smbd.create_file(dst, session_info, service)
ntacl_sddl_str = ntacls_helper.getntacl(src, session_info, as_sddl=True)
_create_ntacl_file(dst, ntacl_sddl_str)
@ -637,7 +637,7 @@ def backup_restore(src_tarfile_path, dst_service_path, samdb_conn, smb_conf_path
dst = os.path.join(dst_dirpath, filename)
if not os.path.isfile(dst):
# dst must be absolute path for smbd API
smbd.create_file(dst, service)
smbd.create_file(dst, session_info, service)
ntacl_sddl_str = _read_ntacl_file(src)
if ntacl_sddl_str:

View File

@ -126,7 +126,7 @@ class NtaclsBackupRestoreTests(SmbdBaseTests):
"""
filepath = os.path.join(self.service_root, 'a-file')
smbd.create_file(filepath, self.service)
smbd.create_file(filepath, system_session_unix(), self.service)
self.assertTrue(os.path.isfile(filepath))
mode = os.stat(filepath).st_mode

View File

@ -1059,10 +1059,13 @@ static PyObject *py_smbd_create_file(PyObject *self, PyObject *args, PyObject *k
{
const char * const kwnames[] = {
"fname",
"session_info",
"service",
NULL
};
char *fname, *service = NULL;
PyObject *py_session = Py_None;
struct auth_session_info *session_info = NULL;
TALLOC_CTX *frame = talloc_stackframe();
struct connection_struct *conn = NULL;
struct files_struct *fsp = NULL;
@ -1070,16 +1073,33 @@ static PyObject *py_smbd_create_file(PyObject *self, PyObject *args, PyObject *k
if (!PyArg_ParseTupleAndKeywords(args,
kwargs,
"s|z",
"sO|z",
discard_const_p(char *,
kwnames),
&fname,
&py_session,
&service)) {
TALLOC_FREE(frame);
return NULL;
}
conn = get_conn_tos(service, NULL);
if (!py_check_dcerpc_type(py_session,
"samba.dcerpc.auth",
"session_info")) {
TALLOC_FREE(frame);
return NULL;
}
session_info = pytalloc_get_type(py_session,
struct auth_session_info);
if (session_info == NULL) {
PyErr_Format(PyExc_TypeError,
"Expected auth_session_info for session_info argument got %s",
pytalloc_get_name(py_session));
TALLOC_FREE(frame);
return NULL;
}
conn = get_conn_tos(service, session_info);
if (!conn) {
TALLOC_FREE(frame);
return NULL;