diff options
author | Stefan Metzmacher <metze@samba.org> | 2010-02-24 14:44:22 +0100 |
---|---|---|
committer | Stefan Metzmacher <metze@samba.org> | 2010-02-26 08:57:30 +0100 |
commit | d2cd0a783b059fc2a938f7e2a5f5d002e83be967 (patch) | |
tree | 085324a6c0212c4d1259f0f386d1389a465543a2 /source4 | |
parent | 9ada48ffdb3b7ab4bc1bce0f6b2179f67292bcf8 (diff) | |
download | samba-d2cd0a783b059fc2a938f7e2a5f5d002e83be967.tar.gz samba-d2cd0a783b059fc2a938f7e2a5f5d002e83be967.tar.bz2 samba-d2cd0a783b059fc2a938f7e2a5f5d002e83be967.zip |
s4:pyglue: add generate_random_password()
metze
Diffstat (limited to 'source4')
-rw-r--r-- | source4/scripting/python/pyglue.c | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/source4/scripting/python/pyglue.c b/source4/scripting/python/pyglue.c index 136b121bc0..6fe789ae73 100644 --- a/source4/scripting/python/pyglue.c +++ b/source4/scripting/python/pyglue.c @@ -79,6 +79,23 @@ static PyObject *py_generate_random_str(PyObject *self, PyObject *args) return ret; } +static PyObject *py_generate_random_password(PyObject *self, PyObject *args) +{ + int min, max; + PyObject *ret; + char *retstr; + if (!PyArg_ParseTuple(args, "ii", &min, &max)) + return NULL; + + retstr = generate_random_password(NULL, min, max); + if (retstr == NULL) { + return NULL; + } + ret = PyString_FromString(retstr); + talloc_free(retstr); + return ret; +} + static PyObject *py_unix2nttime(PyObject *self, PyObject *args) { time_t t; @@ -636,8 +653,11 @@ static PyObject *py_interface_ips(PyObject *self, PyObject *args) static PyMethodDef py_misc_methods[] = { { "generate_random_str", (PyCFunction)py_generate_random_str, METH_VARARGS, - "random_password(len) -> string\n" - "Generate random password with specified length." }, + "generate_random_str(len) -> string\n" + "Generate random string with specified length." }, + { "generate_random_password", (PyCFunction)py_generate_random_password, METH_VARARGS, + "generate_random_password(min, max) -> string\n" + "Generate random password with a length >= min and <= max." }, { "unix2nttime", (PyCFunction)py_unix2nttime, METH_VARARGS, "unix2nttime(timestamp) -> nttime" }, { "ldb_set_session_info", (PyCFunction)py_ldb_set_session_info, METH_VARARGS, |