[IRCServices Coding] Associating NickGroupInfo with two nicks at once

Craig Edwards brain at brainbox.winbot.co.uk
Tue Apr 22 08:24:03 PDT 2003


Hi, we're writing a module which allows a web interface to "su" to a nickname, similar to the way the unix "su" command (dont ask! :)) heres how it works:

basically, /msg somepseudoclient su <nick> <pass>

..and you gain the privilages of that nick, wether or not they are using it at the time. What we're doing at the moment is associating the user's ngi and ni fields with the nickgroupinfo of the registered nickname, e.g.

NickInfo* MyNickInf = get_nickinfo(somenick);
NickGroupInfo* MyNGroupInf = get_ngi(MyNickInf);

u->ngi = MyNGroupInf;
u->ni = MyNickInf;
/* user u is now logged in with privilages of "ngi" nick, send +r as a raw if neccessary */

sorry for any errors in this code, im typing it off the top of my head.
Basically, the problem we have is, that only one nick can have "ownership" of a groupinfo at any one time, if we associate user 'u' with MyNGroupInf, then if some other user online at the time (lets call them u2) has this same association (u2->ngi == MyNGroupInf) than u2 is logged out (and has to re-identify using /msg nickserv identify <pass>). Basically we cant give two people ownership of the same nickgroup at the same time. Is there any way we can get around this, e.g. by memcpy'ing the NickGroupInfo? The ownership of the nick by the second user only needs to be temporary, until disconnect, so there shouldnt be any corruption of services DB's by having two people pointing at the same nickgroup in the file, or anything as weird as that :)

If theres any way to solve this problem simply, without needing andy to rewrite the core, or for us to approach the problem a different way, we'd be grateful of anyone could tell us how :)

Thanks,
Brain
ChatSpike Services-dev