diff options
author | David Mulder <dmulder@suse.com> | 2018-04-10 15:07:34 -0600 |
---|---|---|
committer | Douglas Bagnall <dbagnall@samba.org> | 2018-04-12 08:13:34 +0200 |
commit | 6747553d1b40dc82b6aae6173dff7d2f89deb90d (patch) | |
tree | a85b7312190c8ee56e42f72255f6cae44696ba9a /source4/param | |
parent | 477fd77c4d200f2c987caaf0c1740273c7a4e4a7 (diff) | |
download | samba-6747553d1b40dc82b6aae6173dff7d2f89deb90d.tar.gz |
param: Add python binding for lpcfg_cache_path
Signed-off-by: David Mulder <dmulder@suse.com>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Diffstat (limited to 'source4/param')
-rw-r--r-- | source4/param/pyparam.c | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/source4/param/pyparam.c b/source4/param/pyparam.c index f16c2c0b227..18d7017b9c6 100644 --- a/source4/param/pyparam.c +++ b/source4/param/pyparam.c @@ -358,6 +358,28 @@ static PyObject *py_samdb_url(PyObject *self, PyObject *unused) return PyStr_FromFormat("tdb://%s/sam.ldb", lpcfg_private_dir(lp_ctx)); } +static PyObject *py_cache_path(PyObject *self, PyObject *args) +{ + struct loadparm_context *lp_ctx = PyLoadparmContext_AsLoadparmContext(self); + char *name = NULL; + char *path = NULL; + PyObject *ret = NULL; + + if (!PyArg_ParseTuple(args, "s", &name)) { + return NULL; + } + + path = lpcfg_cache_path(NULL, lp_ctx, name); + if (!path) { + PyErr_Format(PyExc_RuntimeError, + "Unable to access cache %s", name); + return NULL; + } + ret = PyStr_FromString(path); + talloc_free(path); + + return ret; +} static PyMethodDef py_lp_ctx_methods[] = { { "load", py_lp_ctx_load, METH_VARARGS, @@ -394,6 +416,9 @@ static PyMethodDef py_lp_ctx_methods[] = { { "samdb_url", py_samdb_url, METH_NOARGS, "S.samdb_url() -> string\n" "Returns the current URL for sam.ldb." }, + { "cache_path", py_cache_path, METH_VARARGS, + "S.cache_path(name) -> string\n" + "Returns a path in the Samba cache directory." }, { NULL } }; |