Skip to content

Commit

Permalink
Make sure that the target user is able to join a local channel
Browse files Browse the repository at this point in the history
Implement ERR_USERNOTONSERV(504) numeric and make sure that the
target user is on the same server when inviting other users to
local ("&") channels.

ircd-ratbox uses the ERR_USERNOTONSERV(504) numeric for this, and I
think this is a good idea -- other IRC daemons (like ircu) silently
drop such impossible invites, but thats not a big benefit ...

Idea by Cahata, thanks! Closes #183.
  • Loading branch information
alexbarton committed Apr 12, 2015
1 parent 4330f5d commit c5da483
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/ngircd/irc-op.c
Expand Up @@ -150,6 +150,14 @@ IRC_INVITE(CLIENT *Client, REQUEST *Req)
return IRC_WriteErrClient(from, ERR_NOSUCHNICK_MSG,
Client_ID(Client), Req->argv[0]);

if (Req->argv[1][0] == '&') {
/* Local channel. Make sure the target user is on this server! */
if (Client_Conn(target) == NONE)
return IRC_WriteErrClient(from, ERR_USERNOTONSERV_MSG,
Client_ID(Client),
Req->argv[0]);
}

chan = Channel_Search(Req->argv[1]);
if (chan) {
/* Channel exists. Is the user a valid member of the channel? */
Expand Down
1 change: 1 addition & 0 deletions src/ngircd/messages.h
Expand Up @@ -156,6 +156,7 @@
#define ERR_UMODEUNKNOWNFLAG_MSG "501 %s :Unknown mode"
#define ERR_UMODEUNKNOWNFLAG2_MSG "501 %s :Unknown mode \"%c%c\""
#define ERR_USERSDONTMATCH_MSG "502 %s :Can't set/get mode for other users"
#define ERR_USERNOTONSERV_MSG "504 %s %s :User is not on this server"
#define ERR_NOINVITE_MSG "518 %s :Cannot invite to %s (+V)"

#ifdef ZLIB
Expand Down

0 comments on commit c5da483

Please sign in to comment.