]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
auth/credentials: Add bindings for getting and setting the salt principal
authorAndrew Bartlett <abartlet@samba.org>
Thu, 21 Dec 2023 09:04:17 +0000 (22:04 +1300)
committerAndrew Bartlett <abartlet@samba.org>
Thu, 14 Mar 2024 22:06:39 +0000 (22:06 +0000)
Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Jo Sutton <josutton@catalyst.net.nz>
auth/credentials/pycredentials.c

index a27e02d1aa53b9765e8b2225c2dda7898c933f80..40773ff74a9e8c327599c01a39e99f732ee79dd7 100644 (file)
@@ -973,6 +973,35 @@ static PyObject *py_creds_get_secure_channel_type(PyObject *self, PyObject *args
        return PyLong_FromLong(channel_type);
 }
 
+static PyObject *py_creds_set_kerberos_salt_principal(PyObject *self, PyObject *args)
+{
+       char *salt_principal = NULL;
+       struct cli_credentials *creds = PyCredentials_AsCliCredentials(self);
+       if (creds == NULL) {
+               PyErr_Format(PyExc_TypeError, "Credentials expected");
+               return NULL;
+       }
+
+       if (!PyArg_ParseTuple(args, "s", &salt_principal))
+               return NULL;
+
+       cli_credentials_set_salt_principal(
+               creds,
+               salt_principal);
+
+       Py_RETURN_NONE;
+}
+
+static PyObject *py_creds_get_kerberos_salt_principal(PyObject *self, PyObject *unused)
+{
+       struct cli_credentials *creds = PyCredentials_AsCliCredentials(self);
+       if (creds == NULL) {
+               PyErr_Format(PyExc_TypeError, "Credentials expected");
+               return NULL;
+       }
+       return PyString_FromStringOrNULL(cli_credentials_get_salt_principal(creds));
+}
+
 static PyObject *py_creds_get_aes256_key(PyObject *self, PyObject *args)
 {
        struct loadparm_context *lp_ctx = NULL;
@@ -1586,6 +1615,16 @@ static PyMethodDef py_creds_methods[] = {
                .ml_meth  = py_creds_get_secure_channel_type,
                .ml_flags = METH_VARARGS,
        },
+       {
+               .ml_name  = "set_kerberos_salt_principal",
+               .ml_meth  = py_creds_set_kerberos_salt_principal,
+               .ml_flags = METH_VARARGS,
+       },
+       {
+               .ml_name  = "get_kerberos_salt_principal",
+               .ml_meth  = py_creds_get_kerberos_salt_principal,
+               .ml_flags = METH_VARARGS,
+       },
        {
                .ml_name  = "get_aes256_key",
                .ml_meth  = py_creds_get_aes256_key,