more checking when we load modules.
#define RLM_TYPE_THREAD_SAFE (0 << 0)
#define RLM_TYPE_THREAD_UNSAFE (1 << 0)
+#define RLM_MODULE_MAGIC_NUMBER ((uint32_t) (0xf4ee4ad12))
+#define RLM_MODULE_INIT RLM_MODULE_MAGIC_NUMBER
+
typedef struct module_t {
+ uint32_t magic; /* may later be opaque struct */
const char *name;
- int type; /* reserved */
- int (*init)(void);
- int (*instantiate)(CONF_SECTION *mod_cs, void **instance);
+ int type;
+ int (*instantiate)(CONF_SECTION *mod_cs, void **instance);
+ int (*detach)(void *instance);
packetmethod methods[RLM_COMPONENT_COUNT];
- int (*detach)(void *instance);
- int (*destroy)(void);
} module_t;
enum {
{
module_entry_t *this = data;
- if (this->module->destroy)
- (this->module->destroy)();
lt_dlclose(this->handle); /* ignore any errors */
free(this);
}
lt_dlhandle handle;
char module_struct[256];
char *p;
+ const void *module;
node = cf_data_find(modules, module_name);
if (node) return node;
handle = lt_dlopenext(module_name);
if (handle == NULL) {
radlog(L_ERR|L_CONS, "%s[%d] Failed to link to module '%s':"
- " %s\n", cffilename, cflineno, module_name, lt_dlerror());
+ " %s\n", cffilename, cflineno, module_name, lt_dlerror());
return NULL;
}
- /* make room for the module type */
- node = rad_malloc(sizeof(*node));
- memset(node, 0, sizeof(*node));
-
- /* fill in the module structure */
- node->handle = handle;
- strNcpy(node->name, module_name, sizeof(node->name));
-
/*
* Link to the module's rlm_FOO{} module structure.
*
p = strrchr(module_struct, '-');
if (p) *p = '\0';
- node->module = (module_t *) lt_dlsym(node->handle, module_struct);
- if (!node->module) {
+ DEBUG3(" (Loaded %s, checking if it's valid)", module_name);
+
+ /*
+ * libltld MAY core here, if the handle it gives us contains
+ * garbage data.
+ */
+ module = lt_dlsym(handle, module_struct);
+ if (!module) {
radlog(L_ERR|L_CONS, "%s[%d] Failed linking to "
"%s structure in %s: %s\n",
cffilename, cflineno,
module_name, cffilename, lt_dlerror());
- lt_dlclose(node->handle); /* ignore any errors */
- free(node);
+ lt_dlclose(handle);
return NULL;
}
-
- /* call the modules initialization */
- if (node->module->init && (node->module->init)() < 0) {
- radlog(L_ERR|L_CONS, "%s[%d] Module initialization failed.\n",
- cffilename, cflineno);
- lt_dlclose(node->handle); /* ignore any errors */
- free(node);
+ /*
+ * Before doing anything else, check if it's sane.
+ */
+ if ((*(uint32_t *) module) != RLM_MODULE_MAGIC_NUMBER) {
+ lt_dlclose(handle);
+ DEBUG2("%08x %08x\n", (*(uint32_t *) handle), RLM_MODULE_MAGIC_NUMBER);
+ radlog(L_ERR|L_CONS, "%s[%d] Invalid version in module '%s'",
+ cffilename, cflineno, module_name);
return NULL;
+
}
+ /* make room for the module type */
+ node = rad_malloc(sizeof(*node));
+ memset(node, 0, sizeof(*node));
+ node->module = module;
+
DEBUG("Module: Loaded %s ", node->module->name);
/*
/* globally exported name */
module_t rlm_acct_unique = {
+ RLM_MODULE_INIT,
"Acct-Unique-Session-Id",
0, /* type: reserved */
- NULL, /* initialization */
unique_instantiate, /* instantiation */
+ unique_detach, /* detach */
{
NULL, /* authentication */
add_unique_id, /* authorization */
NULL, /* post-proxy */
NULL /* post-auth */
},
- unique_detach, /* detach */
- NULL, /* destroy */
};
}
module_t rlm_always = {
+ RLM_MODULE_INIT,
"always",
RLM_TYPE_THREAD_SAFE, /* type */
- NULL, /* initialization */
always_instantiate, /* instantiation */
+ always_detach, /* detach */
{
always_return, /* authentication */
always_return, /* authorization */
always_return, /* post-proxy */
always_return /* post-auth */
},
- always_detach, /* detach */
- NULL, /* destroy */
};
/* globally exported name */
module_t rlm_attr_filter = {
+ RLM_MODULE_INIT,
"attr_filter",
0, /* type: reserved */
- NULL, /* initialization */
attr_filter_instantiate, /* instantiation */
+ attr_filter_detach, /* detach */
{
NULL, /* authentication */
NULL, /* authorization */
attr_filter_postproxy, /* post-proxy */
NULL /* post-auth */
},
- attr_filter_detach, /* detach */
- NULL /* destroy */
};
{
rlm_attr_rewrite_t *data;
DICT_ATTR *dattr;
- char *instance_name = NULL;
+ const char *instance_name = NULL;
/*
* Set up a storage area for instance data
* is single-threaded.
*/
module_t rlm_attr_rewrite = {
+ RLM_MODULE_INIT,
"attr_rewrite",
RLM_TYPE_THREAD_UNSAFE, /* type */
- NULL, /* initialization */
attr_rewrite_instantiate, /* instantiation */
+ attr_rewrite_detach, /* detach */
{
attr_rewrite_authenticate, /* authentication */
attr_rewrite_authorize, /* authorization */
attr_rewrite_postproxy, /* post-proxy */
attr_rewrite_postauth /* post-auth */
},
- attr_rewrite_detach, /* detach */
- NULL, /* destroy */
};
* is single-threaded.
*/
module_t rlm_caching = {
+ RLM_MODULE_INIT,
"Caching",
RLM_TYPE_THREAD_SAFE, /* type */
- NULL, /* initialization */
caching_instantiate, /* instantiation */
+ caching_detach, /* detach */
{
NULL, /* authentication */
caching_authorize, /* authorization */
NULL, /* post-proxy */
caching_postauth /* post-auth */
},
- caching_detach, /* detach */
- NULL, /* destroy */
};
* is single-threaded.
*/
module_t rlm_chap = {
+ RLM_MODULE_INIT,
"CHAP",
0, /* type */
- NULL, /* initialization */
NULL, /* instantiation */
+ NULL, /* detach */
{
chap_authenticate, /* authentication */
chap_authorize, /* authorization */
NULL, /* post-proxy */
NULL /* post-auth */
},
- NULL, /* detach */
- NULL, /* destroy */
};
* is single-threaded.
*/
module_t rlm_checkval = {
+ RLM_MODULE_INIT,
"checkval",
0, /* type */
- NULL, /* initialization */
checkval_instantiate, /* instantiation */
+ checkval_detach, /* detach */
{
NULL, /* authentication */
checkval_authorize, /* authorization */
NULL, /* post-proxy */
NULL /* post-auth */
},
- checkval_detach, /* detach */
- NULL, /* destroy */
};
* is single-threaded.
*/
module_t rlm_copy_packet = {
+ RLM_MODULE_INIT,
"copy_packet",
RLM_TYPE_THREAD_SAFE, /* type */
- NULL, /* initialization */
packet_instantiate, /* instantiation */
+ packet_detach, /* detach */
{
NULL, /* authentication */
packet_authorize, /* authorization */
NULL, /* post-proxy */
NULL /* post-auth */
},
- packet_detach, /* detach */
- NULL, /* destroy */
};
* is single-threaded.
*/
module_t rlm_counter = {
- "Counter",
+ RLM_MODULE_INIT,
+ "counter",
RLM_TYPE_THREAD_SAFE, /* type */
- NULL, /* initialization */
counter_instantiate, /* instantiation */
+ counter_detach, /* detach */
{
NULL, /* authentication */
counter_authorize, /* authorization */
NULL, /* post-proxy */
NULL /* post-auth */
},
- counter_detach, /* detach */
- NULL, /* destroy */
};
}
module_t rlm_cram = {
- "CRAM",
- RLM_TYPE_THREAD_SAFE, /* type */
- NULL, /* initialize */
- NULL, /* instantiation */
- {
- cram_authenticate, /* authenticate */
- NULL, /* authorize */
- NULL, /* pre-accounting */
- NULL, /* accounting */
- NULL, /* checksimul */
- NULL, /* pre-proxy */
- NULL, /* post-proxy */
- NULL /* post-auth */
- },
- NULL, /* detach */
- NULL, /* destroy */
+ RLM_MODULE_INIT,
+ "CRAM",
+ RLM_TYPE_THREAD_SAFE, /* type */
+ NULL, /* instantiation */
+ NULL, /* detach */
+ {
+ cram_authenticate, /* authenticate */
+ NULL, /* authorize */
+ NULL, /* pre-accounting */
+ NULL, /* accounting */
+ NULL, /* checksimul */
+ NULL, /* pre-proxy */
+ NULL, /* post-proxy */
+ NULL /* post-auth */
+ },
};
/* globally exported name */
module_t rlm_dbm = {
+ RLM_MODULE_INIT,
"dbm",
0, /* type: reserved */
- NULL, /* initialization */
rlm_dbm_instantiate, /* instantiation */
+ rlm_dbm_detach, /* detach */
{
NULL, /* authentication */
rlm_dbm_authorize, /* authorization */
NULL, /* post-proxy */
NULL /* post-auth */
},
- rlm_dbm_detach, /* detach */
- NULL /* destroy */
};
*/
if ((inst->last_made_directory == NULL) ||
(strcmp(inst->last_made_directory, buffer) != 0)) {
-
- /*
- * Free any previously cached name.
- */
- if (inst->last_made_directory != NULL) {
- free((char *) inst->last_made_directory);
- inst->last_made_directory = NULL;
- }
-
+ free((char *) inst->last_made_directory);
inst->last_made_directory = strdup(buffer);
}
/* globally exported name */
module_t rlm_detail = {
+ RLM_MODULE_INIT,
"detail",
RLM_TYPE_THREAD_UNSAFE, /* type: reserved */
- NULL, /* initialization */
detail_instantiate, /* instantiation */
+ detail_detach, /* detach */
{
NULL, /* authentication */
detail_authorize, /* authorization */
detail_post_proxy, /* post-proxy */
detail_postauth /* post-auth */
},
- detail_detach, /* detach */
- NULL /* destroy */
};
VALUE_PAIR *vp;
VALUE_PAIR *qop, *nonce;
+ instance = instance; /* -Wunused */
+
/*
* We require access to the plain-text password.
*/
* is single-threaded.
*/
module_t rlm_digest = {
- "DIGEST",
+ RLM_MODULE_INIT,
+ "digest",
0, /* type */
- NULL, /* initialization */
NULL, /* instantiation */
+ NULL, /* detach */
{
digest_authenticate, /* authentication */
digest_authorize, /* authorization */
NULL, /* post-proxy */
NULL /* post-auth */
},
- NULL, /* detach */
- NULL, /* destroy */
};
{ NULL, -1, 0, NULL, NULL } /* end the list */
};
-static int eap_init(void)
-{
- return 0;
-}
-
-
/*
* delete all the allocated space by eap module
*/
* That is, everything else should be 'static'.
*/
module_t rlm_eap = {
+ RLM_MODULE_INIT,
"eap",
RLM_TYPE_THREAD_SAFE, /* type */
- eap_init, /* initialization */
eap_instantiate, /* instantiation */
+ eap_detach, /* detach */
{
eap_authenticate, /* authentication */
eap_authorize, /* authorization */
eap_post_proxy, /* post-proxy */
NULL /* post-auth */
},
- eap_detach, /* detach */
- NULL, /* destroy */
};
{ NULL, -1, 0, NULL, NULL } /* end the list */
};
-/*
- * Do any per-module initialization. e.g. set up connections
- * to external databases, read configuration files, set up
- * dictionary entries, etc.
- *
- * Try to avoid putting too much stuff in here - it's better to
- * do it in instantiate() where it is not global.
- */
-static int example_init(void)
-{
- /*
- * Everything's OK, return without an error.
- */
- return 0;
-}
/*
* Do any per-module initialization that is separate to each
* is single-threaded.
*/
module_t rlm_example = {
+ RLM_MODULE_INIT,
"example",
RLM_TYPE_THREAD_SAFE, /* type */
- example_init, /* initialization */
example_instantiate, /* instantiation */
+ example_detach, /* detach */
{
example_authenticate, /* authentication */
example_authorize, /* authorization */
NULL, /* post-proxy */
NULL /* post-auth */
},
- example_detach, /* detach */
- NULL, /* destroy */
};
static int exec_instantiate(CONF_SECTION *conf, void **instance)
{
rlm_exec_t *inst;
- char *xlat_name;
+ const char *xlat_name;
/*
* Set up a storage area for instance data
*/
if (inst->wait &&
(inst->output == NULL)) {
- radlog(L_INFO, "rlm_exec: Wait=yes but no output defined. Did you mean output=none?");
+ radlog(L_INFO, "rlm_exec: wait=yes but no output defined. Did you mean output=none?");
}
/*
* is single-threaded.
*/
module_t rlm_exec = {
+ RLM_MODULE_INIT,
"exec", /* Name */
RLM_TYPE_THREAD_SAFE, /* type */
- NULL, /* initialization */
exec_instantiate, /* instantiation */
+ exec_detach, /* detach */
{
exec_dispatch, /* authentication */
exec_dispatch, /* authorization */
exec_dispatch, /* post-proxy */
exec_dispatch /* post-auth */
},
- exec_detach, /* detach */
- NULL, /* destroy */
};
* is single-threaded.
*/
module_t rlm_expiration = {
- "Expiration",
+ RLM_MODULE_INIT,
+ "expiration",
RLM_TYPE_THREAD_SAFE, /* type */
- NULL, /* initialization */
expiration_instantiate, /* instantiation */
+ expiration_detach, /* detach */
{
NULL, /* authentication */
expiration_authorize, /* authorization */
NULL, /* post-proxy */
NULL /* post-auth */
},
- expiration_detach, /* detach */
- NULL, /* destroy */
};
* is single-threaded.
*/
module_t rlm_expr = {
+ RLM_MODULE_INIT,
"expr", /* Name */
RLM_TYPE_THREAD_SAFE, /* type */
- NULL, /* initialization */
expr_instantiate, /* instantiation */
+ expr_detach, /* detach */
{
NULL, /* authentication */
NULL, /* authorization */
NULL, /* pre-accounting */
NULL /* accounting */
},
- expr_detach, /* detach */
- NULL, /* destroy */
};
/* globally exported name */
module_t rlm_fastusers = {
+ RLM_MODULE_INIT,
"fastusers",
0, /* type: reserved */
- NULL, /* initialization */
fastuser_instantiate, /* instantiation */
+ fastuser_detach, /* detach */
{
fastuser_authenticate, /* authentication */
fastuser_authorize, /* authorization */
NULL, /* post-proxy */
NULL /* post-auth */
},
- fastuser_detach, /* detach */
- NULL /* destroy */
};
const char *name;
struct file_instance *inst = instance;
VALUE_PAIR **check_pairs, **reply_pairs;
- VALUE_PAIR *check_save;
request_pairs = request->packet->vps;
check_pairs = &request->config_items;
/* globally exported name */
module_t rlm_files = {
+ RLM_MODULE_INIT,
"files",
0, /* type: reserved */
- NULL, /* initialization */
file_instantiate, /* instantiation */
+ file_detach, /* detach */
{
NULL, /* authentication */
file_authorize, /* authorization */
NULL, /* post-proxy */
NULL /* post-auth */
},
- file_detach, /* detach */
- NULL /* destroy */
};
* is single-threaded.
*/
module_t rlm_ippool = {
- "IPPOOL",
+ RLM_MODULE_INIT,
+ "ippool",
RLM_TYPE_THREAD_SAFE, /* type */
- NULL, /* initialization */
ippool_instantiate, /* instantiation */
+ ippool_detach, /* detach */
{
NULL, /* authentication */
NULL, /* authorization */
NULL, /* post-proxy */
ippool_postauth /* post-auth */
},
- ippool_detach, /* detach */
- NULL, /* destroy */
};
#endif /* HEIMDAL_KRB5 */
module_t rlm_krb5 = {
- "Kerberos",
- RLM_TYPE_THREAD_UNSAFE, /* type: not thread safe */
- NULL, /* initialize */
- krb5_instantiate, /* instantiation */
- {
- krb5_auth, /* authenticate */
- NULL, /* authorize */
- NULL, /* pre-accounting */
- NULL, /* accounting */
- NULL, /* checksimul */
- NULL, /* pre-proxy */
- NULL, /* post-proxy */
- NULL /* post-auth */
- },
- krb5_detach, /* detach */
- NULL, /* destroy */
+ RLM_MODULE_INIT,
+ "Kerberos",
+ RLM_TYPE_THREAD_UNSAFE, /* type: not thread safe */
+ krb5_instantiate, /* instantiation */
+ krb5_detach, /* detach */
+ {
+ krb5_auth, /* authenticate */
+ NULL, /* authorize */
+ NULL, /* pre-accounting */
+ NULL, /* accounting */
+ NULL, /* checksimul */
+ NULL, /* pre-proxy */
+ NULL, /* post-proxy */
+ NULL /* post-auth */
+ },
};
/* globally exported name */
module_t rlm_ldap = {
+ RLM_MODULE_INIT,
"LDAP",
RLM_TYPE_THREAD_SAFE, /* type: reserved */
- NULL, /* initialization */
ldap_instantiate, /* instantiation */
+ ldap_detach, /* detach */
{
ldap_authenticate, /* authentication */
ldap_authorize, /* authorization */
NULL
#endif
},
- ldap_detach, /* detach */
- NULL, /* destroy */
};
* Externally visible module definition.
*/
module_t rlm_linelog = {
+ RLM_MODULE_INIT,
"example",
RLM_TYPE_THREAD_SAFE, /* type */
- NULL, /* initialization */
linelog_instantiate, /* instantiation */
+ linelog_detach, /* detach */
{
do_linelog, /* authentication */
do_linelog, /* authorization */
do_linelog, /* post-proxy */
do_linelog /* post-auth */
},
- linelog_detach, /* detach */
- NULL, /* destroy */
};
* is single-threaded.
*/
module_t rlm_logintime = {
+ RLM_MODULE_INIT,
"logintime",
RLM_TYPE_THREAD_SAFE, /* type */
- NULL, /* initialization */
logintime_instantiate, /* instantiation */
+ logintime_detach, /* detach */
{
NULL, /* authentication */
logintime_authorize, /* authorization */
NULL, /* post-proxy */
NULL /* post-auth */
},
- logintime_detach, /* detach */
- NULL, /* destroy */
};
}
module_t rlm_mschap = {
- "MS-CHAP",
- RLM_TYPE_THREAD_SAFE, /* type */
- NULL, /* initialize */
- mschap_instantiate, /* instantiation */
- {
- mschap_authenticate, /* authenticate */
- mschap_authorize, /* authorize */
- NULL, /* pre-accounting */
- NULL, /* accounting */
- NULL, /* checksimul */
- NULL, /* pre-proxy */
- NULL, /* post-proxy */
- NULL /* post-auth */
- },
- mschap_detach, /* detach */
- NULL, /* destroy */
+ RLM_MODULE_INIT,
+ "MS-CHAP",
+ RLM_TYPE_THREAD_SAFE, /* type */
+ mschap_instantiate, /* instantiation */
+ mschap_detach, /* detach */
+ {
+ mschap_authenticate, /* authenticate */
+ mschap_authorize, /* authorize */
+ NULL, /* pre-accounting */
+ NULL, /* accounting */
+ NULL, /* checksimul */
+ NULL, /* pre-proxy */
+ NULL, /* post-proxy */
+ NULL /* post-auth */
+ },
};
* is single-threaded.
*/
module_t rlm_otp = {
+ RLM_MODULE_INIT,
"otp",
RLM_TYPE_THREAD_SAFE, /* type */
otp_init, /* initialization */
}
module_t rlm_pam = {
- "Pam",
- RLM_TYPE_THREAD_UNSAFE, /* The PAM libraries are not thread-safe */
- NULL, /* initialize */
- pam_instantiate, /* instantiation */
- {
- pam_auth, /* authenticate */
- NULL, /* authorize */
- NULL, /* pre-accounting */
- NULL, /* accounting */
- NULL, /* checksimul */
- NULL, /* pre-proxy */
- NULL, /* post-proxy */
- NULL /* post-auth */
- },
- pam_detach, /* detach */
- NULL, /* destroy */
+ RLM_MODULE_INIT,
+ "pam",
+ RLM_TYPE_THREAD_UNSAFE, /* The PAM libraries are not thread-safe */
+ pam_instantiate, /* instantiation */
+ pam_detach, /* detach */
+ {
+ pam_auth, /* authenticate */
+ NULL, /* authorize */
+ NULL, /* pre-accounting */
+ NULL, /* accounting */
+ NULL, /* checksimul */
+ NULL, /* pre-proxy */
+ NULL, /* post-proxy */
+ NULL /* post-auth */
+ },
};
* is single-threaded.
*/
module_t rlm_pap = {
+ RLM_MODULE_INIT,
"PAP",
0, /* type */
- NULL, /* initialization */
pap_instantiate, /* instantiation */
+ pap_detach, /* detach */
{
pap_authenticate, /* authentication */
pap_authorize, /* authorization */
NULL, /* post-proxy */
NULL /* post-auth */
},
- pap_detach, /* detach */
- NULL, /* destroy */
};
}
module_t rlm_passwd = {
+ RLM_MODULE_INIT,
"passwd",
RLM_TYPE_THREAD_SAFE, /* type */
- NULL, /* initialize */
passwd_instantiate, /* instantiation */
+ passwd_detach, /* detach */
{
NULL, /* authentication */
passwd_authorize, /* authorization */
NULL, /* post-proxy */
NULL /* post-auth */
},
- passwd_detach, /* detach */
- NULL /* destroy */
};
#endif /* TEST */
* We clone it for every instance if we have perl
* with -Duseithreads compiled in
*/
-static PerlInterpreter *interp;
+static PerlInterpreter *interp = NULL;
static const CONF_PARSER pool_conf[] = {
{ "max_clones", PW_TYPE_INTEGER, offsetof(PERL_POOL, max_clones), NULL, "32"},
int t;
PERL_POOL *pool;
+ if (!interp) {
+#ifdef USE_ITHREADS
+ if ((interp = perl_alloc()) == NULL) {
+ radlog(L_DBG, "rlm_perl: No memory for allocating new perl !");
+ return -1;
+ }
+
+ perl_construct(interp);
+ PL_perl_destruct_level = 2;
+#endif
+ }
+
pool = rad_malloc(sizeof(PERL_POOL));
memset(pool,0,sizeof(PERL_POOL));
*/
static int perl_init(void)
{
-#ifdef USE_ITHREADS
- if ((interp = perl_alloc()) == NULL) {
- radlog(L_DBG, "rlm_perl: No memory for allocating new perl !");
- return -1;
- }
-
- perl_construct(interp);
- PL_perl_destruct_level = 2;
-#endif
return 0;
}
* is single-threaded.
*/
module_t rlm_perl = {
+ RLM_MODULE_INIT,
"perl", /* Name */
#ifdef USE_ITHREADS
RLM_TYPE_THREAD_SAFE, /* type */
#else
RLM_TYPE_THREAD_UNSAFE,
#endif
- perl_init, /* initialization */
perl_instantiate, /* instantiation */
+ perl_detach, /* detach */
{
perl_authenticate,
perl_authorize,
perl_post_proxy, /* post-proxy */
perl_post_auth /* post-auth */
},
- perl_detach, /* detach */
- NULL, /* destroy */
};
* is single-threaded.
*/
module_t rlm_policy = {
+ RLM_MODULE_INIT,
"policy",
RLM_TYPE_THREAD_SAFE, /* type */
- NULL, /* initialization */
policy_instantiate, /* instantiation */
+ policy_detach, /* detach */
{
NULL, /* authentication */
policy_authorize, /* authorization */
policy_post_proxy, /* post-proxy */
policy_post_auth /* post-auth */
},
- policy_detach, /* detach */
- NULL, /* destroy */
};
}
/* globally exported name */
-module_t rlm_preprocess = {
+module_t rlm_preprocess = {
+ RLM_MODULE_INIT,
"preprocess",
0, /* type: reserved */
- NULL, /* initialization */
preprocess_instantiate, /* instantiation */
+ preprocess_detach, /* detach */
{
NULL, /* authentication */
preprocess_authorize, /* authorization */
NULL, /* post-proxy */
NULL /* post-auth */
},
- preprocess_detach, /* detach */
- NULL, /* destroy */
};
* is single-threaded.
*/
module_t rlm_protocol_filter = {
+ RLM_MODULE_INIT,
"protocol_filter",
RLM_TYPE_THREAD_SAFE, /* type */
- NULL, /* initialization */
filter_instantiate, /* instantiation */
+ filter_detach, /* detach */
{
NULL, /* authentication */
filter_authorize, /* authorization */
NULL, /* post-proxy */
NULL /* post-auth */
},
- filter_detach, /* detach */
- NULL, /* destroy */
};
{NULL, NULL, 0, NULL}
};
-/*
- * Do any per-module initialization. e.g. set up connections
- * to external databases, read configuration files, set up
- * dictionary entries, etc.
- *
- * Try to avoid putting too much stuff in here - it's better to
- * do it in instantiate() where it is not global.
- */
-static int python_init(void)
-{
- /*
- * Initialize Python interpreter. Fatal error if this fails.
- */
- Py_Initialize();
-
- radlog(L_DBG, "python_init done");
-
- return 0;
-}
/* Extract string representation of Python error. */
static void python_error(void) {
int idx;
/*
- * Set up a storage area for instance data
- */
+ * Initialize Python interpreter. Fatal error if this fails.
+ */
+ Py_Initialize();
+
+ /*
+ * Set up a storage area for instance data
+ */
data = rad_malloc(sizeof(*data));
if (!data) {
return -1;
* is single-threaded.
*/
module_t rlm_python = {
+ RLM_MODULE_INIT,
"python",
RLM_TYPE_THREAD_SAFE, /* type */
- python_init, /* initialization */
python_instantiate, /* instantiation */
+ python_detach, /* detach */
{
python_authenticate, /* authentication */
python_authorize, /* authorization */
NULL, /* post-proxy */
NULL /* post-auth */
},
- python_detach, /* detach */
- NULL, /* destroy */
};
/* globally exported name */
module_t rlm_radutmp = {
- "radutmp",
- 0, /* type: reserved */
- NULL, /* initialization */
- radutmp_instantiate, /* instantiation */
- {
- NULL, /* authentication */
- NULL, /* authorization */
- NULL, /* preaccounting */
- radutmp_accounting, /* accounting */
- radutmp_checksimul, /* checksimul */
- NULL, /* pre-proxy */
- NULL, /* post-proxy */
- NULL /* post-auth */
- },
- radutmp_detach, /* detach */
- NULL, /* destroy */
+ RLM_MODULE_INIT,
+ "radutmp",
+ 0, /* type: reserved */
+ radutmp_instantiate, /* instantiation */
+ radutmp_detach, /* detach */
+ {
+ NULL, /* authentication */
+ NULL, /* authorization */
+ NULL, /* preaccounting */
+ radutmp_accounting, /* accounting */
+ radutmp_checksimul, /* checksimul */
+ NULL, /* pre-proxy */
+ NULL, /* post-proxy */
+ NULL /* post-auth */
+ },
};
/* globally exported name */
module_t rlm_realm = {
- "realm",
- 0, /* type: reserved */
- NULL, /* initialization */
- realm_instantiate, /* instantiation */
- {
- NULL, /* authentication */
- realm_authorize, /* authorization */
- realm_preacct, /* preaccounting */
- NULL, /* accounting */
- NULL, /* checksimul */
- NULL, /* pre-proxy */
- NULL, /* post-proxy */
- NULL /* post-auth */
- },
- realm_detach, /* detach */
- NULL, /* destroy */
+ RLM_MODULE_INIT,
+ "realm",
+ 0, /* type: reserved */
+ realm_instantiate, /* instantiation */
+ realm_detach, /* detach */
+ {
+ NULL, /* authentication */
+ realm_authorize, /* authorization */
+ realm_preacct, /* preaccounting */
+ NULL, /* accounting */
+ NULL, /* checksimul */
+ NULL, /* pre-proxy */
+ NULL, /* post-proxy */
+ NULL /* post-auth */
+ },
};
/* globally exported name */
module_t rlm_sim_files = {
+ RLM_MODULE_INIT,
"sim_files",
0, /* type: reserved */
- NULL, /* initialization */
sim_file_instantiate, /* instantiation */
+ sim_file_detach, /* detach */
{
NULL, /* authentication */
sim_file_authorize, /* authorization */
NULL, /* post-proxy */
NULL /* post-auth */
},
- sim_file_detach, /* detach */
- NULL /* destroy */
};
* is single-threaded.
*/
module_t rlm_smb = {
+ RLM_MODULE_INIT,
"SMB",
RLM_TYPE_THREAD_UNSAFE, /* type */
- NULL, /* initialization */
smb_instantiate, /* instantiation */
+ smb_detach, /* detach */
{
smb_authenticate, /* authentication */
NULL, /* authorization */
NULL, /* post-proxy */
NULL /* post-auth */
},
- smb_detach, /* detach */
- NULL, /* destroy */
};
}
-/***********************************************************************
- * start of main routines
- ***********************************************************************/
-static int rlm_sql_init(void) {
-
- /*
- * FIXME:
- * We should put the sqlsocket array here once
- * the module code is reworked to not unload
- * modules on HUP. This way we can have
- * persistant connections. -jcarneal
- */
- return 0;
-}
/*
* Yucky prototype.
return RLM_MODULE_OK;
}
-static int rlm_sql_destroy(void)
-{
- return 0;
-}
-
static int rlm_sql_authorize(void *instance, REQUEST * request)
{
/* globally exported name */
module_t rlm_sql = {
+ RLM_MODULE_INIT,
"SQL",
RLM_TYPE_THREAD_SAFE, /* type: reserved */
- rlm_sql_init, /* initialization */
rlm_sql_instantiate, /* instantiation */
+ rlm_sql_detach, /* detach */
{
NULL, /* authentication */
rlm_sql_authorize, /* authorization */
NULL, /* post-proxy */
rlm_sql_postauth /* post-auth */
},
- rlm_sql_detach, /* detach */
- rlm_sql_destroy, /* destroy */
};
* is single-threaded.
*/
module_t rlm_sql_log = {
+ RLM_MODULE_INIT,
"sql_log",
RLM_TYPE_THREAD_SAFE, /* type */
- NULL, /* initialization */
sql_log_instantiate, /* instantiation */
+ sql_log_detach, /* detach */
{
NULL, /* authentication */
NULL, /* authorization */
NULL, /* post-proxy */
sql_log_postauth /* post-auth */
},
- sql_log_detach, /* detach */
- NULL, /* destroy */
};
* is single-threaded.
*/
module_t rlm_sqlcounter = {
+ RLM_MODULE_INIT,
"SQL Counter",
RLM_TYPE_THREAD_SAFE, /* type */
- NULL, /* initialization */
sqlcounter_instantiate, /* instantiation */
+ sqlcounter_detach, /* detach */
{
NULL, /* authentication */
sqlcounter_authorize, /* authorization */
NULL, /* post-proxy */
NULL /* post-auth */
},
- sqlcounter_detach, /* detach */
- NULL, /* destroy */
};
/*
- * Done once when the module is loaded, and NOT on a per-instance
- * basis.
- */
-static int unix_init(void)
-{
- /* FIXME - delay these until a group file has been read so we know
- * groupcmp can actually do something */
- paircompare_register(PW_GROUP, PW_USER_NAME, groupcmp, NULL);
-#ifdef PW_GROUP_NAME /* compat */
- paircompare_register(PW_GROUP_NAME, PW_USER_NAME, groupcmp, NULL);
-#endif
- return 0;
-}
-
-
-/*
* Detach.
*/
static int unix_detach(void *instance)
#define inst ((struct unix_instance *)instance)
if (inst->radwtmp)
free(inst->radwtmp);
+
+ paircompare_unregister(PW_GROUP, groupcmp);
+#ifdef PW_GROUP_NAME
+ paircompare_unregister(PW_GROUP_NAME, groupcmp);
+#endif
#undef inst
free(instance);
return 0;
return -1;
}
-#undef inst
-
- return 0;
-}
-
+ /* FIXME - delay these until a group file has been read so we know
+ * groupcmp can actually do something */
+ paircompare_register(PW_GROUP, PW_USER_NAME, groupcmp, NULL);
+#ifdef PW_GROUP_NAME /* compat */
+ paircompare_register(PW_GROUP_NAME, PW_USER_NAME, groupcmp, NULL);
+#endif
+#undef inst
-static int unix_destroy(void)
-{
- paircompare_unregister(PW_GROUP, groupcmp);
-#ifdef PW_GROUP_NAME
- paircompare_unregister(PW_GROUP_NAME, groupcmp);
-#endif
return 0;
}
/* globally exported name */
module_t rlm_unix = {
- "System",
- RLM_TYPE_THREAD_UNSAFE, /* type */
- unix_init, /* initialization */
- unix_instantiate, /* instantiation */
- {
- unix_authenticate, /* authentication */
- unix_authorize, /* authorization */
- NULL, /* preaccounting */
- unix_accounting, /* accounting */
- NULL, /* checksimul */
- NULL, /* pre-proxy */
- NULL, /* post-proxy */
- NULL /* post-auth */
- },
- unix_detach, /* detach */
- unix_destroy, /* destroy */
+ RLM_MODULE_INIT,
+ "System",
+ RLM_TYPE_THREAD_UNSAFE, /* type */
+ unix_instantiate, /* instantiation */
+ unix_detach, /* detach */
+ {
+ unix_authenticate, /* authentication */
+ unix_authorize, /* authorization */
+ NULL, /* preaccounting */
+ unix_accounting, /* accounting */
+ NULL, /* checksimul */
+ NULL, /* pre-proxy */
+ NULL, /* post-proxy */
+ NULL /* post-auth */
+ },
};