| 142 |
|
* side effects - loads a module if successful |
| 143 |
|
*/ |
| 144 |
|
int |
| 145 |
< |
load_a_module(const char *path, int warn, int core) |
| 145 |
> |
load_a_module(const char *path, int warn) |
| 146 |
|
{ |
| 147 |
|
lt_dlhandle tmpptr = NULL; |
| 148 |
|
const char *mod_basename = NULL; |
| 174 |
|
if (EmptyString(modp->version)) |
| 175 |
|
modp->version = unknown_ver; |
| 176 |
|
|
| 177 |
– |
if (core) |
| 178 |
– |
modp->flags |= MODULE_FLAG_CORE; |
| 179 |
– |
|
| 177 |
|
DupString(modp->name, mod_basename); |
| 178 |
|
dlinkAdd(modp, &modp->node, &modules_list); |
| 179 |
|
|
| 226 |
|
mod_find_path(const char *path) |
| 227 |
|
{ |
| 228 |
|
dlink_node *ptr; |
| 232 |
– |
struct module_path *mpath; |
| 229 |
|
|
| 230 |
|
DLINK_FOREACH(ptr, mod_paths.head) |
| 231 |
|
{ |
| 232 |
< |
mpath = ptr->data; |
| 232 |
> |
struct module_path *mpath = ptr->data; |
| 233 |
|
|
| 234 |
|
if (!strcmp(path, mpath->path)) |
| 235 |
|
return mpath; |
| 284 |
|
void |
| 285 |
|
mod_clear_paths(void) |
| 286 |
|
{ |
| 291 |
– |
struct module_path *pathst = NULL; |
| 287 |
|
dlink_node *ptr = NULL, *next_ptr = NULL; |
| 288 |
|
|
| 289 |
|
DLINK_FOREACH_SAFE(ptr, next_ptr, mod_paths.head) |
| 290 |
|
{ |
| 291 |
< |
pathst = ptr->data; |
| 292 |
< |
|
| 298 |
< |
dlinkDelete(&pathst->node, &mod_paths); |
| 299 |
< |
MyFree(pathst); |
| 291 |
> |
dlinkDelete(ptr, &mod_paths); |
| 292 |
> |
MyFree(ptr->data); |
| 293 |
|
} |
| 294 |
|
|
| 295 |
|
DLINK_FOREACH_SAFE(ptr, next_ptr, conf_modules.head) |
| 296 |
|
{ |
| 297 |
< |
pathst = ptr->data; |
| 298 |
< |
|
| 306 |
< |
dlinkDelete(&pathst->node, &conf_modules); |
| 307 |
< |
MyFree(pathst); |
| 297 |
> |
dlinkDelete(ptr, &conf_modules); |
| 298 |
> |
MyFree(ptr->data); |
| 299 |
|
} |
| 300 |
|
} |
| 301 |
|
|
| 334 |
|
struct dirent *ldirent = NULL; |
| 335 |
|
char module_fq_name[PATH_MAX + 1]; |
| 336 |
|
|
| 346 |
– |
modules_init(); |
| 347 |
– |
|
| 337 |
|
if ((system_module_dir = opendir(AUTOMODPATH)) == NULL) |
| 338 |
|
{ |
| 339 |
|
ilog(LOG_TYPE_IRCD, "Could not load modules from %s: %s", |
| 347 |
|
{ |
| 348 |
|
snprintf(module_fq_name, sizeof(module_fq_name), "%s/%s", |
| 349 |
|
AUTOMODPATH, ldirent->d_name); |
| 350 |
< |
load_a_module(module_fq_name, warn, 0); |
| 350 |
> |
load_a_module(module_fq_name, warn); |
| 351 |
|
} |
| 352 |
|
} |
| 353 |
|
|
| 364 |
|
load_conf_modules(void) |
| 365 |
|
{ |
| 366 |
|
dlink_node *ptr = NULL; |
| 378 |
– |
struct module_path *mpath = NULL; |
| 367 |
|
|
| 368 |
|
DLINK_FOREACH(ptr, conf_modules.head) |
| 369 |
|
{ |
| 370 |
< |
mpath = ptr->data; |
| 370 |
> |
struct module_path *mpath = ptr->data; |
| 371 |
|
|
| 372 |
|
if (findmodule_byname(mpath->path) == NULL) |
| 373 |
< |
load_one_module(mpath->path, 0); |
| 373 |
> |
load_one_module(mpath->path); |
| 374 |
|
} |
| 375 |
|
} |
| 376 |
|
|
| 391 |
|
snprintf(module_name, sizeof(module_name), "%s%s", |
| 392 |
|
MODPATH, core_module_table[i]); |
| 393 |
|
|
| 394 |
< |
if (load_a_module(module_name, warn, 1) == -1) |
| 394 |
> |
if (load_a_module(module_name, warn) == -1) |
| 395 |
|
{ |
| 396 |
|
ilog(LOG_TYPE_IRCD, "Error loading core module %s: terminating ircd", |
| 397 |
|
core_module_table[i]); |
| 408 |
|
* side effects - module is loaded if found. |
| 409 |
|
*/ |
| 410 |
|
int |
| 411 |
< |
load_one_module(const char *path, int coremodule) |
| 411 |
> |
load_one_module(const char *path) |
| 412 |
|
{ |
| 413 |
|
dlink_node *ptr = NULL; |
| 414 |
|
char modpath[PATH_MAX + 1]; |
| 425 |
|
|
| 426 |
|
if (strstr(modpath, "../") == NULL && |
| 427 |
|
strstr(modpath, "/..") == NULL) |
| 440 |
– |
{ |
| 428 |
|
if (!stat(modpath, &statbuf)) |
| 429 |
< |
{ |
| 430 |
< |
if (S_ISREG(statbuf.st_mode)) |
| 444 |
< |
{ |
| 445 |
< |
/* Regular files only please */ |
| 446 |
< |
return load_a_module(modpath, 1, coremodule); |
| 447 |
< |
} |
| 448 |
< |
} |
| 449 |
< |
} |
| 429 |
> |
if (S_ISREG(statbuf.st_mode)) /* Regular files only please */ |
| 430 |
> |
return load_a_module(modpath, 1); |
| 431 |
|
} |
| 432 |
|
|
| 433 |
|
sendto_realops_flags(UMODE_ALL, L_ALL, |
| 459 |
|
return; |
| 460 |
|
} |
| 461 |
|
|
| 462 |
< |
load_one_module(parv[1], 0); |
| 462 |
> |
load_one_module(parv[1]); |
| 463 |
|
} |
| 464 |
|
|
| 465 |
|
/* unload a module .. */ |
| 535 |
|
return; |
| 536 |
|
} |
| 537 |
|
|
| 538 |
< |
if ((load_one_module(parv[1], check_core) == -1) && check_core) |
| 538 |
> |
if ((load_one_module(parv[1]) == -1) && check_core) |
| 539 |
|
{ |
| 540 |
|
sendto_realops_flags(UMODE_ALL, L_ALL, "Error reloading core " |
| 541 |
|
"module: %s: terminating ircd", parv[1]); |