From dc9f29e5c35982e7ce2cb5135ce906e9960579af Mon Sep 17 00:00:00 2001 From: Douglas Bagnall Date: Thu, 1 Sep 2022 01:18:12 +0000 Subject: [PATCH] pysmbd: set_nt_acl() can raise FileNotFoundError rather than an NTStatusError, which is harder to decipher, and which carries less information (namely, not the name of the problematic file). BUG: https://bugzilla.samba.org/show_bug.cgi?id=14937 Signed-off-by: Douglas Bagnall Reviewed-by: Andrew Bartlett --- source3/smbd/pysmbd.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/source3/smbd/pysmbd.c b/source3/smbd/pysmbd.c index e53d7fd2d58..af8a08d7c65 100644 --- a/source3/smbd/pysmbd.c +++ b/source3/smbd/pysmbd.c @@ -811,6 +811,14 @@ static PyObject *py_smbd_set_nt_acl(PyObject *self, PyObject *args, PyObject *kw status = set_nt_acl_conn(fname, security_info_sent, sd, conn); TALLOC_FREE(frame); if (NT_STATUS_IS_ERR(status)) { + if (NT_STATUS_EQUAL(status, NT_STATUS_OBJECT_NAME_NOT_FOUND)) { + /* + * This will show up as a FileNotFoundError in python. + */ + PyErr_SetFromErrnoWithFilename(PyExc_OSError, fname); + } else { + PyErr_SetNTSTATUS(status); + } return NULL; }