]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
Nuke the cext tests (no longer supported) and change the module name to freeradius
authorArran Cudbard-Bell <a.cudbardb@freeradius.org>
Thu, 17 Dec 2020 03:14:15 +0000 (21:14 -0600)
committerArran Cudbard-Bell <a.cudbardb@freeradius.org>
Thu, 17 Dec 2020 03:14:15 +0000 (21:14 -0600)
src/modules/rlm_python/example.py
src/modules/rlm_python/prepaid.py
src/modules/rlm_python/rlm_python.c
src/tests/modules/python/auth_cext_compat.attrs [deleted file]
src/tests/modules/python/auth_cext_compat.unlang [deleted file]
src/tests/modules/python/auth_with_shared_storage.unlang
src/tests/modules/python/mod_return_ok.py
src/tests/modules/python/mod_shared_storage.py
src/tests/modules/python/mod_thread_local_storage.py
src/tests/modules/python/mod_with_config.py
src/tests/modules/python/module.conf

index abcd966c488d240f472b3e45ad215b0e28f2b262..0dfb93fe4fd06b63bc0666e9baac708f20e5c874 100644 (file)
@@ -5,7 +5,7 @@
 #
 # $Id$
 
-import radiusd
+import freeradius
 
 def instantiate(p):
   print("*** instantiate ***")
@@ -15,51 +15,51 @@ def instantiate(p):
 def authorize(p):
   print("*** authorize ***")
   print("")
-  radiusd.log(radiusd.L_INFO, '*** log call in authorize ***')
+  freeradius.log(freeradius.L_INFO, '*** log call in authorize ***')
   print("")
   print(p)
   print("")
-  print(radiusd.config)
+  print(freeradius.config)
   print("")
-  return radiusd.RLM_MODULE_OK
+  return freeradius.RLM_MODULE_OK
 
 def preacct(p):
   print("*** preacct ***")
   print(p)
-  return radiusd.RLM_MODULE_OK
+  return freeradius.RLM_MODULE_OK
 
 def accounting(p):
   print("*** accounting ***")
-  radiusd.log(radiusd.L_INFO, '*** log call in accounting (0) ***')
+  freeradius.log(freeradius.L_INFO, '*** log call in accounting (0) ***')
   print("")
   print(p)
-  return radiusd.RLM_MODULE_OK
+  return freeradius.RLM_MODULE_OK
 
 def pre_proxy(p):
   print("*** pre_proxy ***")
   print(p)
-  return radiusd.RLM_MODULE_OK
+  return freeradius.RLM_MODULE_OK
 
 def post_proxy(p):
   print("*** post_proxy ***")
   print(p)
-  return radiusd.RLM_MODULE_OK
+  return freeradius.RLM_MODULE_OK
 
 def post_auth(p):
   print("*** post_auth ***")
   print(p)
-  return radiusd.RLM_MODULE_OK
+  return freeradius.RLM_MODULE_OK
 
 def recv_coa(p):
   print("*** recv_coa ***")
   print(p)
-  return radiusd.RLM_MODULE_OK
+  return freeradius.RLM_MODULE_OK
 
 def send_coa(p):
   print("*** send_coa ***")
   print(p)
-  return radiusd.RLM_MODULE_OK
+  return freeradius.RLM_MODULE_OK
 
 def detach():
   print("*** goodbye from example.py ***")
-  return radiusd.RLM_MODULE_OK
+  return freeradius.RLM_MODULE_OK
index 56a09dfe8eb5b642c8168b2e6ee073fc2d5aeab5..84c4fe5b91fad14a04a2f3c36d704ea91f269081 100644 (file)
@@ -19,7 +19,7 @@
 #
 # $Id$
 
-import radiusd
+import freeradius
 import MySQLdb
 
 # Configuration
@@ -35,7 +35,7 @@ dbHandle = None
 
 def log(level, s):
   """Log function."""
-  radiusd.radlog(level, 'prepaid.py: ' + s)
+  freeradius.radlog(level, 'prepaid.py: ' + s)
 
 def instantiate(p):
   """Module Instantiation.  0 for success, -1 for failure.
@@ -49,10 +49,10 @@ def instantiate(p):
   except MySQLdb.OperationalError, e:
     # Report the error and return -1 for failure.
     # xxx A more advanced module would retry the database.
-    log(radiusd.L_ERR, str(e))
+    log(freeradius.L_ERR, str(e))
     return -1
 
-  log(radiusd.L_INFO, 'db connection: ' + str(dbHandle))
+  log(freeradius.L_INFO, 'db connection: ' + str(dbHandle))
 
   return 0
 
@@ -71,41 +71,41 @@ def authorize(authData):
       userPasswd = t[1]
 
   # Build and log the SQL statement
-  # radiusd puts double quotes (") around the string representation of
+  # freeradius puts double quotes (") around the string representation of
   # the RADIUS packet.
   sql = 'select passwd, maxseconds from users where username = ' +  userName
 
-  log(radiusd.L_DBG, sql)
+  log(freeradius.L_DBG, sql)
 
   # Get a cursor
   # xxx Or should this be one cursor all throughout?
   try:
     dbCursor = dbHandle.cursor()
   except MySQLdb.OperationalError, e:
-    log(radiusd.L_ERR, str(e))
-    return radiusd.RLM_MODULE_FAIL
+    log(freeradius.L_ERR, str(e))
+    return freeradius.RLM_MODULE_FAIL
 
   # Execute the SQL statement
   try:
     dbCursor.execute(sql)
   except MySQLdb.OperationalError, e:
-    log(radiusd.L_ERR, str(e))
+    log(freeradius.L_ERR, str(e))
     dbCursor.close()
-    return radiusd.RLM_MODULE_FAIL
+    return freeradius.RLM_MODULE_FAIL
 
   # Get the result. (passwd, maxseconds)
   result = dbCursor.fetchone()
   if not result:
     # User not found
-    log(radiusd.L_INFO, 'user not found: ' + userName)
+    log(freeradius.L_INFO, 'user not found: ' + userName)
     dbCursor.close()
-    return radiusd.RLM_MODULE_NOTFOUND
+    return freeradius.RLM_MODULE_NOTFOUND
 
   # Compare passwords
   # Ignore the quotes around userPasswd.
   if result[0] != userPasswd[1:-1]:
-    log(radiusd.L_DBG, 'user password mismatch: ' + userName)
-    return radiusd.RLM_MODULE_REJECT
+    log(freeradius.L_DBG, 'user password mismatch: ' + userName)
+    return freeradius.RLM_MODULE_REJECT
 
   maxSeconds = result[1]
 
@@ -114,15 +114,15 @@ def authorize(authData):
   # Build and log the SQL statement
   sql = 'select sum(seconds) from sessions where username = ' + userName
 
-  log(radiusd.L_DBG, sql)
+  log(freeradius.L_DBG, sql)
 
   # Execute the SQL statement
   try:
     dbCursor.execute(sql)
   except MySQLdb.OperationalError, e:
-    log(radiusd.L_ERR, str(e))
+    log(freeradius.L_ERR, str(e))
     dbCursor.close()
-    return radiusd.RLM_MODULE_FAIL
+    return freeradius.RLM_MODULE_FAIL
 
   # Get the result. (sum,)
   result = dbCursor.fetchone()
@@ -140,23 +140,23 @@ def authorize(authData):
 
   if sessionTimeout <= 0:
     # No more time, reject outright
-    log(radiusd.L_INFO, 'user out of time: ' + userName)
-    return radiusd.RLM_MODULE_REJECT
+    log(freeradius.L_INFO, 'user out of time: ' + userName)
+    return freeradius.RLM_MODULE_REJECT
 
   # Log the success
-  log(radiusd.L_DBG, 'user accepted: %s, %d seconds' %
+  log(freeradius.L_DBG, 'user accepted: %s, %d seconds' %
       (userName, sessionTimeout))
 
   # We are adding to the RADIUS packet
   # Note that the session timeout integer must be converted to string.
   # We need to set an Auth-Type.
 
-  return (radiusd.RLM_MODULE_UPDATED,
+  return (freeradius.RLM_MODULE_UPDATED,
          (('Session-Timeout', str(sessionTimeout)),),
          (('Auth-Type', 'python'),))
   # If you want to use different operators
   # you can do
-  # return (radiusd.RLM_MODULE_UPDATED,
+  # return (freeradius.RLM_MODULE_UPDATED,
   #         (
   #            ('Session-Timeout', ':=', str(sessionTimeout)),
   #            ('Some-other-option', '-=', Value'),
@@ -167,11 +167,11 @@ def authorize(authData):
   #        )
 
 def authenticate(p):
-  return radiusd.RLM_MODULE_OK
+  return freeradius.RLM_MODULE_OK
 
 
 def preacct(p):
-  return radiusd.RLM_MODULE_OK
+  return freeradius.RLM_MODULE_OK
 
 
 def accounting(acctData):
@@ -194,10 +194,10 @@ def accounting(acctData):
   # We will not deal with Start for now.
   # We may later, for simultaneous checks and the like.
   if acctStatusType == 'Start':
-    return radiusd.RLM_MODULE_OK
+    return freeradius.RLM_MODULE_OK
 
   # Build and log the SQL statement
-  # radiusd puts double quotes (") around the string representation of
+  # freeradius puts double quotes (") around the string representation of
   # the RADIUS packet.
   #
   # xxx This is simplistic as it does not record the time, etc.
@@ -205,36 +205,36 @@ def accounting(acctData):
   sql = 'insert into sessions (username, seconds) values (%s, %d)' % \
        (userName, int(acctSessionTime))
 
-  log(radiusd.L_DBG, sql)
+  log(freeradius.L_DBG, sql)
 
   # Get a cursor
   # xxx Or should this be one cursor all throughout?
   try:
     dbCursor = dbHandle.cursor()
   except MySQLdb.OperationalError, e:
-    log(radiusd.L_ERR, str(e))
-    return radiusd.RLM_MODULE_FAIL
+    log(freeradius.L_ERR, str(e))
+    return freeradius.RLM_MODULE_FAIL
 
   # Execute the SQL statement
   try:
     dbCursor.execute(sql)
   except MySQLdb.OperationalError, e:
-    log(radiusd.L_ERR, str(e))
+    log(freeradius.L_ERR, str(e))
     dbCursor.close()
-    return radiusd.RLM_MODULE_FAIL
+    return freeradius.RLM_MODULE_FAIL
 
 
-  return radiusd.RLM_MODULE_OK
+  return freeradius.RLM_MODULE_OK
 
 
 def detach():
   """Detach and clean up."""
   # Shut down the database connection.
   global dbHandle
-  log(radiusd.L_DBG, 'closing database handle: ' + str(dbHandle))
+  log(freeradius.L_DBG, 'closing database handle: ' + str(dbHandle))
   dbHandle.close()
 
-  return radiusd.RLM_MODULE_OK
+  return freeradius.RLM_MODULE_OK
 
 
 
index ad59d4b64084d2aa7722ec8fa7f375997b757b35..63e76b537f4e6b2992a442771d1568edc9671c65 100644 (file)
@@ -192,7 +192,7 @@ static PyObject *mod_log(UNUSED PyObject *module, PyObject *args)
 
 static PyMethodDef module_methods[] = {
        { "log", &mod_log, METH_VARARGS,
-         "radiusd.log(level, msg)\n\n" \
+         "freeradius.log(level, msg)\n\n" \
          "Print a message using radiusd logging system. level should be one of the\n" \
          "constants L_DBG, L_AUTH, L_INFO, L_ERR\n"
        },
@@ -851,8 +851,8 @@ static PyObject *python_module_init(void)
 
        static struct PyModuleDef py_module_def = {
                PyModuleDef_HEAD_INIT,
-               "radiusd",                      /* m_name */
-               "FreeRADIUS python module",     /* m_doc */
+               "freeradius",                   /* m_name */
+               "freeRADIUS python module",     /* m_doc */
                -1,                             /* m_size */
                module_methods,                 /* m_methods */
                NULL,                           /* m_reload */
@@ -911,9 +911,9 @@ static int python_interpreter_init(rlm_python_t *inst, CONF_SECTION *conf)
         *      own copy which it can mutate as much as
         *      it wants.
         */
-       module = PyImport_ImportModule("radiusd");
+       module = PyImport_ImportModule("freeradius");
        if (!module) {
-               ERROR("Failed importing \"radiusd\" module into interpreter %p", inst->interpreter);
+               ERROR("Failed importing \"freeradius\" module into interpreter %p", inst->interpreter);
                return -1;
        }
        if ((python_module_import_config(inst, conf, module) < 0) ||
@@ -1113,7 +1113,7 @@ static int mod_load(void)
         *      are automatically created when the first
         *      interpreter is spawned.
         */
-       PyImport_AppendInittab("radiusd", python_module_init);
+       PyImport_AppendInittab("freeradius", python_module_init);
        LSAN_DISABLE(Py_InitializeEx(0));       /* Don't override signal handlers - noop on subs calls */
 
        /*
diff --git a/src/tests/modules/python/auth_cext_compat.attrs b/src/tests/modules/python/auth_cext_compat.attrs
deleted file mode 100644 (file)
index 8b7914e..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-#
-#  Input packet
-#
-User-Name = "bob"
-User-Password = "hello"
-
-#
-#  Expected answer
-#
-Packet-Type == Access-Accept
\ No newline at end of file
diff --git a/src/tests/modules/python/auth_cext_compat.unlang b/src/tests/modules/python/auth_cext_compat.unlang
deleted file mode 100644 (file)
index 5396ef9..0000000
+++ /dev/null
@@ -1,36 +0,0 @@
-if ("%{config:version.python}" =~ /^3/) {
-       test_pass
-       return
-}
-
-# This module is cext_compat and should work
-pmod4_cextcompat
-if (!noop) {
-    test_fail
-} else {
-    test_pass
-}
-
-# This module share the main interpreter with pmod4_cextcompat. shared_attribute should be defined
-pmod5_cextcompat
-if (!ok) {
-    test_fail
-} else {
-    test_pass
-}
-
-# This module has it's own SubInterpreter. shared_attribute shouldn't be defined
-pmod4_not_cextcompat
-if (!noop) {
-    test_fail
-} else {
-    test_pass
-}
-
-# This module has it's own SubInterpreter. shared_attribute shouldn't be defined
-pmod5_not_cextcompat
-if (!noop) {
-    test_fail
-} else {
-    test_pass
-}
index 9e55880a82ad54299d9d9bdbc18b83b8c7f270e0..54ba761ec7c4d7f7d7423a030fef572fab9bc9ed 100644 (file)
@@ -1,5 +1,5 @@
 # Should return noop (no shared variable set)
-pmod_shared_storage
+pmod7_shared_storage
 if (noop) {
        test_pass
 } else {
@@ -7,7 +7,7 @@ if (noop) {
 }
 
 # Should return ok (shared variable set)
-pmod_shared_storage
+pmod7_shared_storage
 if (ok) {
        test_pass
 } else {
index 9089d1aa7fb748dc26ce2d0c40ae57643ec20f9b..8879e10b2bcbd7420d68ae3c8a466e91a492d2cc 100644 (file)
@@ -1,4 +1,4 @@
-import radiusd
+import freeradius
 
-def authorize(p):   
-    return radiusd.RLM_MODULE_OK
\ No newline at end of file
+def authorize(p):
+    return freeradius.RLM_MODULE_OK
index b2f3e84c88efe8991b3d5db5e123682b3a0e0b43..4b0e13975a1aaf484bb3df93409a1e4a472a36c6 100644 (file)
@@ -1,10 +1,10 @@
-import radiusd
+import freeradius
 import shared
 
 def authorize(p):
-  radiusd.log(radiusd.L_DBG, 'Python - shared_attribute=' + str(hasattr(shared, 'shared_attribute')))
+  freeradius.log(freeradius.L_DBG, 'Python - shared_attribute=' + str(hasattr(shared, 'shared_attribute')))
   if not hasattr(shared, 'shared_attribute'):
     setattr(shared, 'shared_attribute', True)
-    return radiusd.RLM_MODULE_NOOP
+    return freeradius.RLM_MODULE_NOOP
   else:
-     return radiusd.RLM_MODULE_OK
+     return freeradius.RLM_MODULE_OK
index f2897dc29ecd50576d4c6e88b209b61d910efb0e..3018e870c8c6593bc872fcb49cbe34399a87229a 100644 (file)
@@ -1,13 +1,13 @@
-import radiusd
+import freeradius
 import threading
 
 local = threading.local()
 
 def authorize(p):
     global local
-    radiusd.log(radiusd.L_DBG, 'Python - threading.local.tls()=' + str(hasattr(local, 'tls')))
+    freeradius.log(freeradius.L_DBG, 'Python - threading.local.tls()=' + str(hasattr(local, 'tls')))
     if hasattr(local, 'tls'):
-        return radiusd.RLM_MODULE_OK
+        return freeradius.RLM_MODULE_OK
     else:
         local.tls = True
-        return radiusd.RLM_MODULE_NOOP
+        return freeradius.RLM_MODULE_NOOP
index e95e6cfa34ac9fb5f6668bd98e35768633af59e2..91571f4366dd4a8b5e6bc8eba64581bc5998d8ba 100644 (file)
@@ -1,7 +1,7 @@
-import radiusd
+import freeradius
 
 def authorize(p):
-    if radiusd.config.get('a_param'):
-        return radiusd.RLM_MODULE_OK
+    if freeradius.config.get('a_param'):
+        return freeradius.RLM_MODULE_OK
 
-    return radiusd.RLM_MODULE_NOOP
\ No newline at end of file
+    return freeradius.RLM_MODULE_NOOP
index 5d7072e71fc042ed3d03d1957280906bccba5b69..c184d2ebd6d40bd1d73bdb6c9fb194c9b5f25864 100644 (file)
@@ -25,40 +25,18 @@ python pmod3_withmod1 {
        func_authorize = authorize
 }
 
-python pmod4_cextcompat {
+python pmod4 {
        module = 'mod_shared_storage'
 
        mod_authorize = ${.module}
        func_authorize = authorize
-
-       cext_compat = true
-}
-
-python pmod5_cextcompat {
-       module = 'mod_shared_storage'
-
-       mod_authorize = ${.module}
-       func_authorize = authorize
-
-       cext_compat = true
 }
 
-python pmod4_not_cextcompat {
+python pmod5 {
        module = 'mod_shared_storage'
 
        mod_authorize = ${.module}
        func_authorize = authorize
-
-       cext_compat = false
-}
-
-python pmod5_not_cextcompat {
-       module = 'mod_shared_storage'
-
-       mod_authorize = ${.module}
-       func_authorize = authorize
-
-       cext_compat = false
 }
 
 python pmod6_configured {
@@ -72,7 +50,7 @@ python pmod6_configured {
        }
 }
 
-python pmod_shared_storage {
+python pmod7_shared_storage {
        module = 'mod_shared_storage'
 
        mod_authorize = ${.module}