Skip to content
This repository has been archived by the owner on Jun 24, 2021. It is now read-only.

Show users the RESV reason when they attempt to join channels that are resv'd #56

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion extensions/m_omode.c
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,8 @@ mo_omode(struct Client *client_p, struct Client *source_p, int parc, const char
if(!IsChanPrefix(parv[1][0]) || !check_channel_name(parv[1]))
{
sendto_one_numeric(source_p, ERR_BADCHANNAME,
form_str(ERR_BADCHANNAME), parv[1]);
form_str(ERR_BADCHANNAME), parv[1],
"invalid or too long");
return 0;
}

Expand Down
6 changes: 5 additions & 1 deletion help/opers/resv
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
RESV [time] <channel|nick> :<reason>
RESV [time] <channel|nick> :<reason> [| oper reason]

Reserves a channel or nickname from use. If [time] is not specified this
is added to the database, otherwise is temporary for [time] minutes.

If an oper reason is added (the pipe must be specified
to seperate the fields) it will not be shown to the user
when they are given the resv reason.

Nick resvs accept the same wildcard chars as xlines.
Channel resvs only use exact string comparisons.

Expand Down
4 changes: 2 additions & 2 deletions include/messages.h
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@
#define NUMERIC_STR_421 ":%s 421 %s %s :Unknown command"
#define NUMERIC_STR_422 ":%s 422 %s :MOTD File is missing"
#define NUMERIC_STR_431 ":%s 431 %s :No nickname given"
#define NUMERIC_STR_432 ":%s 432 %s %s :Erroneous Nickname"
#define NUMERIC_STR_432 ":%s 432 %s %s :Erroneous Nickname (%s)"
#define NUMERIC_STR_433 ":%s 433 %s %s :Nickname is already in use."
#define NUMERIC_STR_435 "%s %s :Cannot change nickname while banned on channel"
#define NUMERIC_STR_436 "%s :Nickname collision KILL"
Expand All @@ -183,7 +183,7 @@
#define NUMERIC_STR_475 ":%s 475 %s %s :Cannot join channel (+k) - bad key"
#define NUMERIC_STR_477 ":%s 477 %s %s :Cannot join channel (+r) - you need to be identified with services"
#define NUMERIC_STR_478 ":%s 478 %s %s %s :Channel ban list is full"
#define NUMERIC_STR_479 "%s :Illegal channel name"
#define NUMERIC_STR_479 "%s :Illegal channel name (%s)"
#define NUMERIC_STR_480 ":%s 480 %s %s :Cannot join channel (+j) - throttle exceeded, try again later"
#define NUMERIC_STR_481 ":Permission Denied - You're not an IRC operator"
#define NUMERIC_STR_482 ":%s 482 %s %s :You're not a channel operator"
Expand Down
14 changes: 12 additions & 2 deletions modules/core/m_join.c
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,8 @@ m_join(struct Client *client_p, struct Client *source_p, int parc, const char *p
if(!check_channel_name_loc(source_p, name) || (strlen(name) > LOC_CHANNELLEN))
{
sendto_one_numeric(source_p, ERR_BADCHANNAME,
form_str(ERR_BADCHANNAME), (unsigned char *) name);
form_str(ERR_BADCHANNAME), (unsigned char *) name,
"invalid or too long");
continue;
}

Expand All @@ -187,8 +188,17 @@ m_join(struct Client *client_p, struct Client *source_p, int parc, const char *p
/* see if its resv'd */
if(!IsExemptResv(source_p) && (aconf = hash_find_resv(name)))
{
/* like klines, resvs have a user visible reason and an oper-visible reason
* delimited by a pipe character. If we find a pipe in the reason, swap it
* out for a null before sending it out, and swap the pipe back in after
* faster and less verbose than using a temporary buffer or other method
*/
char *reason_break = strstr(aconf->passwd, "|");
if (reason_break != NULL) *reason_break = '\0';
sendto_one_numeric(source_p, ERR_BADCHANNAME,
form_str(ERR_BADCHANNAME), name);
form_str(ERR_BADCHANNAME), name,
aconf->passwd);
if (reason_break != NULL) *reason_break = '|';

/* dont warn for opers */
if(!IsExemptJupe(source_p) && !IsOper(source_p))
Expand Down
6 changes: 3 additions & 3 deletions modules/core/m_mode.c
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ m_mode(struct Client *client_p, struct Client *source_p, int parc, const char *p

if(!check_channel_name(dest))
{
sendto_one_numeric(source_p, ERR_BADCHANNAME, form_str(ERR_BADCHANNAME), parv[1]);
sendto_one_numeric(source_p, ERR_BADCHANNAME, form_str(ERR_BADCHANNAME), parv[1], "invalid or too long");
return 0;
}

Expand Down Expand Up @@ -178,7 +178,7 @@ ms_tmode(struct Client *client_p, struct Client *source_p, int parc, const char
/* Now, try to find the channel in question */
if(!IsChanPrefix(parv[2][0]) || !check_channel_name(parv[2]))
{
sendto_one_numeric(source_p, ERR_BADCHANNAME, form_str(ERR_BADCHANNAME), parv[2]);
sendto_one_numeric(source_p, ERR_BADCHANNAME, form_str(ERR_BADCHANNAME), parv[2], "invalid or too long");
return 0;
}

Expand Down Expand Up @@ -217,7 +217,7 @@ ms_mlock(struct Client *client_p, struct Client *source_p, int parc, const char
/* Now, try to find the channel in question */
if(!IsChanPrefix(parv[2][0]) || !check_channel_name(parv[2]))
{
sendto_one_numeric(source_p, ERR_BADCHANNAME, form_str(ERR_BADCHANNAME), parv[2]);
sendto_one_numeric(source_p, ERR_BADCHANNAME, form_str(ERR_BADCHANNAME), parv[2], "invalid or too long");
return 0;
}

Expand Down
26 changes: 20 additions & 6 deletions modules/core/m_nick.c
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ static int
mr_nick(struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
{
struct Client *target_p;
struct ConfItem *aconf;
char nick[NICKLEN];

if (strlen(client_p->id) == 3)
Expand All @@ -137,15 +138,23 @@ mr_nick(struct Client *client_p, struct Client *source_p, int parc, const char *
if(!clean_nick(nick, 1))
{
sendto_one(source_p, form_str(ERR_ERRONEUSNICKNAME),
me.name, EmptyString(source_p->name) ? "*" : source_p->name, parv[1]);
me.name, EmptyString(source_p->name) ? "*" : source_p->name, parv[1], "invalid or too long");
return 0;
}

/* check if the nick is resv'd */
if(find_nick_resv(nick))
if(aconf = find_nick_resv(nick))
{
/* like klines, resvs have a user visible reason and an oper-visible reason
* delimited by a pipe character. If we find a pipe in the reason, swap it
* out for a null before sending it out, and swap the pipe back in after
* faster and less verbose than using a temporary buffer or other method
*/
char *reason_break = strstr(aconf->passwd, "|");
if (reason_break != NULL) *reason_break = '\0';
sendto_one(source_p, form_str(ERR_ERRONEUSNICKNAME),
me.name, EmptyString(source_p->name) ? "*" : source_p->name, nick);
me.name, EmptyString(source_p->name) ? "*" : source_p->name, nick, aconf->passwd);
if (reason_break != NULL) *reason_break = '|';
return 0;
}

Expand Down Expand Up @@ -173,6 +182,7 @@ static int
m_nick(struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
{
struct Client *target_p;
struct ConfItem *aconf;
char nick[NICKLEN];

if(parc < 2 || EmptyString(parv[1]))
Expand All @@ -191,13 +201,17 @@ m_nick(struct Client *client_p, struct Client *source_p, int parc, const char *p
/* check the nickname is ok */
if(!clean_nick(nick, 1))
{
sendto_one(source_p, form_str(ERR_ERRONEUSNICKNAME), me.name, source_p->name, nick);
sendto_one(source_p, form_str(ERR_ERRONEUSNICKNAME), me.name, source_p->name, nick, "invalid or too long");
return 0;
}

if(!IsExemptResv(source_p) && find_nick_resv(nick))
if(!IsExemptResv(source_p) && (aconf = find_nick_resv(nick)))
{
sendto_one(source_p, form_str(ERR_ERRONEUSNICKNAME), me.name, source_p->name, nick);
/* resvs, like klines, have oper-only reason delimited by a pipe char */
char *reason_break = strstr(aconf->passwd, "|");
if (reason_break != NULL) *reason_break = '\0';
sendto_one(source_p, form_str(ERR_ERRONEUSNICKNAME), me.name, source_p->name, nick, aconf->passwd);
if (reason_break != NULL) *reason_break = '|';
return 0;
}

Expand Down
4 changes: 2 additions & 2 deletions modules/m_invite.c
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ m_invite(struct Client *client_p, struct Client *source_p, int parc, const char
{
sendto_one_numeric(source_p, ERR_BADCHANNAME,
form_str(ERR_BADCHANNAME),
parv[2]);
parv[2], "invalid or too long");
return 0;
}

Expand All @@ -108,7 +108,7 @@ m_invite(struct Client *client_p, struct Client *source_p, int parc, const char
{
sendto_one_numeric(source_p, ERR_BADCHANNAME,
form_str(ERR_BADCHANNAME),
parv[2]);
parv[2], "invalid or too long");
return 0;
}

Expand Down
3 changes: 2 additions & 1 deletion modules/m_names.c
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,8 @@ m_names(struct Client *client_p, struct Client *source_p, int parc, const char *
{
sendto_one_numeric(source_p, ERR_BADCHANNAME,
form_str(ERR_BADCHANNAME),
(unsigned char *) p);
(unsigned char *) p,
"invalid or too long");
return 0;
}

Expand Down
21 changes: 17 additions & 4 deletions src/chmode.c
Original file line number Diff line number Diff line change
Expand Up @@ -514,18 +514,31 @@ check_forward(struct Client *source_p, struct Channel *chptr,
{
struct Channel *targptr;
struct membership *msptr;
struct ConfItem *aconf = NULL;

if(!check_channel_name(forward) ||
(MyClient(source_p) && (strlen(forward) > LOC_CHANNELLEN || hash_find_resv(forward))))
if(!check_channel_name(forward) || (MyClient(source_p) && strlen(forward) > LOC_CHANNELLEN))
{
sendto_one_numeric(source_p, ERR_BADCHANNAME, form_str(ERR_BADCHANNAME), forward);
sendto_one_numeric(source_p, ERR_BADCHANNAME, form_str(ERR_BADCHANNAME), forward, "invalid or too long");
return 0;
}
else if (MyClient(source_p) && (aconf = hash_find_resv(forward)))
{
/* like klines, resvs have a user visible reason and an oper-visible reason
* delimited by a pipe character. If we find a pipe in the reason, swap it
* out for a null before sending it out, and swap the pipe back in after
* faster and less verbose than using a temporary buffer or other method
*/
char *reason_break = strstr(aconf->passwd, "|");
if (reason_break != NULL) *reason_break = '\0';
sendto_one_numeric(source_p, ERR_BADCHANNAME, form_str(ERR_BADCHANNAME), forward, aconf->passwd);
if (reason_break != NULL) *reason_break = '|';
return 0;
}
/* don't forward to inconsistent target -- jilles */
if(chptr->chname[0] == '#' && forward[0] == '&')
{
sendto_one_numeric(source_p, ERR_BADCHANNAME,
form_str(ERR_BADCHANNAME), forward);
form_str(ERR_BADCHANNAME), forward, "inconsistent target");
return 0;
}
if(MyClient(source_p) && (targptr = find_channel(forward)) == NULL)
Expand Down