Module: ngircd.git
Branch: master
Commit: 94e4562c1c732f7bf67bed2f77cc7b3b0aeaeafe
URL: http://ngircd.barton.de/cgi-bin/gitweb.cgi?p=ngircd.git&a=commit;h=94e4562c…
Author: Alexander Barton <alex(a)barton.de>
Date: Wed Feb 23 22:55:45 2011 +0100
PAM-Auth child: log if result can't be reported
This fixes the followin GCC warning on modern Linux systems as well:
irc-login.c: In function ‘Hello_User’:
irc-login.c:876: warning: ignoring return value of ‘write’,
declared with attribute warn_unused_result
---
src/ngircd/irc-login.c | 4 +++-
1 files changed, 3 insertions(+), 1 deletions(-)
diff --git a/src/ngircd/irc-login.c b/src/ngircd/irc-login.c
index 6a97074..f76a627 100644
--- a/src/ngircd/irc-login.c
+++ b/src/ngircd/irc-login.c
@@ -873,7 +873,9 @@ Hello_User(CLIENT * Client)
/* Sub process */
Log_Init_Subprocess("Auth");
result = PAM_Authenticate(Client);
- write(pipefd[1], &result, sizeof(result));
+ if (write(pipefd[1], &result, sizeof(result)) != sizeof(result))
+ Log_Subprocess(LOG_ERR,
+ "Failed to pipe result to parent!");
Log_Exit_Subprocess("Auth");
exit(0);
}
Module: ngircd.git
Branch: master
Commit: 6caa947f989b692cf8bf3568cffa03b5c21374e9
URL: http://ngircd.barton.de/cgi-bin/gitweb.cgi?p=ngircd.git&a=commit;h=6caa947f…
Author: Alexander Barton <alex(a)barton.de>
Date: Thu Feb 17 12:26:56 2011 +0100
Protocol.txt: Update description of CHANINFO command
---
doc/Protocol.txt | 10 ++++++++--
1 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/doc/Protocol.txt b/doc/Protocol.txt
index 2b7e7b8..5093eea 100644
--- a/doc/Protocol.txt
+++ b/doc/Protocol.txt
@@ -141,11 +141,17 @@ therefore to disconnect the peer prior to registering it in the network.
II.3 Exchange channel-modes, topics, and persistent channels
Command: CHANINFO
- Parameters: <channel> +<modes> <key> <limit> [<topic>]
+ Parameters: <channel> +<modes> [[<key> <limit>] <topic>]
Used by: servers only
CHANINFO is used by servers to inform each other about a channel: its
-modes, channel key, user limits and its topic. <topic> is optional.
+modes, channel key, user limits and its topic. The parameter combination
+<key> and <limit> is optional, as well as the <topic> parameter, so that
+there are three possible forms of this command:
+
+ CHANINFO <channel> +<modes>
+ CHANINFO <channel> +<modes> <topic>
+ CHANINFO <channel> +<modes> <key> <limit> <topic>
If the channel already exists on the server receiving the CHANINFO command,
it only adopts the <modes> (or the <topic>) if there are no modes (or topic)
Module: ngircd.git
Branch: master
Commit: 07f241ff6d3afee88d6c6b3e2ed1e195c0367c91
URL: http://ngircd.barton.de/cgi-bin/gitweb.cgi?p=ngircd.git&a=commit;h=07f241ff…
Author: Alexander Barton <alex(a)barton.de>
Date: Wed Dec 29 14:10:18 2010 +0100
Enhance documentation for the WEBIRC command
---
doc/Protocol.txt | 14 ++++++++++++++
src/ngircd/irc-login.c | 10 ++++++++--
2 files changed, 22 insertions(+), 2 deletions(-)
diff --git a/doc/Protocol.txt b/doc/Protocol.txt
index 354b814..2b7e7b8 100644
--- a/doc/Protocol.txt
+++ b/doc/Protocol.txt
@@ -161,3 +161,17 @@ and therefore can't be omitted. The parameter <limit> must be ignored when
a channel has no user limit (the parameter <modes> doesn't list the "l"
channel mode). In this case <limit> should be "0".
+
+II.4 Update webchat/proxy client information
+
+ Command: WEBIRC
+ Parameters: <password> <username> <hostname> <ip-address>
+ Used by: unregistered clients only
+
+The WEBIRC command is used by some Web-to-IRC gateways to set the correct
+user name and host name of users instead of their own. It must be the very
+first command sent to the server, even before USER and NICK commands!
+
+The <password> must be set in the server configuration file to prevent
+unauthorized clients to fake their identity; it is an arbitrary string.
+
diff --git a/src/ngircd/irc-login.c b/src/ngircd/irc-login.c
index 1557f18..6a97074 100644
--- a/src/ngircd/irc-login.c
+++ b/src/ngircd/irc-login.c
@@ -596,8 +596,14 @@ IRC_SERVICE(CLIENT *Client, REQUEST *Req)
/**
- * Handler for the IRC command "WEBIRC".
- * Syntax: WEBIRC <password> <username> <real-hostname> <real-IP-address>
+ * Handler for the IRC "WEBIRC" command.
+ *
+ * See doc/Protocol.txt, section II.4:
+ * "Update webchat/proxy client information".
+ *
+ * @param Client The client from which this command has been received.
+ * @param Req Request structure with prefix and all parameters.
+ * @returns CONNECTED or DISCONNECTED.
*/
GLOBAL bool
IRC_WEBIRC(CLIENT *Client, REQUEST *Req)
Module: ngircd.git
Branch: master
Commit: 53fecf5a2b3e0f396b08b2a00a73eb73c46e1853
URL: http://ngircd.barton.de/cgi-bin/gitweb.cgi?p=ngircd.git&a=commit;h=53fecf5a…
Author: Alexander Barton <alex(a)barton.de>
Date: Wed Dec 29 14:09:46 2010 +0100
Doxygen'ify irc-login.c
---
src/ngircd/irc-login.c | 113 ++++++++++++++++++++++++++++++++++++++++++++++--
1 files changed, 109 insertions(+), 4 deletions(-)
diff --git a/src/ngircd/irc-login.c b/src/ngircd/irc-login.c
index a0f16a9..1557f18 100644
--- a/src/ngircd/irc-login.c
+++ b/src/ngircd/irc-login.c
@@ -56,8 +56,13 @@ static void cb_Read_Auth_Result PARAMS((int r_fd, UNUSED short events));
#endif
/**
- * Handler for the IRC command "PASS".
+ * Handler for the IRC "PASS" command.
+ *
* See RFC 2813 section 4.1.1, and RFC 2812 section 3.1.1.
+ *
+ * @param Client The client from which this command has been received.
+ * @param Req Request structure with prefix and all parameters.
+ * @returns CONNECTED or DISCONNECTED.
*/
GLOBAL bool
IRC_PASS( CLIENT *Client, REQUEST *Req )
@@ -176,10 +181,17 @@ IRC_PASS( CLIENT *Client, REQUEST *Req )
/**
- * IRC "NICK" command.
+ * Handler for the IRC "NICK" command.
+ *
+ * See RFC 2812, 3.1.2 "Nick message", and RFC 2813, 4.1.3 "Nick".
+ *
* This function implements the IRC command "NICK" which is used to register
* with the server, to change already registered nicknames and to introduce
* new users which are connected to other servers.
+ *
+ * @param Client The client from which this command has been received.
+ * @param Req Request structure with prefix and all parameters.
+ * @returns CONNECTED or DISCONNECTED.
*/
GLOBAL bool
IRC_NICK( CLIENT *Client, REQUEST *Req )
@@ -381,7 +393,13 @@ IRC_NICK( CLIENT *Client, REQUEST *Req )
/**
- * Handler for the IRC command "USER".
+ * Handler for the IRC "USER" command.
+ *
+ * See RFC 2812, 3.1.3 "User message".
+ *
+ * @param Client The client from which this command has been received.
+ * @param Req Request structure with prefix and all parameters.
+ * @returns CONNECTED or DISCONNECTED.
*/
GLOBAL bool
IRC_USER(CLIENT * Client, REQUEST * Req)
@@ -474,12 +492,18 @@ IRC_USER(CLIENT * Client, REQUEST * Req)
/**
- * Handler for the IRC command "SERVICE".
+ * Handler for the IRC "SERVICE" command.
+ *
* This function implements IRC Services registration using the SERVICE command
* defined in RFC 2812 3.1.6 and RFC 2813 4.1.4.
+ *
* At the moment ngIRCd doesn't support directly linked services, so this
* function returns ERR_ERRONEUSNICKNAME when the SERVICE command has not been
* received from a peer server.
+ *
+ * @param Client The client from which this command has been received.
+ * @param Req Request structure with prefix and all parameters.
+ * @returns CONNECTED or DISCONNECTED..
*/
GLOBAL bool
IRC_SERVICE(CLIENT *Client, REQUEST *Req)
@@ -597,6 +621,15 @@ IRC_WEBIRC(CLIENT *Client, REQUEST *Req)
} /* IRC_WEBIRC */
+/**
+ * Handler for the IRC "QUIT" command.
+ *
+ * See RFC 2812, 3.1.7 "Quit", and RFC 2813, 4.1.5 "Quit".
+ *
+ * @param Client The client from which this command has been received.
+ * @param Req Request structure with prefix and all parameters.
+ * @returns CONNECTED or DISCONNECTED.
+ */
GLOBAL bool
IRC_QUIT( CLIENT *Client, REQUEST *Req )
{
@@ -644,6 +677,15 @@ IRC_QUIT( CLIENT *Client, REQUEST *Req )
} /* IRC_QUIT */
+/**
+ * Handler for the IRC "PING" command.
+ *
+ * See RFC 2812, 3.7.2 "Ping message".
+ *
+ * @param Client The client from which this command has been received.
+ * @param Req Request structure with prefix and all parameters.
+ * @returns CONNECTED or DISCONNECTED.
+ */
GLOBAL bool
IRC_PING(CLIENT *Client, REQUEST *Req)
{
@@ -713,6 +755,15 @@ IRC_PING(CLIENT *Client, REQUEST *Req)
} /* IRC_PING */
+/**
+ * Handler for the IRC "PONG" command.
+ *
+ * See RFC 2812, 3.7.3 "Pong message".
+ *
+ * @param Client The client from which this command has been received.
+ * @param Req Request structure with prefix and all parameters.
+ * @returns CONNECTED or DISCONNECTED.
+ */
GLOBAL bool
IRC_PONG(CLIENT *Client, REQUEST *Req)
{
@@ -771,6 +822,17 @@ IRC_PONG(CLIENT *Client, REQUEST *Req)
} /* IRC_PONG */
+/**
+ * Initiate client registration.
+ *
+ * This function is called after the daemon received the required NICK and
+ * USER commands of a new client. If the daemon is compiled with support for
+ * PAM, the authentication sub-processs is forked; otherwise the global server
+ * password is checked.
+ *
+ * @param Client The client logging in.
+ * @returns CONNECTED or DISCONNECTED.
+ */
static bool
Hello_User(CLIENT * Client)
{
@@ -827,6 +889,9 @@ Hello_User(CLIENT * Client)
/**
* Read result of the authenticatior sub-process from pipe
+ *
+ * @param r_fd File descriptor of the pipe.
+ * @param events (ignored IO specification)
*/
static void
cb_Read_Auth_Result(int r_fd, UNUSED short events)
@@ -870,6 +935,14 @@ cb_Read_Auth_Result(int r_fd, UNUSED short events)
#endif
+/**
+ * Reject a client because of wrong password.
+ *
+ * This function is called either when the global server password or a password
+ * checked using PAM has been wrong.
+ *
+ * @param Client The client to reject.
+ */
static void
Reject_Client(CLIENT *Client)
{
@@ -881,6 +954,15 @@ Reject_Client(CLIENT *Client)
}
+/**
+ * Finish client registration.
+ *
+ * Introduce the new client to the network and send all "hello messages"
+ * to it after authentication has been succeeded.
+ *
+ * @param Client The client logging in.
+ * @returns CONNECTED or DISCONNECTED.
+ */
static bool
Hello_User_PostAuth(CLIENT *Client)
{
@@ -920,6 +1002,12 @@ Hello_User_PostAuth(CLIENT *Client)
}
+/**
+ * Kill all users with a specific nick name in the network.
+ *
+ * @param Nick Nick name.
+ * @param Reason Reason for the KILL.
+ */
static void
Kill_Nick( char *Nick, char *Reason )
{
@@ -938,6 +1026,13 @@ Kill_Nick( char *Nick, char *Reason )
} /* Kill_Nick */
+/**
+ * Introduce a new user or service client in the network.
+ *
+ * @param From Remote server introducing the client or NULL (local).
+ * @param Client New client.
+ * @param Type Type of the client (CLIENT_USER or CLIENT_SERVICE).
+ */
static void
Introduce_Client(CLIENT *From, CLIENT *Client, int Type)
{
@@ -971,6 +1066,16 @@ Introduce_Client(CLIENT *From, CLIENT *Client, int Type)
} /* Introduce_Client */
+/**
+ * Introduce a new user or service client to a remote server.
+ *
+ * This function differentiates between RFC1459 and RFC2813 server links and
+ * generates the appropriate commands to register the new user or service.
+ *
+ * @param To The remote server to inform.
+ * @param Prefix Prefix for the generated commands.
+ * @param data CLIENT structure of the new client.
+ */
static void
cb_introduceClient(CLIENT *To, CLIENT *Prefix, void *data)
{
Module: ngircd.git
Branch: master
Commit: 8a674c3263a2b4e0dfbac40acfd9e3320bbc5321
URL: http://ngircd.barton.de/cgi-bin/gitweb.cgi?p=ngircd.git&a=commit;h=8a674c32…
Author: Alexander Barton <alex(a)barton.de>
Date: Wed Dec 29 13:11:20 2010 +0100
Doxygen'ify irc-channel.c
---
src/ngircd/irc-channel.c | 121 ++++++++++++++++++++++++++++++++++++++++------
1 files changed, 105 insertions(+), 16 deletions(-)
diff --git a/src/ngircd/irc-channel.c b/src/ngircd/irc-channel.c
index a7a273d..33ea68d 100644
--- a/src/ngircd/irc-channel.c
+++ b/src/ngircd/irc-channel.c
@@ -39,13 +39,18 @@
#include "irc-channel.h"
-/*
+/**
+ * Part from all channels.
+ *
* RFC 2812, (3.2.1 Join message Command):
- * Note that this message
- * accepts a special argument ("0"), which is a special request to leave all
- * channels the user is currently a member of. The server will process this
- * message as if the user had sent a PART command (See Section 3.2.2) for
- * each channel he is a member of.
+ * Note that this message accepts a special argument ("0"), which is a
+ * special request to leave all channels the user is currently a member of.
+ * The server will process this message as if the user had sent a PART
+ * command (See Section 3.2.2) for each channel he is a member of.
+ *
+ * @param client Client that initiated the part request
+ * @param target Client that should part all joined channels
+ * @returns CONNECTED or DISCONNECTED
*/
static bool
part_from_all_channels(CLIENT* client, CLIENT *target)
@@ -59,17 +64,18 @@ part_from_all_channels(CLIENT* client, CLIENT *target)
Channel_Part(target, client, Channel_Name(chan), Client_ID(target));
}
return CONNECTED;
-}
+} /* part_from_all_channels */
/**
* Check weather a local client is allowed to join an already existing
* channel or not.
- * @param Client Client that sent the JOIN command
- * @param chan Channel to check
- * @param channame Name of the channel
- * @param key Provided channel key (or NULL if none has been provided)
- * @return true if client is allowed to join channel, false otherwise
+ *
+ * @param Client Client that sent the JOIN command
+ * @param chan Channel to check
+ * @param channame Name of the channel
+ * @param key Provided channel key (or NULL)
+ * @returns true if client is allowed to join, false otherwise
*/
static bool
join_allowed(CLIENT *Client, CHANNEL *chan, const char *channame,
@@ -132,9 +138,16 @@ join_allowed(CLIENT *Client, CHANNEL *chan, const char *channame,
}
return true;
-}
+} /* join_allowed */
+/**
+ * Set user channel modes.
+ *
+ * @param chan Channel
+ * @param target User to set modes for
+ * @param flags Channel modes to add
+ */
static void
join_set_channelmodes(CHANNEL *chan, CLIENT *target, const char *flags)
{
@@ -148,9 +161,22 @@ join_set_channelmodes(CHANNEL *chan, CLIENT *target, const char *flags)
/* If channel persistent and client is ircop: make client chanop */
if (strchr(Channel_Modes(chan), 'P') && strchr(Client_Modes(target), 'o'))
Channel_UserModeAdd(chan, target, 'o');
-}
+} /* join_set_channelmodes */
+/**
+ * Forward JOIN command to a specific server
+ *
+ * This function diffentiates between servers using RFC 2813 mode that
+ * support the JOIN command with appended ASCII 7 character and channel
+ * modes, and servers using RFC 1459 protocol which require separate JOIN
+ * and MODE commands.
+ *
+ * @param To Forward JOIN (and MODE) command to this peer server
+ * @param Prefix Client used to prefix the genrated commands
+ * @param Data Parameters of JOIN command to forward, probably
+ * containing channel modes separated by ASCII 7.
+ */
static void
cb_join_forward(CLIENT *To, CLIENT *Prefix, void *Data)
{
@@ -175,12 +201,25 @@ cb_join_forward(CLIENT *To, CLIENT *Prefix, void *Data)
} /* cb_join_forward */
+/**
+ * Forward JOIN command to all servers
+ *
+ * This function calls cb_join_forward(), which differentiates between
+ * protocol implementations (e.g. RFC 2812, RFC 1459).
+ *
+ * @param Client Client used to prefix the genrated commands
+ * @param target Forward JOIN (and MODE) command to this peer server
+ * @param chan Channel structure
+ * @param channame Channel name
+ */
static void
join_forward(CLIENT *Client, CLIENT *target, CHANNEL *chan,
const char *channame)
{
char modes[CHANNEL_MODE_LEN], str[COMMAND_LEN];
+ /* RFC 2813, 4.2.1: channel modes are separated from the channel
+ * name with ASCII 7, if any, and not spaces: */
strlcpy(&modes[1], Channel_UserModes(chan, target), sizeof(modes) - 1);
if (modes[1])
modes[0] = 0x7;
@@ -207,6 +246,14 @@ join_forward(CLIENT *Client, CLIENT *target, CHANNEL *chan,
} /* join_forward */
+/**
+ * Aknowledge user JOIN request and send "channel info" numerics.
+ *
+ * @param Client Client used to prefix the genrated commands
+ * @param target Forward commands/numerics to this user
+ * @param chan Channel structure
+ * @param channame Channel name
+ */
static bool
join_send_topic(CLIENT *Client, CLIENT *target, CHANNEL *chan,
const char *channame)
@@ -237,10 +284,20 @@ join_send_topic(CLIENT *Client, CLIENT *target, CHANNEL *chan,
/* send list of channel members to client */
if (!IRC_Send_NAMES(Client, chan))
return false;
- return IRC_WriteStrClient(Client, RPL_ENDOFNAMES_MSG, Client_ID(Client), Channel_Name(chan));
-}
+ return IRC_WriteStrClient(Client, RPL_ENDOFNAMES_MSG, Client_ID(Client),
+ Channel_Name(chan));
+} /* join_send_topic */
+/**
+ * Handler for the IRC "JOIN" command.
+ *
+ * See RFC 2812, 3.2.1 "Join message"; RFC 2813, 4.2.1 "Join message".
+ *
+ * @param Client The client from which this command has been received
+ * @param Req Request structure with prefix and all parameters
+ * @returns CONNECTED or DISCONNECTED
+ */
GLOBAL bool
IRC_JOIN( CLIENT *Client, REQUEST *Req )
{
@@ -365,6 +422,12 @@ IRC_JOIN( CLIENT *Client, REQUEST *Req )
/**
* Handler for the IRC "PART" command.
+ *
+ * See RFC 2812, 3.2.2: "Part message".
+ *
+ * @param Client The client from which this command has been received
+ * @param Req Request structure with prefix and all parameters
+ * @returns CONNECTED or DISCONNECTED
*/
GLOBAL bool
IRC_PART(CLIENT * Client, REQUEST * Req)
@@ -410,6 +473,15 @@ IRC_PART(CLIENT * Client, REQUEST * Req)
} /* IRC_PART */
+/**
+ * Handler for the IRC "TOPIC" command.
+ *
+ * See RFC 2812, 3.2.4 "Topic message".
+ *
+ * @param Client The client from which this command has been received
+ * @param Req Request structure with prefix and all parameters
+ * @returns CONNECTED or DISCONNECTED
+ */
GLOBAL bool
IRC_TOPIC( CLIENT *Client, REQUEST *Req )
{
@@ -502,8 +574,15 @@ IRC_TOPIC( CLIENT *Client, REQUEST *Req )
/**
* Handler for the IRC "LIST" command.
+ *
+ * See RFC 2812, 3.2.6 "List message".
+ *
* This implementation handles the local case as well as the forwarding of the
* LIST command to other servers in the IRC network.
+ *
+ * @param Client The client from which this command has been received
+ * @param Req Request structure with prefix and all parameters
+ * @returns CONNECTED or DISCONNECTED
*/
GLOBAL bool
IRC_LIST( CLIENT *Client, REQUEST *Req )
@@ -587,6 +666,16 @@ IRC_LIST( CLIENT *Client, REQUEST *Req )
} /* IRC_LIST */
+/**
+ * Handler for the IRC+ command "CHANINFO".
+ *
+ * See doc/Protocol.txt, section II.3:
+ * "Exchange channel-modes, topics, and persistent channels".
+ *
+ * @param Client The client from which this command has been received
+ * @param Req Request structure with prefix and all parameters
+ * @returns CONNECTED or DISCONNECTED
+ */
GLOBAL bool
IRC_CHANINFO( CLIENT *Client, REQUEST *Req )
{
Module: ngircd.git
Branch: master
Commit: 5858dc3886e492f96a42b61decdda3c1acd920a4
URL: http://ngircd.barton.de/cgi-bin/gitweb.cgi?p=ngircd.git&a=commit;h=5858dc38…
Author: Alexander Barton <alex(a)barton.de>
Date: Mon Dec 27 17:37:56 2010 +0100
Doxygen'ify proc.h
---
src/ngircd/proc.h | 7 +++++--
1 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/src/ngircd/proc.h b/src/ngircd/proc.h
index bb4bceb..84b61f2 100644
--- a/src/ngircd/proc.h
+++ b/src/ngircd/proc.h
@@ -19,11 +19,14 @@
/** Process status. This struct must not be accessed directly! */
typedef struct _Proc_Stat {
- pid_t pid; /* PID of the child process or 0 if none */
- int pipe_fd; /* Pipe file descriptor or -1 if none */
+ pid_t pid; /**< PID of the child process or 0 if none */
+ int pipe_fd; /**< Pipe file descriptor or -1 if none */
} PROC_STAT;
+/** Return true if sub-process is still running */
#define Proc_InProgress(x) ((x)->pid != 0)
+
+/** Return file descriptor of pipe to sub-process (or -1 if none open) */
#define Proc_GetPipeFd(x) ((x)->pipe_fd)
GLOBAL void Proc_InitStruct PARAMS((PROC_STAT *proc));