38 |
|
#include "memory.h" |
39 |
|
#include "list.h" |
40 |
|
|
41 |
– |
/* -TimeMr14C: |
42 |
– |
* I have moved the dl* function definitions and |
43 |
– |
* the two functions (load_a_module / unload_a_module) to the |
44 |
– |
* file dynlink.c |
45 |
– |
* And also made the necessary changes to those functions |
46 |
– |
* to comply with shl_load and friends. |
47 |
– |
* In this file, to keep consistency with the makefile, |
48 |
– |
* I added the ability to load *.sl files, too. |
49 |
– |
* 27/02/2002 |
50 |
– |
*/ |
51 |
– |
|
52 |
– |
#ifndef STATIC_MODULES |
41 |
|
|
42 |
|
dlink_list mod_list = { NULL, NULL, 0 }; |
43 |
|
|
44 |
|
static const char *core_module_table[] = |
45 |
|
{ |
46 |
< |
"m_die", |
47 |
< |
"m_join", |
48 |
< |
"m_kick", |
49 |
< |
"m_kill", |
50 |
< |
"m_message", |
51 |
< |
"m_mode", |
52 |
< |
"m_nick", |
53 |
< |
"m_part", |
54 |
< |
"m_quit", |
55 |
< |
"m_server", |
56 |
< |
"m_sjoin", |
57 |
< |
"m_squit", |
46 |
> |
"m_die.la", |
47 |
> |
"m_error.la", |
48 |
> |
"m_join.la", |
49 |
> |
"m_kick.la", |
50 |
> |
"m_kill.la", |
51 |
> |
"m_message.la", |
52 |
> |
"m_mode.la", |
53 |
> |
"m_nick.la", |
54 |
> |
"m_part.la", |
55 |
> |
"m_quit.la", |
56 |
> |
"m_server.la", |
57 |
> |
"m_sjoin.la", |
58 |
> |
"m_squit.la", |
59 |
|
NULL |
60 |
|
}; |
61 |
|
|
106 |
|
void |
107 |
|
modules_init(void) |
108 |
|
{ |
109 |
+ |
dynlink_init(); |
110 |
+ |
|
111 |
|
mod_add_cmd(&modload_msgtab); |
112 |
|
mod_add_cmd(&modunload_msgtab); |
113 |
|
mod_add_cmd(&modreload_msgtab); |
114 |
|
mod_add_cmd(&modlist_msgtab); |
115 |
|
mod_add_cmd(&modrestart_msgtab); |
125 |
– |
mod_add_cmd(&error_msgtab); |
116 |
|
} |
117 |
|
|
118 |
|
/* mod_find_path() |
252 |
|
|
253 |
|
while ((ldirent = readdir(system_module_dir)) != NULL) |
254 |
|
{ |
255 |
< |
const char *offset = strrchr(ldirent->d_name, '.'); |
266 |
< |
|
267 |
< |
if (offset && !strcmp(offset, SHARED_SUFFIX)) |
255 |
> |
if (modules_valid_suffix(ldirent->d_name)) |
256 |
|
{ |
257 |
|
snprintf(module_fq_name, sizeof(module_fq_name), "%s/%s", |
258 |
|
AUTOMODPATH, ldirent->d_name); |
298 |
|
|
299 |
|
for (; core_module_table[i]; ++i) |
300 |
|
{ |
301 |
< |
snprintf(module_name, sizeof(module_name), "%s%s%s", MODPATH, |
302 |
< |
core_module_table[i], SHARED_SUFFIX); |
301 |
> |
snprintf(module_name, sizeof(module_name), "%s%s", |
302 |
> |
MODPATH, core_module_table[i]); |
303 |
|
|
304 |
|
if (load_a_module(module_name, warn, 1) == -1) |
305 |
|
{ |
306 |
< |
ilog(L_CRIT, "Error loading core module %s%s: terminating ircd", |
307 |
< |
core_module_table[i], SHARED_SUFFIX); |
306 |
> |
ilog(L_CRIT, "Error loading core module %s: terminating ircd", |
307 |
> |
core_module_table[i]); |
308 |
|
exit(EXIT_FAILURE); |
309 |
|
} |
310 |
|
} |
318 |
|
* side effects - module is loaded if found. |
319 |
|
*/ |
320 |
|
int |
321 |
< |
load_one_module(char *path, int coremodule) |
321 |
> |
load_one_module(const char *path, int coremodule) |
322 |
|
{ |
323 |
|
dlink_node *ptr = NULL; |
324 |
|
char modpath[PATH_MAX + 1]; |
330 |
|
|
331 |
|
snprintf(modpath, sizeof(modpath), "%s/%s", mpath->path, path); |
332 |
|
|
333 |
+ |
if (!modules_valid_suffix(path)) |
334 |
+ |
continue; |
335 |
+ |
|
336 |
|
if (strstr(modpath, "../") == NULL && |
337 |
|
strstr(modpath, "/..") == NULL) |
338 |
|
{ |
358 |
|
mo_modload(struct Client *client_p, struct Client *source_p, |
359 |
|
int parc, char *parv[]) |
360 |
|
{ |
361 |
< |
char *m_bn; |
361 |
> |
const char *m_bn = NULL; |
362 |
|
|
363 |
|
if (!IsAdmin(source_p)) |
364 |
|
{ |
367 |
|
return; |
368 |
|
} |
369 |
|
|
370 |
< |
m_bn = basename(parv[1]); |
370 |
> |
m_bn = libio_basename(parv[1]); |
371 |
|
|
372 |
|
if (findmodule_byname(m_bn) != NULL) |
373 |
|
{ |
384 |
|
mo_modunload(struct Client *client_p, struct Client *source_p, |
385 |
|
int parc, char *parv[]) |
386 |
|
{ |
387 |
< |
char *m_bn; |
387 |
> |
const char *m_bn = NULL; |
388 |
|
dlink_node *ptr; |
389 |
|
struct module *modp; |
390 |
|
|
395 |
|
return; |
396 |
|
} |
397 |
|
|
398 |
< |
m_bn = basename(parv[1]); |
398 |
> |
m_bn = libio_basename(parv[1]); |
399 |
|
|
400 |
|
if ((ptr = findmodule_byname(m_bn)) == NULL) |
401 |
|
{ |
428 |
|
mo_modreload(struct Client *client_p, struct Client *source_p, |
429 |
|
int parc, char *parv[]) |
430 |
|
{ |
431 |
< |
char *m_bn; |
431 |
> |
const char *m_bn = NULL; |
432 |
|
dlink_node *ptr; |
433 |
|
struct module *modp; |
434 |
|
int check_core; |
440 |
|
return; |
441 |
|
} |
442 |
|
|
443 |
< |
m_bn = basename(parv[1]); |
443 |
> |
m_bn = libio_basename(parv[1]); |
444 |
|
|
445 |
|
if ((ptr = findmodule_byname(m_bn)) == NULL) |
446 |
|
{ |
473 |
|
mo_modlist(struct Client *client_p, struct Client *source_p, |
474 |
|
int parc, char *parv[]) |
475 |
|
{ |
476 |
< |
dlink_node *ptr; |
486 |
< |
struct module *modp; |
476 |
> |
const dlink_node *ptr = NULL; |
477 |
|
|
478 |
|
if (!IsAdmin(source_p)) |
479 |
|
{ |
484 |
|
|
485 |
|
DLINK_FOREACH(ptr, mod_list.head) |
486 |
|
{ |
487 |
< |
modp = ptr->data; |
487 |
> |
const struct module *modp = ptr->data; |
488 |
|
|
489 |
< |
if (parc > 1) |
490 |
< |
{ |
491 |
< |
if (match(parv[1], modp->name)) |
492 |
< |
{ |
493 |
< |
sendto_one(source_p, form_str(RPL_MODLIST), me.name, parv[0], |
494 |
< |
modp->name, modp->address, |
505 |
< |
modp->version, modp->core?"(core)":""); |
506 |
< |
} |
507 |
< |
} |
508 |
< |
else |
509 |
< |
{ |
510 |
< |
sendto_one(source_p, form_str(RPL_MODLIST), me.name, parv[0], |
511 |
< |
modp->name, modp->address, |
512 |
< |
modp->version, modp->core?"(core)":""); |
513 |
< |
} |
489 |
> |
if (parc > 1 && !match(parv[1], modp->name)) |
490 |
> |
continue; |
491 |
> |
|
492 |
> |
sendto_one(source_p, form_str(RPL_MODLIST), me.name, parv[0], |
493 |
> |
modp->name, modp->handle, |
494 |
> |
modp->version, modp->core?"(core)":""); |
495 |
|
} |
496 |
|
|
497 |
|
sendto_one(source_p, form_str(RPL_ENDOFMODLIST), |
504 |
|
int parc, char *parv[]) |
505 |
|
{ |
506 |
|
unsigned int modnum = 0; |
507 |
< |
dlink_node *ptr; |
508 |
< |
dlink_node *tptr; |
528 |
< |
struct module *modp; |
529 |
< |
|
507 |
> |
dlink_node *ptr = NULL, *ptr_next = NULL; |
508 |
> |
|
509 |
|
if (!IsAdmin(source_p)) |
510 |
|
{ |
511 |
|
sendto_one(source_p, form_str(ERR_NOPRIVILEGES), |
518 |
|
|
519 |
|
modnum = dlink_list_length(&mod_list); |
520 |
|
|
521 |
< |
DLINK_FOREACH_SAFE(ptr, tptr, mod_list.head) |
521 |
> |
DLINK_FOREACH_SAFE(ptr, ptr_next, mod_list.head) |
522 |
|
{ |
523 |
< |
modp = ptr->data; |
523 |
> |
struct module *modp = ptr->data; |
524 |
|
unload_one_module(modp->name, 0); |
525 |
|
} |
526 |
|
|
534 |
|
ilog(L_WARN, "Module Restart: %u modules unloaded, %lu modules loaded", |
535 |
|
modnum, dlink_list_length(&mod_list)); |
536 |
|
} |
558 |
– |
|
559 |
– |
#else /* STATIC_MODULES */ |
560 |
– |
#include "s_serv.h" |
561 |
– |
|
562 |
– |
/* load_all_modules() |
563 |
– |
* |
564 |
– |
* input - warn flag |
565 |
– |
* output - NONE |
566 |
– |
* side effects - all the msgtabs are added for static modules |
567 |
– |
*/ |
568 |
– |
void |
569 |
– |
load_all_modules(int warn) |
570 |
– |
{ |
571 |
– |
mod_add_cmd(&error_msgtab); |
572 |
– |
mod_add_cmd(&accept_msgtab); |
573 |
– |
mod_add_cmd(&admin_msgtab); |
574 |
– |
mod_add_cmd(&away_msgtab); |
575 |
– |
mod_add_cmd(&capab_msgtab); |
576 |
– |
mod_add_cmd(&cburst_msgtab); |
577 |
– |
mod_add_cmd(&close_msgtab); |
578 |
– |
mod_add_cmd(&connect_msgtab); |
579 |
– |
#ifdef HAVE_LIBCRYPTO |
580 |
– |
mod_add_cmd(&challenge_msgtab); |
581 |
– |
mod_add_cmd(&cryptlink_msgtab); |
582 |
– |
#endif |
583 |
– |
mod_add_cmd(&die_msgtab); |
584 |
– |
mod_add_cmd(&drop_msgtab); |
585 |
– |
mod_add_cmd(&eob_msgtab); |
586 |
– |
mod_add_cmd(&etrace_msgtab); |
587 |
– |
mod_add_cmd(&gline_msgtab); |
588 |
– |
add_capability("GLN", CAP_GLN, 1); |
589 |
– |
mod_add_cmd(&hash_msgtab); |
590 |
– |
mod_add_cmd(&ungline_msgtab); |
591 |
– |
mod_add_cmd(&info_msgtab); |
592 |
– |
mod_add_cmd(&invite_msgtab); |
593 |
– |
mod_add_cmd(&ison_msgtab); |
594 |
– |
mod_add_cmd(&join_msgtab); |
595 |
– |
mod_add_cmd(&kick_msgtab); |
596 |
– |
mod_add_cmd(&kill_msgtab); |
597 |
– |
mod_add_cmd(&kline_msgtab); |
598 |
– |
add_capability("KLN", CAP_KLN, 1); |
599 |
– |
mod_add_cmd(&dline_msgtab); |
600 |
– |
mod_add_cmd(&unkline_msgtab); |
601 |
– |
mod_add_cmd(&undline_msgtab); |
602 |
– |
mod_add_cmd(&knock_msgtab); |
603 |
– |
add_capability("KNOCK", CAP_KNOCK, 1); |
604 |
– |
mod_add_cmd(&knockll_msgtab); |
605 |
– |
mod_add_cmd(&links_msgtab); |
606 |
– |
mod_add_cmd(&list_msgtab); |
607 |
– |
mod_add_cmd(&lljoin_msgtab); |
608 |
– |
mod_add_cmd(&llnick_msgtab); |
609 |
– |
mod_add_cmd(&locops_msgtab); |
610 |
– |
mod_add_cmd(&lusers_msgtab); |
611 |
– |
mod_add_cmd(&privmsg_msgtab); |
612 |
– |
mod_add_cmd(¬ice_msgtab); |
613 |
– |
mod_add_cmd(&map_msgtab); |
614 |
– |
mod_add_cmd(&mode_msgtab); |
615 |
– |
mod_add_cmd(&motd_msgtab); |
616 |
– |
mod_add_cmd(&names_msgtab); |
617 |
– |
mod_add_cmd(&nburst_msgtab); |
618 |
– |
mod_add_cmd(&nick_msgtab); |
619 |
– |
mod_add_cmd(&omotd_msgtab); |
620 |
– |
mod_add_cmd(&oper_msgtab); |
621 |
– |
mod_add_cmd(&operwall_msgtab); |
622 |
– |
mod_add_cmd(&part_msgtab); |
623 |
– |
mod_add_cmd(&pass_msgtab); |
624 |
– |
mod_add_cmd(&ping_msgtab); |
625 |
– |
mod_add_cmd(&pong_msgtab); |
626 |
– |
mod_add_cmd(&post_msgtab); |
627 |
– |
mod_add_cmd(&get_msgtab); |
628 |
– |
mod_add_cmd(&put_msgtab); |
629 |
– |
mod_add_cmd(&quit_msgtab); |
630 |
– |
mod_add_cmd(&rehash_msgtab); |
631 |
– |
mod_add_cmd(&restart_msgtab); |
632 |
– |
mod_add_cmd(&resv_msgtab); |
633 |
– |
mod_add_cmd(&rkline_msgtab); |
634 |
– |
mod_add_cmd(&rxline_msgtab); |
635 |
– |
mod_add_cmd(&server_msgtab); |
636 |
– |
mod_add_cmd(&set_msgtab); |
637 |
– |
mod_add_cmd(&sid_msgtab); |
638 |
– |
mod_add_cmd(&sjoin_msgtab); |
639 |
– |
mod_add_cmd(&squit_msgtab); |
640 |
– |
mod_add_cmd(&stats_msgtab); |
641 |
– |
mod_add_cmd(&svinfo_msgtab); |
642 |
– |
mod_add_cmd(&tb_msgtab); |
643 |
– |
add_capability("TB", CAP_TB, 1); |
644 |
– |
mod_add_cmd(&tburst_msgtab); |
645 |
– |
add_capability("TBURST", CAP_TBURST, 1); |
646 |
– |
mod_add_cmd(&testline_msgtab); |
647 |
– |
mod_add_cmd(&testgecos_msgtab); |
648 |
– |
mod_add_cmd(&testmask_msgtab); |
649 |
– |
mod_add_cmd(&time_msgtab); |
650 |
– |
mod_add_cmd(&topic_msgtab); |
651 |
– |
mod_add_cmd(&trace_msgtab); |
652 |
– |
add_capability("UNKLN", CAP_UNKLN, 1); |
653 |
– |
mod_add_cmd(&uid_msgtab); |
654 |
– |
mod_add_cmd(&unresv_msgtab); |
655 |
– |
mod_add_cmd(&unxline_msgtab); |
656 |
– |
mod_add_cmd(&user_msgtab); |
657 |
– |
mod_add_cmd(&userhost_msgtab); |
658 |
– |
mod_add_cmd(&users_msgtab); |
659 |
– |
mod_add_cmd(&version_msgtab); |
660 |
– |
mod_add_cmd(&wallops_msgtab); |
661 |
– |
mod_add_cmd(&who_msgtab); |
662 |
– |
mod_add_cmd(&whois_msgtab); |
663 |
– |
mod_add_cmd(&whowas_msgtab); |
664 |
– |
mod_add_cmd(&xline_msgtab); |
665 |
– |
mod_add_cmd(&help_msgtab); |
666 |
– |
mod_add_cmd(&uhelp_msgtab); |
667 |
– |
#ifdef BUILD_CONTRIB |
668 |
– |
mod_add_cmd(&botserv_msgtab); |
669 |
– |
mod_add_cmd(&capture_msgtab); |
670 |
– |
mod_add_cmd(&chanserv_msgtab); |
671 |
– |
mod_add_cmd(&chghost_msgtab); |
672 |
– |
mod_add_cmd(&chgident_msgtab); |
673 |
– |
mod_add_cmd(&chgname_msgtab); |
674 |
– |
mod_add_cmd(&classlist_msgtab); |
675 |
– |
mod_add_cmd(&clearchan_msgtab); |
676 |
– |
mod_add_cmd(&cs_msgtab); |
677 |
– |
mod_add_cmd(&ctrace_msgtab); |
678 |
– |
mod_add_cmd(&delspoof_msgtab); |
679 |
– |
mod_add_cmd(&flags_msgtab); |
680 |
– |
mod_add_cmd(&forcejoin_msgtab); |
681 |
– |
mod_add_cmd(&forcepart_msgtab); |
682 |
– |
mod_add_cmd(&global_msgtab); |
683 |
– |
mod_add_cmd(&help_msgtab); |
684 |
– |
mod_add_cmd(&uhelp_msgtab); |
685 |
– |
mod_add_cmd(&helpserv_msgtab); |
686 |
– |
mod_add_cmd(&hostserv_msgtab); |
687 |
– |
mod_add_cmd(&identify_msgtab); |
688 |
– |
mod_add_cmd(&jupe_msgtab); |
689 |
– |
mod_add_cmd(&killhost_msgtab); |
690 |
– |
mod_add_cmd(<race_msgtab); |
691 |
– |
mod_add_cmd(&memoserv_msgtab); |
692 |
– |
mod_add_cmd(&mkpasswd_msgtab); |
693 |
– |
mod_add_cmd(&ms_msgtab); |
694 |
– |
mod_add_cmd(&nickserv_msgtab); |
695 |
– |
mod_add_cmd(&ns_msgtab); |
696 |
– |
mod_add_cmd(&ojoin_msgtab); |
697 |
– |
mod_add_cmd(&operserv_msgtab); |
698 |
– |
mod_add_cmd(&operspy_msgtab); |
699 |
– |
mod_add_cmd(&opme_msgtab); |
700 |
– |
mod_add_cmd(&os_msgtab); |
701 |
– |
mod_add_cmd(&seenserv_msgtab); |
702 |
– |
mod_add_cmd(&spoof_msgtab); |
703 |
– |
mod_add_cmd(&statserv_msgtab); |
704 |
– |
mod_add_cmd(&svsnick_msgtab); |
705 |
– |
mod_add_cmd(&uncapture_msgtab); |
706 |
– |
/* FIXME: what about spy*? */ |
707 |
– |
#endif |
708 |
– |
} |
709 |
– |
#endif /* STATIC_MODULES */ |