s4:param: Add 'weak crypto' getter to pyparam
authorAndreas Schneider <asn@samba.org>
Wed, 28 Oct 2020 16:05:36 +0000 (17:05 +0100)
committerAndreas Schneider <asn@cryptomilk.org>
Thu, 29 Oct 2020 14:19:36 +0000 (14:19 +0000)
Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Alexander Bokovoy <ab@samba.org>
source4/param/pyparam.c

index 4023fac4dd649abc405f28b6a89467ba6f2c21c2..e15592b574302e9560406bfbca160c068138f4e4 100644 (file)
@@ -463,6 +463,23 @@ static PyObject *py_lp_ctx_config_file(PyObject *self, void *closure)
                return PyUnicode_FromString(configfile);
 }
 
+static PyObject *py_lp_ctx_weak_crypto(PyObject *self, void *closure)
+{
+       enum samba_weak_crypto weak_crypto =
+               lpcfg_weak_crypto(PyLoadparmContext_AsLoadparmContext(self));
+
+       switch(weak_crypto) {
+       case SAMBA_WEAK_CRYPTO_UNKNOWN:
+               Py_RETURN_NONE;
+       case SAMBA_WEAK_CRYPTO_ALLOWED:
+               return PyUnicode_FromString("allowed");
+       case SAMBA_WEAK_CRYPTO_DISALLOWED:
+               return PyUnicode_FromString("disallowed");
+       }
+
+       Py_RETURN_NONE;
+}
+
 static PyGetSetDef py_lp_ctx_getset[] = {
        {
                .name = discard_const_p(char, "default_service"),
@@ -473,6 +490,11 @@ static PyGetSetDef py_lp_ctx_getset[] = {
                .get  = (getter)py_lp_ctx_config_file,
                .doc  = discard_const_p(char, "Name of last config file that was loaded.")
        },
+       {
+               .name = discard_const_p(char, "weak_crypto"),
+               .get  = (getter)py_lp_ctx_weak_crypto,
+               .doc  = discard_const_p(char, "If weak crypto is allowed.")
+       },
        { .name = NULL }
 };