[IRCServices Coding] Associating NickGroupInfo with two nicks at once

Andrew Church achurch at achurch.org
Wed Apr 23 10:17:37 PDT 2003

     The code currently assumes that at most one user will be associated
with any particular nickname, that NickInfo.user will point at the user
with nickname NickInfo.nick, that User.ni will point at the NickInfo with
nickname User.nick (or NULL if the nickname is not registered), and that
User.ngi will point to a nickname group containing User.ni (or NULL or
NICKGROUPINFO_INVALID).  Breaking any of these assumptions will probably
cause many weird and dangerous things to happen.

     Note that two or more users can be associated with a single nick group
(if, for example, someone has two clients open and using two linked nicks).
However, if the user's nick is not in NickGroupInfo.nicks[], things will
probably break.

     I'd strongly suggest finding another way to accomplish whatever you're
trying to do without an "su"-like command.

  --Andrew Church
    achurch at achurch.org

>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 == MyNG
>roupInf) 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 :)
>ChatSpike Services-dev