X-Git-Url: http://git.pk910.de/?a=blobdiff_plain;f=ircd%2Fs_user.c;h=2c9a9bce35be8aeaa46866eab9ef0925ba10f38e;hb=fa4486fe3e166152a57a42320fd1f2faee37b0c3;hp=942c44c96a7b291db160290f3d67164bb82f014d;hpb=c666f34b1e2d872189f36761e3b69eac635fd6ae;p=ircu2.10.12-pk.git diff --git a/ircd/s_user.c b/ircd/s_user.c index 942c44c..2c9a9bc 100644 --- a/ircd/s_user.c +++ b/ircd/s_user.c @@ -485,7 +485,7 @@ int register_user(struct Client *cptr, struct Client *sptr) * account assignment causes a numeric reply during registration. */ if (HasHiddenHost(sptr)) - hide_hostmask(sptr, FLAG_HIDDENHOST); + hide_hostmask(sptr, HIDE_HOSTMASK_FLAG_HIDDENHOST); if (IsInvisible(sptr)) ++UserStats.inv_clients; if (IsOper(sptr)) @@ -589,7 +589,8 @@ static const struct UserMode { { FLAG_WEBIRC, 'W' }, { FLAG_SEE_IDLETIME,'t' }, { FLAG_SECURITY_SERV,'D' }, - { FLAG_HIDDENHOST, 'x' } + { FLAG_HIDDENHOST, 'x' }, + { FLAG_NOTCONN, 'Z' } }; /** Length of #userModeList. */ @@ -979,35 +980,47 @@ hide_hostmask(struct Client *cptr, unsigned int flag) struct Membership *chan; char buf[HOSTLEN]; - switch (flag) { - case FLAG_HIDDENHOST: + if (flag & HIDE_HOSTMASK_FLAG_HIDDENHOST) { /* Local users cannot set +x unless FEAT_HOST_HIDING is true. */ if (MyConnect(cptr) && !feature_bool(FEAT_HOST_HIDING)) return 0; - break; - case FLAG_ACCOUNT: - case FLAG_FAKEHOST: - case FLAG_FAKEIDENT: + } + if (flag & (HIDE_HOSTMASK_FLAG_ACCOUNT | HIDE_HOSTMASK_FLAG_FAKEHOST | HIDE_HOSTMASK_FLAG_FAKEIDENT)) { /* Invalidate all bans against the user so we check them again */ for (chan = (cli_user(cptr))->channel; chan; chan = chan->next_channel) ClearBanValid(chan); - break; - default: - /* default: no special handling */ - break; } /* Set flags and stop if no fakehost has to be applied. */ - SetFlag(cptr, flag); + if(flag & HIDE_HOSTMASK_FLAG_HIDDENHOST) + SetFlag(cptr, FLAG_HIDDENHOST); + if(flag & HIDE_HOSTMASK_FLAG_ACCOUNT) + SetFlag(cptr, FLAG_ACCOUNT); + if(flag & HIDE_HOSTMASK_FLAG_FAKEHOST) + SetFlag(cptr, FLAG_FAKEHOST); + if(flag & HIDE_HOSTMASK_FLAG_FAKEIDENT) + SetFlag(cptr, FLAG_FAKEIDENT); + if(!HasHiddenHost(cptr)) return 0; /* Generate new fakehost. */ - if(IsFakeHost(cptr)) ircd_strncpy(buf, cli_user(cptr)->fakehost, HOSTLEN); - else if (IsAccount(cptr)) ircd_snprintf(0, buf, HOSTLEN, "%s.%s", cli_user(cptr)->account, feature_str(FEAT_HIDDEN_HOST)); - else return 0; - if(strncmp(buf, cli_user(cptr)->host, HOSTLEN) == 0 && (!IsFakeIdent(cptr) || strncmp(cli_user(cptr)->fakeuser, cli_user(cptr)->username, USERLEN) == 0)) return 0; + unsigned int reregister = 0; + if(IsFakeHost(cptr) || IsAccount(cptr)) { + if(IsFakeHost(cptr)) + ircd_strncpy(buf, cli_user(cptr)->fakehost, HOSTLEN); + else + ircd_snprintf(0, buf, HOSTLEN, "%s.%s", cli_user(cptr)->account, feature_str(FEAT_HIDDEN_HOST)); + if(strncmp(buf, cli_user(cptr)->host, HOSTLEN)) + reregister |= HIDE_HOSTMASK_FLAG_FAKEHOST; + } + if(IsFakeIdent(cptr)) { + if(strncmp(cli_user(cptr)->fakeuser, cli_user(cptr)->username, USERLEN)) + reregister |= HIDE_HOSTMASK_FLAG_FAKEIDENT; + } + + if (!reregister) return 0; /* Remove all "valid" marks on the bans. This forces them to be * rechecked if the ban is accessed again. @@ -1018,20 +1031,17 @@ hide_hostmask(struct Client *cptr, unsigned int flag) /* Quit user and set the previously generated fakehost. */ sendcmdto_common_channels_butone(cptr, CMD_QUIT, cptr, ":Registered"); - ircd_strncpy(cli_user(cptr)->host, buf, HOSTLEN); - - /* spoof also the username if username is passed */ - if(IsFakeIdent(cptr)) { - if(strncmp(cli_user(cptr)->username, cli_user(cptr)->fakeuser, USERLEN) != 0) { - ircd_strncpy(cli_username(cptr), cli_user(cptr)->fakeuser, USERLEN); - ircd_strncpy(cli_user(cptr)->username, cli_user(cptr)->fakeuser, USERLEN); - } - /* ok, the client is now fully hidden, so let them know -- hikari */ - if (MyConnect(cptr)) + if(reregister & HIDE_HOSTMASK_FLAG_FAKEHOST) + ircd_strncpy(cli_user(cptr)->host, buf, HOSTLEN); + if(reregister & HIDE_HOSTMASK_FLAG_FAKEIDENT) + ircd_strncpy(cli_user(cptr)->username, cli_user(cptr)->fakeuser, USERLEN); + + + /* ok, the client is now fully hidden, so let them know -- hikari */ + if(MyConnect(cptr)) { + if (IsFakeIdent(cptr)) send_reply(cptr, RPL_HOSTUSERHIDDEN, cli_user(cptr)->username, cli_user(cptr)->host); - } else { - /* ok, the client is now fully hidden, so let them know -- hikari */ - if (MyConnect(cptr)) + else send_reply(cptr, RPL_HOSTHIDDEN, cli_user(cptr)->host); } @@ -1060,6 +1070,25 @@ hide_hostmask(struct Client *cptr, unsigned int flag) else { SetDelayedJoin(chan); } + + /* + * Check if the client is actually overriding a ban with the + * mask change, if so, kick him out of the channel. + * We have to proceed that way to ensure data consistency (join + kick) + */ + if (find_ban(cptr, chan->channel->banlist)) { + /* Silentely kick in case of delayed join */ + if (chan->channel->mode.mode & MODE_DELJOINS) { + sendcmdto_one(&his, CMD_KICK, cptr, "%H %C :Ban override", chan->channel, cptr); + CheckDelayedJoins(chan->channel); + + } else { + /* Otherwise publicly kick */ + sendcmdto_serv_butone(&me, CMD_KICK, NULL, "%H %C :Ban override", chan->channel, cptr); + sendcmdto_channel_butserv_butone(&his, CMD_KICK, chan->channel, NULL, 0, "%H %C :Ban override", chan->channel, cptr); + make_zombie(chan, cptr, &me, &me, chan->channel); + } + } } return 0; } @@ -1290,6 +1319,12 @@ int set_user_mode(struct Client *cptr, struct Client *sptr, int parc, case 'z': /* Formerly SSL mode; we ignore it. */ break; #endif + case 'Z': + if (what == MODE_ADD) + SetNotConn(sptr); + else + ClearNotConn(sptr); + break; default: send_reply(sptr, ERR_UMODEUNKNOWNFLAG, *m); break; @@ -1312,6 +1347,8 @@ int set_user_mode(struct Client *cptr, struct Client *sptr, int parc, ClrFlag(sptr, FLAG_FAKEHOST); if (!FlagHas(&setflags, FLAG_SEE_IDLETIME) && IsSeeIdletime(sptr)) ClrFlag(sptr, FLAG_SEE_IDLETIME); + if (!FlagHas(&setflags, FLAG_NOTCONN) && IsNotConn(sptr)) + ClrFlag(sptr, FLAG_NOTCONN); /* * new umode; servers and privileged opers can set it, local users cannot; * prevents users from /kick'ing or /mode -o'ing