pygpo: Check for errors in gpo.gpo_get_sysvol_gpt_version()
authorAndrew Bartlett <abartlet@samba.org>
Tue, 24 Oct 2017 02:58:45 +0000 (15:58 +1300)
committerGarming Sam <garming@samba.org>
Mon, 20 Nov 2017 20:41:15 +0000 (21:41 +0100)
Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Garming Sam <garming@catalyst.net.nz>
libgpo/pygpo.c

index 3a31c59d6ccd030b61bb8552eae7dec4b2c6958e..757c713b0278ca537079e3c7cc81f9c5c75bb65d 100644 (file)
@@ -25,6 +25,7 @@
 #include "secrets.h"
 #include "../libds/common/flags.h"
 #include "auth/credentials/pycredentials.h"
+#include "libcli/util/pyerrors.h"
 
 /* A Python C API module to use LIBGPO */
 
@@ -288,13 +289,22 @@ static PyObject *py_gpo_get_sysvol_gpt_version(PyObject * self, PyObject * args)
        char *display_name = NULL;
        uint32_t sysvol_version = 0;
        PyObject *result;
+       NTSTATUS status;
 
        tmp_ctx = talloc_new(NULL);
 
        if (!PyArg_ParseTuple(args, "s", &unix_path)) {
                return NULL;
        }
-       gpo_get_sysvol_gpt_version(tmp_ctx, unix_path, &sysvol_version, &display_name);
+       status = gpo_get_sysvol_gpt_version(tmp_ctx, unix_path,
+                                           &sysvol_version,
+                                           &display_name);
+       if (!NT_STATUS_IS_OK(status)) {
+               PyErr_SetNTSTATUS(status);
+               TALLOC_FREE(tmp_ctx);
+               return NULL;
+       }
+
        talloc_free(tmp_ctx);
        result = Py_BuildValue("[s,i]", display_name, sysvol_version);
        return result;