ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/trunk/src/modules.c
(Generate patch)

Comparing:
ircd-hybrid-8/src/modules.c (file contents), Revision 1404 by michael, Thu May 10 20:41:45 2012 UTC vs.
ircd-hybrid/trunk/src/modules.c (file contents), Revision 1592 by michael, Sat Oct 27 21:02:32 2012 UTC

# Line 39 | Line 39
39   #include "memory.h"
40  
41  
42 < static dlink_list modules_list = { NULL, NULL, 0 };
42 > dlink_list modules_list = { NULL, NULL, 0 };
43  
44   static const char *unknown_ver = "<unknown>";
45  
# Line 64 | Line 64 | static const char *core_module_table[] =
64   static dlink_list mod_paths = { NULL, NULL, 0 };
65   static dlink_list conf_modules = { NULL, NULL, 0 };
66  
67 – static void mo_modload(struct Client *, struct Client *, int, char *[]);
68 – static void mo_modlist(struct Client *, struct Client *, int, char *[]);
69 – static void mo_modreload(struct Client *, struct Client *, int, char *[]);
70 – static void mo_modunload(struct Client *, struct Client *, int, char *[]);
71 – static void mo_modrestart(struct Client *, struct Client *, int, char *[]);
72 –
73 – struct Message modload_msgtab = {
74 – "MODLOAD", 0, 0, 2, 0, MFLG_SLOW, 0,
75 –  {m_unregistered, m_not_oper, m_ignore, m_ignore, mo_modload, m_ignore}
76 – };
77 –
78 – struct Message modunload_msgtab = {
79 – "MODUNLOAD", 0, 0, 2, 0, MFLG_SLOW, 0,
80 –  {m_unregistered, m_not_oper, m_ignore, m_ignore, mo_modunload, m_ignore}
81 – };
82 –
83 – struct Message modreload_msgtab = {
84 –  "MODRELOAD", 0, 0, 2, 0, MFLG_SLOW, 0,
85 –  {m_unregistered, m_not_oper, m_ignore, m_ignore, mo_modreload, m_ignore}
86 – };
87 –
88 – struct Message modlist_msgtab = {
89 – "MODLIST", 0, 0, 0, 0, MFLG_SLOW, 0,
90 –  {m_unregistered, m_not_oper, m_ignore, m_ignore, mo_modlist, m_ignore}
91 – };
92 –
93 – struct Message modrestart_msgtab = {
94 – "MODRESTART", 0, 0, 0, 0, MFLG_SLOW, 0,
95 – {m_unregistered, m_not_oper, m_ignore, m_ignore, mo_modrestart, m_ignore}
96 – };
97 –
98 –
67   int
68   modules_valid_suffix(const char *name)
69   {
# Line 162 | Line 130 | load_a_module(const char *path, int warn
130  
131    if ((modp = lt_dlsym(tmpptr, "module_entry")) == NULL)
132    {
133 <    sendto_realops_flags(UMODE_ALL, L_ALL, "Module %s has no module_entry export",
134 <                         mod_basename);
135 <    ilog(LOG_TYPE_IRCD, "Module %s has no module_entry export", mod_basename);
133 >    const char *err = ((err = lt_dlerror())) ? err : "<unknown>";
134 >
135 >    sendto_realops_flags(UMODE_ALL, L_ALL, "Error loading module %s: %s",
136 >                         mod_basename, err);
137 >    ilog(LOG_TYPE_IRCD, "Error loading module %s: %s", mod_basename, err);
138      lt_dlclose(tmpptr);
139      return -1;
140    }
# Line 208 | Line 178 | modules_init(void)
178           " link library. Exiting.");
179      exit(0);
180    }
211 –
212 –  mod_add_cmd(&modload_msgtab);
213 –  mod_add_cmd(&modunload_msgtab);
214 –  mod_add_cmd(&modreload_msgtab);
215 –  mod_add_cmd(&modlist_msgtab);
216 –  mod_add_cmd(&modrestart_msgtab);
181   }
182  
183   /* mod_find_path()
# Line 435 | Line 399 | load_one_module(const char *path)
399    ilog(LOG_TYPE_IRCD, "Cannot locate module %s", path);
400    return -1;
401   }
438 –
439 – /* load a module .. */
440 – static void
441 – mo_modload(struct Client *client_p, struct Client *source_p,
442 –           int parc, char *parv[])
443 – {
444 –  const char *m_bn = NULL;
445 –
446 –  if (!HasOFlag(source_p, OPER_FLAG_MODULE))
447 –  {
448 –    sendto_one(source_p, form_str(ERR_NOPRIVILEGES),
449 –               me.name, source_p->name);
450 –    return;
451 –  }
452 –
453 –  m_bn = libio_basename(parv[1]);
454 –
455 –  if (findmodule_byname(m_bn) != NULL)
456 –  {
457 –    sendto_one(source_p, ":%s NOTICE %s :Module %s is already loaded",
458 –               me.name, source_p->name, m_bn);
459 –    return;
460 –  }
461 –
462 –  load_one_module(parv[1]);
463 – }
464 –
465 – /* unload a module .. */
466 – static void
467 – mo_modunload(struct Client *client_p, struct Client *source_p,
468 –             int parc, char *parv[])
469 – {
470 –  const char *m_bn = NULL;
471 –  struct module *modp = NULL;
472 –
473 –  if (!HasOFlag(source_p, OPER_FLAG_MODULE))
474 –  {
475 –    sendto_one(source_p, form_str(ERR_NOPRIVILEGES),
476 –               me.name, source_p->name);
477 –    return;
478 –  }
479 –
480 –  m_bn = libio_basename(parv[1]);
481 –
482 –  if ((modp = findmodule_byname(m_bn)) == NULL)
483 –  {
484 –    sendto_one(source_p, ":%s NOTICE %s :Module %s is not loaded",
485 –               me.name, source_p->name, m_bn);
486 –    return;
487 –  }
488 –
489 –  if (modp->flags & MODULE_FLAG_CORE)
490 –  {
491 –    sendto_one(source_p,
492 –               ":%s NOTICE %s :Module %s is a core module and may not be unloaded",
493 –               me.name, source_p->name, m_bn);
494 –    return;
495 –  }
496 –
497 –  if (unload_one_module(m_bn, 1) == -1)
498 –  {
499 –    sendto_one(source_p, ":%s NOTICE %s :Module %s is not loaded",
500 –               me.name, source_p->name, m_bn);
501 –  }
502 – }
503 –
504 – /* unload and load in one! */
505 – static void
506 – mo_modreload(struct Client *client_p, struct Client *source_p,
507 –             int parc, char *parv[])
508 – {
509 –  const char *m_bn = NULL;
510 –  struct module *modp = NULL;
511 –  int check_core;
512 –
513 –  if (!HasOFlag(source_p, OPER_FLAG_MODULE))
514 –  {
515 –    sendto_one(source_p, form_str(ERR_NOPRIVILEGES),
516 –               me.name, source_p->name);
517 –    return;
518 –  }
519 –
520 –  m_bn = libio_basename(parv[1]);
521 –
522 –  if ((modp = findmodule_byname(m_bn)) == NULL)
523 –  {
524 –    sendto_one(source_p, ":%s NOTICE %s :Module %s is not loaded",
525 –               me.name, source_p->name, m_bn);
526 –    return;
527 –  }
528 –
529 –  check_core = (modp->flags & MODULE_FLAG_CORE) != 0;
530 –
531 –  if (unload_one_module(m_bn, 1) == -1)
532 –  {
533 –    sendto_one(source_p, ":%s NOTICE %s :Module %s is not loaded",
534 –               me.name, source_p->name, m_bn);
535 –    return;
536 –  }
537 –
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]);
542 –    ilog(LOG_TYPE_IRCD, "Error loading core module %s: terminating ircd", parv[1]);
543 –    exit(0);
544 –  }
545 – }
546 –
547 – /* list modules .. */
548 – static void
549 – mo_modlist(struct Client *client_p, struct Client *source_p,
550 –           int parc, char *parv[])
551 – {
552 –  const dlink_node *ptr = NULL;
553 –
554 –  if (!HasOFlag(source_p, OPER_FLAG_MODULE))
555 –  {
556 –    sendto_one(source_p, form_str(ERR_NOPRIVILEGES),
557 –               me.name, source_p->name);
558 –    return;
559 –  }
560 –
561 –  DLINK_FOREACH(ptr, modules_list.head)
562 –  {
563 –    const struct module *modp = ptr->data;
564 –
565 –    if (parc > 1 && !match(parv[1], modp->name))
566 –      continue;
567 –
568 –    sendto_one(source_p, form_str(RPL_MODLIST), me.name, source_p->name,
569 –               modp->name, modp->handle,
570 –               modp->version, (modp->flags & MODULE_FLAG_CORE) ?"(core)":"");
571 –  }
572 –
573 –  sendto_one(source_p, form_str(RPL_ENDOFMODLIST),
574 –             me.name, source_p->name);
575 – }
576 –
577 – /* unload and reload all modules */
578 – static void
579 – mo_modrestart(struct Client *client_p, struct Client *source_p,
580 –              int parc, char *parv[])
581 – {
582 –  unsigned int modnum = 0;
583 –  dlink_node *ptr = NULL, *ptr_next = NULL;
584 –
585 –  if (!HasOFlag(source_p, OPER_FLAG_MODULE))
586 –  {
587 –    sendto_one(source_p, form_str(ERR_NOPRIVILEGES),
588 –               me.name, source_p->name);
589 –    return;
590 –  }
591 –
592 –  sendto_one(source_p, ":%s NOTICE %s :Reloading all modules",
593 –             me.name, source_p->name);
594 –
595 –  modnum = dlink_list_length(&modules_list);
596 –
597 –  DLINK_FOREACH_SAFE(ptr, ptr_next, modules_list.head)
598 –  {
599 –    struct module *modp = ptr->data;
600 –    unload_one_module(modp->name, 0);
601 –  }
602 –
603 –  load_all_modules(0);
604 –  load_conf_modules();
605 –  load_core_modules(0);
606 –
607 –  sendto_realops_flags(UMODE_ALL, L_ALL,
608 –                      "Module Restart: %u modules unloaded, %u modules loaded",
609 –                        modnum, dlink_list_length(&modules_list));
610 –  ilog(LOG_TYPE_IRCD, "Module Restart: %u modules unloaded, %u modules loaded",
611 –       modnum, dlink_list_length(&modules_list));
612 – }

Diff Legend

– Removed lines
+ Added lines
< Changed lines (old)
> Changed lines (new)