Skip to content

Commit b411a65

Browse files
authored
Fix channel-destruction bug
Reported by Chris[A]. This fixes a bug where channels were not properly destroyed when a user's join request was rejected
1 parent 57a4959 commit b411a65

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

files/restrict-chans.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* LICENSE: GPLv3 or later
2+
* LICENSE: GPLv3
33
* Copyright Ⓒ 2023 Valerie Pond
44
*
55
* Restricts channels to registered users
@@ -28,7 +28,7 @@ int isreg_can_join(Client *client, Channel *channel, const char *key, char **err
2828
ModuleHeader MOD_HEADER =
2929
{
3030
"third/restrict-chans",
31-
"1.0",
31+
"1.1",
3232
"Restrict channel creation to logged-in users",
3333
"Valware",
3434
"unrealircd-6",
@@ -57,8 +57,12 @@ MOD_TEST()
5757

5858
int isreg_can_join(Client *client, Channel *channel, const char *key, char **errmsg)
5959
{
60-
if (!channel->users && !IsLoggedIn(client) && !has_channel_mode(channel, 'P'))
60+
/* allow people to join permanent empty channels and allow opers to create new channels */
61+
if (!channel->users && !IsLoggedIn(client) && !has_channel_mode(channel, 'P') && !IsOper(client))
6162
{
63+
/* there aren't actually any users in the channel but sub1_from_channel()
64+
will destroy the channel best without duplicating code */
65+
sub1_from_channel(channel);
6266
*errmsg = "%s :You must be logged in to create new channels", channel->name;
6367
return ERR_CANNOTDOCOMMAND;
6468
}

0 commit comments

Comments
 (0)