static int dynmasq_init(void) { #if defined(PR_SHARED_MODULE) pr_event_register(&dynmasq_module, "core.module-unload", dynmasq_mod_unload_ev, NULL); #endif /* !PR_SHARED_MODULE */ pr_event_register(&dynmasq_module, "core.postparse", dynmasq_postparse_ev, NULL); pr_event_register(&dynmasq_module, "core.restart", dynmasq_restart_ev, NULL); #ifdef PR_USE_CTRLS if (pr_ctrls_register(&dynmasq_module, "dynmasq", "mod_dynmasq controls", dynmasq_handle_dynmasq) < 0) { pr_log_pri(PR_LOG_NOTICE, MOD_DYNMASQ_VERSION ": error registering 'dynmasq' control: %s", strerror(errno)); } else { register unsigned int i; dynmasq_act_pool = make_sub_pool(permanent_pool); pr_pool_tag(dynmasq_act_pool, "DynMasq Controls Pool"); for (i = 0; dynmasq_acttab[i].act_action; i++) { dynmasq_acttab[i].act_acl = palloc(dynmasq_act_pool, sizeof(ctrls_acl_t)); pr_ctrls_init_acl(dynmasq_acttab[i].act_acl); } } #endif /* PR_USE_CTRLS */ return 0; }
static int dso_init(void) { #ifdef PR_USE_CTRLS register unsigned int i = 0; #endif /* PR_USE_CTRLS */ /* Allocate the pool for this module's use. */ dso_pool = make_sub_pool(permanent_pool); pr_pool_tag(dso_pool, MOD_DSO_VERSION); lt_dlpreload_default(lt_preloaded_symbols); /* Initialize libltdl. */ if (lt_dlinit() < 0) { pr_log_pri(PR_LOG_ERR, MOD_DSO_VERSION ": error initializing libltdl: %s", lt_dlerror()); return -1; } /* Explicitly set the search path used for opening modules. */ if (lt_dlsetsearchpath(dso_module_path) < 0) { pr_log_pri(PR_LOG_ERR, MOD_DSO_VERSION ": error setting module path: %s", lt_dlerror()); return -1; } #ifdef PR_USE_CTRLS /* Register ctrls handlers. */ for (i = 0; dso_acttab[i].act_action; i++) { pool *sub_pool = make_sub_pool(dso_pool); /* Allocate and initialize the ACL for this control. */ dso_acttab[i].act_acl = pcalloc(sub_pool, sizeof(ctrls_acl_t)); dso_acttab[i].act_acl->acl_pool = sub_pool; pr_ctrls_init_acl(dso_acttab[i].act_acl); if (pr_ctrls_register(&dso_module, dso_acttab[i].act_action, dso_acttab[i].act_desc, dso_acttab[i].act_cb) < 0) pr_log_pri(PR_LOG_INFO, MOD_DSO_VERSION ": error registering '%s' control: %s", dso_acttab[i].act_action, strerror(errno)); } #endif /* PR_USE_CTRLS */ /* Ideally, we'd call register a listener for the 'core.exit' event * and call lt_dlexit() there, politely freeing up any resources allocated * by the ltdl library. However, it's possible that other modules, later in * the dispatch cycles, may need to use pointers to memory in shared modules * that would become invalid by such finalization. So we skip it, for now. * * If there was a way to schedule this handler, to happen after all other * exit handlers, that'd be best. */ pr_event_register(&dso_module, "core.restart", dso_restart_ev, NULL); return 0; }