Exemple #1
0
static void
do_modreload(struct Client *source_p, const char *module)
{
	int modindex;
	int check_core;
	char *m_bn = rb_basename(module);

	if((modindex = findmodule_byname(m_bn)) == -1)
	{
		sendto_one_notice(source_p, ":Module %s is not loaded", m_bn);
		rb_free(m_bn);
		return;
	}

	check_core = modlist[modindex]->core;

	if(unload_one_module(m_bn, true) == false)
	{
		sendto_one_notice(source_p, ":Module %s is not loaded", m_bn);
		rb_free(m_bn);
		return;
	}

	if((load_one_module(m_bn, modlist[modindex]->origin, check_core) == false) && check_core)
	{
		sendto_realops_snomask(SNO_GENERAL, L_NETWIDE,
				     "Error reloading core module: %s: terminating ircd", m_bn);
		ilog(L_MAIN, "Error loading core module %s: terminating ircd", m_bn);
		exit(0);
	}

	rb_free(m_bn);
}
Exemple #2
0
static void
do_modunload(struct Client *source_p, const char *module)
{
	int modindex;
	char *m_bn = rb_basename(module);

	if((modindex = findmodule_byname(m_bn)) == -1)
	{
		sendto_one_notice(source_p, ":Module %s is not loaded", m_bn);
		rb_free(m_bn);
		return;
	}

	if(modlist[modindex]->core)
	{
		sendto_one_notice(source_p, ":Module %s is a core module and may not be unloaded", m_bn);
		rb_free(m_bn);
		return;
	}

	if(unload_one_module(m_bn, true) == false)
		sendto_one_notice(source_p, ":Module %s is not loaded", m_bn);

	rb_free(m_bn);
}
Exemple #3
0
/*! \brief UNLOAD subcommand handler
 *         Attempts to unload a module, throwing an error if
 *         the module could not be found
 * \param source_p Pointer to client issuing the command
 * \param arg      Additional argument which might be needed by this handler
 */
static void
module_unload(struct Client *source_p, const char *arg)
{
  const char *m_bn = NULL;
  const struct module *modp = NULL;

  if ((modp = findmodule_byname((m_bn = libio_basename(arg)))) == NULL)
  {
    sendto_one_notice(source_p, &me, ":Module %s is not loaded", m_bn);
    return;
  }

  if (modp->flags & MODULE_FLAG_CORE)
  {
    sendto_one_notice(source_p, &me, ":Module %s is a core module and may not be unloaded",
                      m_bn);
    return;
  }

  if (modp->flags & MODULE_FLAG_NOUNLOAD)
  {
    sendto_one_notice(source_p, &me, ":Module %s is a resident module and may not be unloaded",
                      m_bn);
    return;
  }

  if (unload_one_module(m_bn, 1) == -1)
    sendto_one_notice(source_p, &me, ":Module %s is not loaded", m_bn);
}
Exemple #4
0
void unload_all_modules(struct pa_module_info *m) {
    unsigned i;

    pa_assert(m);

    for (i = 0; i < m->n_items; i++)
        unload_one_module(m, i);

    m->n_items = 0;
}
Exemple #5
0
static void
do_modrestart(struct Client *source_p)
{
	int modnum;

	sendto_one_notice(source_p, ":Reloading all modules");

	modnum = num_mods;
	while (num_mods)
		unload_one_module(modlist[0]->name, false);

	load_all_modules(false);
	load_core_modules(false);
	rehash(false);

	sendto_realops_snomask(SNO_GENERAL, L_NETWIDE,
			     "Module Restart: %d modules unloaded, %d modules loaded",
			     modnum, num_mods);
	ilog(L_MAIN, "Module Restart: %d modules unloaded, %d modules loaded", modnum, num_mods);
}
Exemple #6
0
void load_module(
        struct pa_module_info *m,
        unsigned i,
        const char *name,
        const char *args,
        bool is_new) {

    struct userdata *u;
    pa_module *mod;

    pa_assert(m);
    pa_assert(name);
    pa_assert(args);

    u = m->userdata;

    if (!is_new) {
        if (m->items[i].index != PA_INVALID_INDEX &&
            pa_streq(m->items[i].name, name) &&
            pa_streq(m->items[i].args, args))
            return;

        unload_one_module(m, i);
    }

    pa_log_debug("Loading module '%s' with args '%s' due to GConf/GSettings configuration.", name, args);

    m->items[i].name = pa_xstrdup(name);
    m->items[i].args = pa_xstrdup(args);
    m->items[i].index = PA_INVALID_INDEX;

    if (pa_module_load(&mod, u->core, name, args) < 0) {
        pa_log("pa_module_load() failed");
        return;
    }

    m->items[i].index = mod->index;
}
Exemple #7
0
/*! \brief RELOAD subcommand handler
 *         Attempts to reload a module, throwing an error if
 *         the module could not be found or loaded
 * \param source_p Pointer to client issuing the command
 * \param arg      Additional argument which might be needed by this handler
 */
static void
module_reload(struct Client *source_p, const char *arg)
{
  const char *m_bn = NULL;
  struct module *modp = NULL;
  int check_core = 0;

  if (!strcmp(arg, "*"))
  {
    unsigned int modnum = 0;
    dlink_node *node = NULL, *node_next = NULL;

    sendto_one_notice(source_p, &me, ":Reloading all modules");

    modnum = dlink_list_length(modules_get_list());

    DLINK_FOREACH_SAFE(node, node_next, modules_get_list()->head)
    {
      modp = node->data;

      if (!(modp->flags & MODULE_FLAG_NOUNLOAD))
        unload_one_module(modp->name, 0);
    }
Exemple #8
0
int handle_event(struct userdata *u) {
    int opcode;
    int ret = 0;

    do {
        if ((opcode = read_byte(u)) < 0) {
            if (errno == EINTR || errno == EAGAIN)
                break;
            goto fail;
        }

        switch (opcode) {
            case '!':
                /* The helper tool is now initialized */
                ret = 1;
                break;

            case '+': {
                char *name;
                struct pa_module_info *m;
                unsigned i, j;

                if (!(name = read_string(u)))
                    goto fail;

                if (!(m = pa_hashmap_get(u->module_infos, name))) {
                    m = pa_xnew(struct pa_module_info, 1);
                    m->userdata = u;
                    m->name = name;
                    m->n_items = 0;
                    pa_hashmap_put(u->module_infos, m->name, m);
                } else
                    pa_xfree(name);

                i = 0;
                while (i < MAX_MODULES) {
                    char *module, *args;

                    if (!(module = read_string(u))) {
                        if (i > m->n_items) m->n_items = i;
                        goto fail;
                    }

                    if (!*module) {
                        pa_xfree(module);
                        break;
                    }

                    if (!(args = read_string(u))) {
                        pa_xfree(module);

                        if (i > m->n_items) m->n_items = i;
                        goto fail;
                    }

                    load_module(m, i, module, args, i >= m->n_items);

                    i++;

                    pa_xfree(module);
                    pa_xfree(args);
                }

                /* Unload all removed modules */
                for (j = i; j < m->n_items; j++)
                    unload_one_module(m, j);

                m->n_items = i;

                break;
            }

            case '-': {
                char *name;

                if (!(name = read_string(u)))
                    goto fail;

                pa_hashmap_remove_and_free(u->module_infos, name);
                pa_xfree(name);

                break;
            }
        }