Page 1 of 1

Custom module interfering with cloak's config

Posted: Thu Jan 29, 2009 5:15 pm
by superdooper
I'm starting to write a custom module. In order to make it configurable, I'd like to have it process the config file. I've created the necessary stubs, and my mod startup code looks like:

Code: Select all

DLLFUNC int mymod_config_test(ConfigFile *, ConfigEntry *, int, int *);
DLLFUNC int mymod_config_posttest(int *);
DLLFUNC int mymod_config_run(ConfigFile *, ConfigEntry *, int);

DLLFUNC int MOD_TEST(dblog)(ModuleInfo *modinfo) {
  HookAddEx(modinfo->handle, HOOKTYPE_CONFIGTEST, mymod_config_test);
  HookAddEx(modinfo->handle, HOOKTYPE_CONFIGPOSTTEST, mymod_config_posttest);

  return MOD_SUCCESS;
}

DLLFUNC int MOD_INIT(dblog)(ModuleInfo *modinfo) {
  HookAddEx(modinfo->handle, HOOKTYPE_CONFIGRUN,   mymod_config_run);
  
  return MOD_SUCCESS;
}
However, when I do this and load my module in unrealircd.conf, the cloak module starts acting funny and the exact symptoms differ depending on where the loadmodule directive for my module is placed.

If the loadmodule for my module is after the loadmodule for cloak, cloak complains that it could not find its cloak keys and the Unreal does not boot.

If the loadmodule for my module is before the loadmodule for cloak, everything seems to boot fine, however the server crashes when the first user logs in. From the core, it looks like the crash happens at the ircsprintf at cloak.c:385 because one of the KEYs is not present.

If I comment out the lines registering for the HOOKTYPE_CONFIG*, everything works as expected.

Anyone have any ideas what is going on here? I figure that its probably something to do with the HOOK dispatching, but I wanted to see if I was doing something obviously wrong before digging too far in the code.

System: CentOS 5.2, x86, UnrealIRCd 3.2.7

Re: Custom module interfering with cloak's config

Posted: Sat Jan 31, 2009 11:40 am
by Syzop
Hm. Are you properly returning 0 in your config test & run when the ce block is not for you (eg: hook gets called for a set::cloak block which your module isn't interested in -> you must return 0, not -1 / 1 since that means your module handled it and the next module [eg cloak] will not be called).

Re: Custom module interfering with cloak's config

Posted: Thu Feb 19, 2009 3:13 pm
by superdooper
Thanks! That was exactly it. I've got another question about module startup, but I'll post it in a new topic for easier searching.