* FIXME: We really should have an 'init' which makes
* System auth == Unix
*/
-static int unix_init(int argc, char **argv)
+static int unix_init(void)
{
- CONF_SECTION *unix_cs;
- argc = argc; argv = argv;
+ paircompare_register(PW_GROUP, PW_USER_NAME, groupcmp);
+#ifdef PW_GROUP_NAME /* compat */
+ paircompare_register(PW_GROUP_NAME, PW_USER_NAME, groupcmp);
+#endif
+ return 0;
+}
+static int unix_instantiate(CONF_SECTION *conf, void **instance)
+{
/*
- * Look for the module's configuration.
- *
- * If it exists, go parse it, and die if the parse fails.
+ * Not yet multiple-instance-aware. groupcmp is a real
+ * obstacle.
*/
- unix_cs = cf_module_config_find("unix");
- if (unix_cs &&
- (cf_section_parse(unix_cs, module_config) < 0)) {
+ static int alreadydone=0;
+
+ if (alreadydone) {
+ log(L_ERR,
+ "rlm_unix: can't handle multiple authentication instances");
return -1;
}
-
- paircompare_register(PW_GROUP, PW_USER_NAME, groupcmp);
-#ifdef PW_GROUP_NAME /* compat */
- paircompare_register(PW_GROUP_NAME, PW_USER_NAME, groupcmp);
-#endif
+ if (cf_section_parse(conf, module_config) < 0) {
+ return -1;
+ }
+
if (cache_passwd) {
log(L_INFO, "HASH: Reinitializing hash structures "
"and lists for caching...");
}
}
+ alreadydone = 1;
+ *instance = 0;
return 0;
}
-
/*
* Detach.
*/
-static int unix_detach(void)
+static int unix_destroy(void)
{
paircompare_unregister(PW_GROUP, groupcmp);
#ifdef PW_GROUP_NAME
* Check the users password against the standard UNIX
* password table.
*/
-static int unix_authenticate(REQUEST *request)
+static int unix_authenticate(void *instance, REQUEST *request)
{
char *name, *passwd;
struct passwd *pwd;
#ifdef HAVE_GETUSERSHELL
char *shell;
#endif
+ instance = instance;
/*
* We can only authenticate user requests which HAVE
/*
* Unix accounting - write a wtmp file.
*/
-static int unix_accounting(REQUEST *request)
+static int unix_accounting(void *instance, REQUEST *request)
{
VALUE_PAIR *vp;
NAS *cl;
int port_seen = 0;
int nas_port_type = 0;
+ instance = instance;
+
/*
* Which type is this.
*/
"System",
0, /* type: reserved */
unix_init, /* initialization */
+ unix_instantiate, /* instantiation */
NULL, /* authorization */
unix_authenticate, /* authentication */
NULL, /* preaccounting */
unix_accounting, /* accounting */
- unix_detach, /* detach */
+ NULL, /* detach */
+ unix_destroy, /* destroy */
};