s4:python Add bindings to set GENSEC flags on credentials in python
authorAndrew Bartlett <abartlet@samba.org>
Thu, 25 Feb 2010 09:22:52 +0000 (20:22 +1100)
committerAndrew Bartlett <abartlet@samba.org>
Fri, 26 Feb 2010 10:38:42 +0000 (21:38 +1100)
This should allow these to be manipulated by python scripts that need
encrypted connections.

Andrew Bartlett

source4/auth/credentials/pycredentials.c
source4/auth/gensec/pygensec.c

index 8602be8060b5eccbb4321572479df7da281b8e57..f5e802958b009b9e7cc00f6409836d281430abc5 100644 (file)
@@ -278,6 +278,27 @@ static PyObject *py_creds_get_named_ccache(py_talloc_Object *self, PyObject *arg
        return NULL;
 }
 
        return NULL;
 }
 
+static PyObject *py_creds_set_gensec_features(py_talloc_Object *self, PyObject *args)
+{
+       unsigned int gensec_features;
+
+       if (!PyArg_ParseTuple(args, "I", &gensec_features))
+               return NULL;
+
+       cli_credentials_set_gensec_features(PyCredentials_AsCliCredentials(self), gensec_features);
+
+       Py_RETURN_NONE;
+}
+
+static PyObject *py_creds_get_gensec_features(py_talloc_Object *self, PyObject *args)
+{
+       unsigned int gensec_features;
+
+       gensec_features = cli_credentials_get_gensec_features(PyCredentials_AsCliCredentials(self));
+       return PyInt_FromLong(gensec_features);
+}
+
+
 static PyMethodDef py_creds_methods[] = {
        { "get_username", (PyCFunction)py_creds_get_username, METH_NOARGS,
                "S.get_username() -> username\nObtain username." },
 static PyMethodDef py_creds_methods[] = {
        { "get_username", (PyCFunction)py_creds_get_username, METH_NOARGS,
                "S.get_username() -> username\nObtain username." },
@@ -335,6 +356,8 @@ static PyMethodDef py_creds_methods[] = {
        { "guess", (PyCFunction)py_creds_guess, METH_VARARGS, NULL },
        { "set_machine_account", (PyCFunction)py_creds_set_machine_account, METH_VARARGS, NULL },
        { "get_named_ccache", (PyCFunction)py_creds_get_named_ccache, METH_VARARGS, NULL },
        { "guess", (PyCFunction)py_creds_guess, METH_VARARGS, NULL },
        { "set_machine_account", (PyCFunction)py_creds_set_machine_account, METH_VARARGS, NULL },
        { "get_named_ccache", (PyCFunction)py_creds_get_named_ccache, METH_VARARGS, NULL },
+       { "set_gensec_features", (PyCFunction)py_creds_set_gensec_features, METH_VARARGS, NULL },
+       { "get_gensec_features", (PyCFunction)py_creds_get_gensec_features, METH_NOARGS, NULL },
        { NULL }
 };
 
        { NULL }
 };
 
index 1c2bd20dde9cc0e2249d6f30c419f77e9d637cde..21acff81362af0edfb9d68ba6d20df8a4d57c5c0 100644 (file)
@@ -177,6 +177,15 @@ void initgensec(void)
        if (m == NULL)
                return;
 
        if (m == NULL)
                return;
 
+       PyModule_AddObject(m, "FEATURE_SESSION_KEY",     PyInt_FromLong(GENSEC_FEATURE_SESSION_KEY));
+       PyModule_AddObject(m, "FEATURE_SIGN",            PyInt_FromLong(GENSEC_FEATURE_SIGN));
+       PyModule_AddObject(m, "FEATURE_SEAL",            PyInt_FromLong(GENSEC_FEATURE_SEAL));
+       PyModule_AddObject(m, "FEATURE_DCE_STYLE",       PyInt_FromLong(GENSEC_FEATURE_DCE_STYLE));
+       PyModule_AddObject(m, "FEATURE_ASYNC_REPLIES",   PyInt_FromLong(GENSEC_FEATURE_ASYNC_REPLIES));
+       PyModule_AddObject(m, "FEATURE_DATAGRAM_MODE",   PyInt_FromLong(GENSEC_FEATURE_DATAGRAM_MODE));
+       PyModule_AddObject(m, "FEATURE_SIGN_PKT_HEADER", PyInt_FromLong(GENSEC_FEATURE_SIGN_PKT_HEADER));
+       PyModule_AddObject(m, "FEATURE_NEW_SPNEGO",      PyInt_FromLong(GENSEC_FEATURE_NEW_SPNEGO));
+
        Py_INCREF(&Py_Security);
        PyModule_AddObject(m, "Security", (PyObject *)&Py_Security);
 }
        Py_INCREF(&Py_Security);
        PyModule_AddObject(m, "Security", (PyObject *)&Py_Security);
 }