Module: ngircd.git
Branch: master
Commit: fcdb5cf8dd1579172ad894ddc8c07defa16f0822
URL: http://ngircd.barton.de/cgi-bin/gitweb.cgi?p=ngircd.git&a=commit;h=fcdb5cf8…
Author: Federico G. Schwindt <fgsch(a)lodoss.net>
Date: Mon Aug 5 11:06:52 2013 +0100
More spelling corrections
---
doc/Commands.txt | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/doc/Commands.txt b/doc/Commands.txt
index c43b50e..e049f5e 100644
--- a/doc/Commands.txt
+++ b/doc/Commands.txt
@@ -145,7 +145,7 @@ Connection Handling Commands
Please note:
The RFCs state that the <token> parameter is used to specify the
- origin of the PING command when forwared in the network, but this
+ origin of the PING command when forwarded in the network, but this
is not the case: the sender is specified using the prefix as usual,
and the parameter is used to identify the PONG reply in practice.
@@ -256,7 +256,7 @@ General Commands
modes are returned. Otherwise the modes are adjusted accordingly
and the changes will be reported back to the client.
.
- All user and chnnel "modes" are indicated by single case-sensitive
+ All user and channel "modes" are indicated by single case-sensitive
characters.
.
Please note that a user can only get and set his own modes, and not
@@ -615,7 +615,7 @@ Channel Commands
- LIST
LIST [<channel>[,<channel>[,...]] [<server>]]
.
- List all visible <channels> (comma-seperated list).
+ List all visible <channels> (comma-separated list).
.
If <server> is given, the command will be forwarded to <server> for
evaluation.
@@ -635,7 +635,7 @@ Channel Commands
- TOPIC
TOPIC <channel> [<topic>]
.
- Cchange or view the topic of a channel.
+ Change or view the topic of a channel.
.
The topic for channel <channel> is returned if there is no <topic>
given. If the <topic> parameter is present, the topic for that
@@ -694,7 +694,7 @@ Administrative Commands
This command provides timed G-Lines (network-wide bans).
.
If a client matches a G-Line, it cannot connect to any server on
- the IRC network for <timeout> seconds. When <timoeut> is 0, it make
+ the IRC network for <timeout> seconds. When <timeout> is 0, it make
the G-Line permanent.
.
If no <timeout> and no <reason> is given, the G-Line is removed.
@@ -727,7 +727,7 @@ Administrative Commands
This command provides timed K-Lines (server-local bans).
.
If a client matches a K-Line, it cannot connect to this server for
- <timeout> seconds. When <timoeut> is 0, it makes the K-Line permanent.
+ <timeout> seconds. When <timeout> is 0, it makes the K-Line permanent.
.
If no <timeout> and no <reason> is given, the K-Line is removed.
.
@@ -904,7 +904,7 @@ Server Protocol Commands
- NJOIN
NJOIN <channel> [<mode>]<nick>[,[<mode>]<nick>[,...]]
.
- The NJOIN command is used on setver-links to add users with <nick>
+ The NJOIN command is used on server-links to add users with <nick>
and <mode> to a <channel> while peering.
.
The NJOIN command is allowed on server-links only.
Module: ngircd.git
Branch: master
Commit: 5258fb7f7c3d92a35083f869bae4f05ab988d2da
URL: http://ngircd.barton.de/cgi-bin/gitweb.cgi?p=ngircd.git&a=commit;h=5258fb7f…
Author: Alexander Barton <alex(a)barton.de>
Date: Sun Aug 4 03:06:53 2013 +0200
Implement new configuration option "AllowedChannelTypes"
The new configuration variable "AllowedChannelTypes" lists all allowed
channel types (channel prefixes) for newly created channels on the local
server. By default, all supported channel types are allowed.
If set to the empty string, local clients can't create new channels at
all, which equals the old "PredefChannelsOnly = yes" setting.
This patch deprecates the "PredefChannelsOnly" variable, too, but it is
still supported and translated to the apropriate "AllowedChannelTypes"
setting. When "PredefChannelsOnly" is processed, a warning message is
logged.
Closes bug #152.
---
doc/sample-ngircd.conf.tmpl | 9 ++++++---
man/ngircd.conf.5.tmpl | 12 ++++++------
src/ngircd/conf.c | 44 ++++++++++++++++++++++++++++++++++++++++---
src/ngircd/conf.h | 4 ++--
src/ngircd/irc-channel.c | 2 +-
5 files changed, 56 insertions(+), 15 deletions(-)
diff --git a/doc/sample-ngircd.conf.tmpl b/doc/sample-ngircd.conf.tmpl
index 31333ec..99960e9 100644
--- a/doc/sample-ngircd.conf.tmpl
+++ b/doc/sample-ngircd.conf.tmpl
@@ -128,6 +128,12 @@
# behavior of ngIRCd. If you want to get started quickly, you most
# probably don't have to make changes here -- they are all optional.
+ # List of allowed channel types (channel prefixes) for newly created
+ # channels on the local server. By default, all supported channel
+ # types are allowed. Set this variable to the empty string to disallow
+ # creation of new channels by local clients at all.
+ ;AllowedChannelTypes = #&+
+
# Are remote IRC operators allowed to control this server, e.g.
# use commands like CONNECT, SQUIT, DIE, ...?
;AllowRemoteOper = no
@@ -209,9 +215,6 @@
# character prepended to their respective user names!
;PAMIsOptional = no
- # Allow Pre-Defined Channels only (see Section [Channels])
- ;PredefChannelsOnly = no
-
# Let ngIRCd send an "authentication PING" when a new client connects,
# and register this client only after receiving the corresponding
# "PONG" reply.
diff --git a/man/ngircd.conf.5.tmpl b/man/ngircd.conf.5.tmpl
index 64acd92..c9d7bf8 100644
--- a/man/ngircd.conf.5.tmpl
+++ b/man/ngircd.conf.5.tmpl
@@ -209,6 +209,12 @@ Optional features and configuration options to further tweak the behavior of
ngIRCd. If you want to get started quickly, you most probably don't have to
make changes here -- they are all optional.
.TP
+\fBAllowedChannelTypes\fR (string)
+List of allowed channel types (channel prefixes) for newly created channels
+on the local server. By default, all supported channel types are allowed.
+Set this variable to the empty string to disallow creation of new channels
+by local clients at all. Default: #&+
+.TP
\fBAllowRemoteOper\fR (boolean)
Are IRC operators connected to remote servers allowed to control this server,
e.g. are they allowed to use administrative commands like CONNECT, DIE,
@@ -319,12 +325,6 @@ able to distinguish between Ident'ified and PAM-authenticated users: both
don't have a "~" character prepended to their respective user names!
Default: no.
.TP
-\fBPredefChannelsOnly\fR (boolean)
-If enabled, no new channels can be created. Useful if you do not want to have
-other channels than those defined in [Channel] sections in the configuration
-file on this server.
-Default: no.
-.TP
\fBRequireAuthPing\fR (boolean)
Let ngIRCd send an "authentication PING" when a new client connects, and
register this client only after receiving the corresponding "PONG" reply.
diff --git a/src/ngircd/conf.c b/src/ngircd/conf.c
index bae5fa7..70c9609 100644
--- a/src/ngircd/conf.c
+++ b/src/ngircd/conf.c
@@ -391,6 +391,7 @@ Conf_Test( void )
puts("");
puts("[OPTIONS]");
+ printf(" AllowedChannelTypes = %s\n", Conf_AllowedChannelTypes);
printf(" AllowRemoteOper = %s\n", yesno_to_str(Conf_AllowRemoteOper));
printf(" ChrootDir = %s\n", Conf_Chroot);
printf(" CloakHost = %s\n", Conf_CloakHost);
@@ -415,7 +416,6 @@ Conf_Test( void )
printf(" PAM = %s\n", yesno_to_str(Conf_PAM));
printf(" PAMIsOptional = %s\n", yesno_to_str(Conf_PAMIsOptional));
#endif
- printf(" PredefChannelsOnly = %s\n", yesno_to_str(Conf_PredefChannelsOnly));
#ifndef STRICT_RFC
printf(" RequireAuthPing = %s\n", yesno_to_str(Conf_AuthPing));
#endif
@@ -758,6 +758,8 @@ Set_Defaults(bool InitServers)
Conf_PongTimeout = 20;
/* Options */
+ strlcpy(Conf_AllowedChannelTypes, CHANTYPES,
+ sizeof(Conf_AllowedChannelTypes));
Conf_AllowRemoteOper = false;
#ifndef STRICT_RFC
Conf_AuthPing = false;
@@ -792,7 +794,6 @@ Set_Defaults(bool InitServers)
Conf_PAM = false;
#endif
Conf_PAMIsOptional = false;
- Conf_PredefChannelsOnly = false;
#ifdef SYSLOG
Conf_ScrubCTCP = false;
#ifdef LOG_LOCAL5
@@ -1633,12 +1634,37 @@ static void
Handle_OPTIONS(const char *File, int Line, char *Var, char *Arg)
{
size_t len;
+ char *p;
assert(File != NULL);
assert(Line > 0);
assert(Var != NULL);
assert(Arg != NULL);
+ if (strcasecmp(Var, "AllowedChannelTypes") == 0) {
+ p = Arg;
+ Conf_AllowedChannelTypes[0] = '\0';
+ while (*p) {
+ if (strchr(Conf_AllowedChannelTypes, *p)) {
+ /* Prefix is already included; ignore it */
+ p++;
+ continue;
+ }
+
+ if (strchr(CHANTYPES, *p)) {
+ len = strlen(Conf_AllowedChannelTypes) + 1;
+ assert(len < sizeof(Conf_AllowedChannelTypes));
+ Conf_AllowedChannelTypes[len - 1] = *p;
+ Conf_AllowedChannelTypes[len] = '\0';
+ } else {
+ Config_Error(LOG_WARNING,
+ "%s, line %d: Unknown channel prefix \"%c\" in \"AllowedChannelTypes\"!",
+ File, Line, *p);
+ }
+ p++;
+ }
+ return;
+ }
if (strcasecmp(Var, "AllowRemoteOper") == 0) {
Conf_AllowRemoteOper = Check_ArgIsTrue(Arg);
return;
@@ -1731,7 +1757,19 @@ Handle_OPTIONS(const char *File, int Line, char *Var, char *Arg)
return;
}
if (strcasecmp(Var, "PredefChannelsOnly") == 0) {
- Conf_PredefChannelsOnly = Check_ArgIsTrue(Arg);
+ /*
+ * TODO: This section and support for "PredefChannelsOnly"
+ * could be removed starting with ngIRCd release 22 (one
+ * release after marking it "deprecated") ...
+ */
+ Config_Error(LOG_WARNING,
+ "%s, line %d (section \"Options\"): \"%s\" is deprecated, please use \"AllowedChannelTypes\"!",
+ File, Line, Var);
+ if (Check_ArgIsTrue(Arg))
+ Conf_AllowedChannelTypes[0] = '\0';
+ else
+ strlcpy(Conf_AllowedChannelTypes, CHANTYPES,
+ sizeof(Conf_AllowedChannelTypes));
return;
}
#ifndef STRICT_RFC
diff --git a/src/ngircd/conf.h b/src/ngircd/conf.h
index bbf4f36..93d6785 100644
--- a/src/ngircd/conf.h
+++ b/src/ngircd/conf.h
@@ -148,8 +148,8 @@ GLOBAL CONF_SERVER Conf_Server[MAX_SERVERS];
/** Array of pre-defined channels */
GLOBAL array Conf_Channels;
-/** Flag indicating if only pre-defined channels are allowed (true) or not */
-GLOBAL bool Conf_PredefChannelsOnly;
+/** String containing all locally allowed channel prefixes for new channels */
+GLOBAL char Conf_AllowedChannelTypes[8];
/** Flag indicating if IRC operators are allowed to always use MODE (true) */
GLOBAL bool Conf_OperCanMode;
diff --git a/src/ngircd/irc-channel.c b/src/ngircd/irc-channel.c
index c683640..16501be 100644
--- a/src/ngircd/irc-channel.c
+++ b/src/ngircd/irc-channel.c
@@ -344,7 +344,7 @@ IRC_JOIN( CLIENT *Client, REQUEST *Req )
}
chan = Channel_Search(channame);
- if (!chan && Conf_PredefChannelsOnly) {
+ if (!chan && !strchr(Conf_AllowedChannelTypes, channame[0])) {
/* channel must be created, but forbidden by config */
IRC_WriteStrClient(Client, ERR_NOSUCHCHANNEL_MSG,
Client_ID(Client), channame);
Module: ngircd.git
Branch: master
Commit: bb8d207efa56b8dbdf366d980b848b0abd072a7d
URL: http://ngircd.barton.de/cgi-bin/gitweb.cgi?p=ngircd.git&a=commit;h=bb8d207e…
Author: Federico G. Schwindt <fgsch(a)lodoss.net>
Date: Sun Aug 4 10:15:11 2013 +0100
Change cloaked hostname to be malloc'd on demand
This shaves a few bytes when cloaked hostnames are not used and
restricts the cloakhost announcement iif there is something to
send.
---
src/ngircd/client.c | 25 ++++++++++++++++---------
src/ngircd/client.h | 2 +-
2 files changed, 17 insertions(+), 10 deletions(-)
diff --git a/src/ngircd/client.c b/src/ngircd/client.c
index 7821d3b..d70cfb4 100644
--- a/src/ngircd/client.c
+++ b/src/ngircd/client.c
@@ -318,6 +318,8 @@ Client_Destroy( CLIENT *Client, const char *LogMsg, const char *FwdMsg, bool Sen
}
}
+ if (c->cloaked)
+ free(c->cloaked);
free( c );
break;
}
@@ -744,8 +746,6 @@ Client_HostnameCloaked(CLIENT *Client)
* Get (potentially cloaked) hostname of a client to display it to other users.
*
* If the client has not enabled cloaking, the real hostname is used.
- * Please note that this function uses a global static buffer, so you can't
- * nest invocations without overwriting earlier results!
*
* @param Client Pointer to client structure
* @return Pointer to client hostname
@@ -760,7 +760,7 @@ Client_HostnameDisplayed(CLIENT *Client)
return Client_Hostname(Client);
/* Use an already saved cloaked hostname, if there is one */
- if (Client->cloaked[0])
+ if (Client->cloaked)
return Client->cloaked;
Client_UpdateCloakedHostname(Client, NULL, NULL);
@@ -781,25 +781,32 @@ GLOBAL void
Client_UpdateCloakedHostname(CLIENT *Client, CLIENT *Origin,
const char *Hostname)
{
- static char Cloak_Buffer[CLIENT_HOST_LEN];
+ char Cloak_Buffer[CLIENT_HOST_LEN];
assert(Client != NULL);
if (!Origin)
Origin = Client_ThisServer();
+ if (!Client->cloaked) {
+ Client->cloaked = malloc(CLIENT_HOST_LEN);
+ if (!Client->cloaked)
+ return;
+ }
+
if (!Hostname) {
/* Generate new cloaked hostname */
if (*Conf_CloakHostModeX) {
- strlcpy(Cloak_Buffer, Client->host, CLIENT_HOST_LEN);
+ strlcpy(Cloak_Buffer, Client->host,
+ sizeof(Cloak_Buffer));
strlcat(Cloak_Buffer, Conf_CloakHostSalt,
- CLIENT_HOST_LEN);
- snprintf(Client->cloaked, sizeof(Client->cloaked),
+ sizeof(Cloak_Buffer));
+ snprintf(Client->cloaked, CLIENT_HOST_LEN,
Conf_CloakHostModeX, Hash(Cloak_Buffer));
} else
strlcpy(Client->cloaked, Client_ID(Client->introducer),
- sizeof(Client->cloaked));
+ CLIENT_HOST_LEN);
} else
- strlcpy(Client->cloaked, Hostname, sizeof(Client->cloaked));
+ strlcpy(Client->cloaked, Hostname, CLIENT_HOST_LEN);
LogDebug("Cloaked hostname of \"%s\" updated to \"%s\"",
Client_ID(Client), Client->cloaked);
diff --git a/src/ngircd/client.h b/src/ngircd/client.h
index 94ca4dc..6d5298f 100644
--- a/src/ngircd/client.h
+++ b/src/ngircd/client.h
@@ -48,7 +48,7 @@ typedef struct _CLIENT
struct _CLIENT *introducer; /* ID of the servers which the client is connected to */
struct _CLIENT *topserver; /* toplevel servers (only valid if client is a server) */
char host[CLIENT_HOST_LEN]; /* hostname of the client */
- char cloaked[CLIENT_HOST_LEN]; /* cloaked hostname of the client */
+ char *cloaked; /* cloaked hostname of the client */
char user[CLIENT_USER_LEN]; /* user name ("login") */
#if defined(PAM) && defined(IDENTAUTH)
char orig_user[CLIENT_USER_LEN];/* user name supplied by USER command */