From: Douglas Bagnall Date: Wed, 31 Aug 2022 23:25:26 +0000 (+1200) Subject: pysmbd: get_nt_acl() raises FileNotFoundError if appropriate X-Git-Tag: talloc-2.4.0~1147 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=1b4938c3b1afc8600d693ef92b6944b18e449415;p=thirdparty%2Fsamba.git pysmbd: get_nt_acl() raises FileNotFoundError if appropriate 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 --- diff --git a/source3/smbd/pysmbd.c b/source3/smbd/pysmbd.c index e7bd8b8f622..e53d7fd2d58 100644 --- a/source3/smbd/pysmbd.c +++ b/source3/smbd/pysmbd.c @@ -879,7 +879,16 @@ static PyObject *py_smbd_get_nt_acl(PyObject *self, PyObject *args, PyObject *kw status = get_nt_acl_conn(frame, fname, conn, security_info_wanted, &sd); if (NT_STATUS_IS_ERR(status)) { - PyErr_SetNTSTATUS(status); + if (NT_STATUS_EQUAL(status, NT_STATUS_OBJECT_NAME_NOT_FOUND)) { + /* + * This will show up as a FileNotFoundError in python, + * from which samba-tool can at least produce a short + * message containing the problematic filename. + */ + PyErr_SetFromErrnoWithFilename(PyExc_OSError, fname); + } else { + PyErr_SetNTSTATUS(status); + } TALLOC_FREE(frame); return NULL; }