mirror of
https://git.proxmox.com/git/mirror_lxc
synced 2025-07-26 05:28:07 +00:00
python3: Handle invalid global config keys
Signed-off-by: Stéphane Graber <stgraber@ubuntu.com> Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
This commit is contained in:
parent
8df68465f2
commit
1b03969c7c
@ -329,12 +329,20 @@ LXC_get_global_config_item(PyObject *self, PyObject *args, PyObject *kwds)
|
|||||||
{
|
{
|
||||||
static char *kwlist[] = {"key", NULL};
|
static char *kwlist[] = {"key", NULL};
|
||||||
char* key = NULL;
|
char* key = NULL;
|
||||||
|
const char* value = NULL;
|
||||||
|
|
||||||
if (! PyArg_ParseTupleAndKeywords(args, kwds, "s|", kwlist,
|
if (! PyArg_ParseTupleAndKeywords(args, kwds, "s|", kwlist,
|
||||||
&key))
|
&key))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
return PyUnicode_FromString(lxc_get_global_config_item(key));
|
value = lxc_get_global_config_item(key);
|
||||||
|
|
||||||
|
if (!value) {
|
||||||
|
PyErr_SetString(PyExc_KeyError, "Invalid configuration key");
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
return PyUnicode_FromString(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
|
Loading…
Reference in New Issue
Block a user