#include "replace.h"
#include "python/modules.h"
#include "python/py3compat.h"
-#include "reparse_symlink.h"
+#include "libcli/util/pyerrors.h"
+#include "reparse.h"
+#include "smb_constants.h"
static PyObject *py_reparse_put(PyObject *module, PyObject *args)
{
{
char *buf = NULL;
Py_ssize_t buflen;
- struct symlink_reparse_struct syml = {
- .flags = 0,
- };
+ struct reparse_data_buffer *syml = NULL;
+ struct symlink_reparse_struct *lnk = NULL;
PyObject *result = NULL;
- int ret;
+ NTSTATUS status;
bool ok;
ok = PyArg_ParseTuple(args, PYARG_BYTES_LEN ":get", &buf, &buflen);
return NULL;
}
- ret = symlink_reparse_buffer_parse(NULL, &syml, (uint8_t *)buf, buflen);
- if (ret != 0) {
- errno = ret;
- PyErr_SetFromErrno(PyExc_RuntimeError);
+ syml = talloc(NULL, struct reparse_data_buffer);
+ if (syml == NULL) {
+ PyErr_NoMemory();
+ return NULL;
+ }
+
+ status = reparse_data_buffer_parse(syml, syml, (uint8_t *)buf, buflen);
+ if (!NT_STATUS_IS_OK(status)) {
+ TALLOC_FREE(syml);
+ PyErr_SetNTSTATUS(status);
+ return NULL;
+ }
+
+ if (syml->tag != IO_REPARSE_TAG_SYMLINK) {
+ TALLOC_FREE(syml);
+ PyErr_SetNTSTATUS(NT_STATUS_INVALID_NETWORK_RESPONSE);
return NULL;
}
+ lnk = &syml->parsed.lnk;
result = Py_BuildValue("ssII",
- syml.substitute_name,
- syml.print_name,
- (unsigned)syml.unparsed_path_length,
- (unsigned)syml.flags);
+ lnk->substitute_name,
+ lnk->print_name,
+ (unsigned)lnk->unparsed_path_length,
+ (unsigned)lnk->flags);
- TALLOC_FREE(syml.print_name);
- TALLOC_FREE(syml.substitute_name);
+ TALLOC_FREE(syml);
return result;
}