Custom module interfering with cloak's config

These are old archives. They are kept for historic purposes only.
Post Reply
superdooper
Posts: 3
Joined: Thu Jan 29, 2009 4:54 pm

Custom module interfering with cloak's config

Post 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
Syzop
UnrealIRCd head coder
Posts: 2112
Joined: Sat Mar 06, 2004 8:57 pm
Location: .nl
Contact:

Re: Custom module interfering with cloak's config

Post 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).
superdooper
Posts: 3
Joined: Thu Jan 29, 2009 4:54 pm

Re: Custom module interfering with cloak's config

Post 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.
Post Reply