about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/ngircd/client.c151
-rw-r--r--src/ngircd/client.h5
-rw-r--r--src/ngircd/conf.c4
-rw-r--r--src/ngircd/conn-encoding.c2
-rw-r--r--src/ngircd/conn-func.c8
-rw-r--r--src/ngircd/conn-ssl.c8
-rw-r--r--src/ngircd/conn-ssl.h4
-rw-r--r--src/ngircd/conn.c29
-rw-r--r--src/ngircd/conn.h4
-rw-r--r--src/ngircd/irc-channel.c8
-rw-r--r--src/ngircd/irc-info.c10
-rw-r--r--src/ngircd/irc-login.c2
-rw-r--r--src/ngircd/irc-metadata.c4
-rw-r--r--src/ngircd/irc-mode.c6
-rw-r--r--src/ngircd/irc-server.c8
-rw-r--r--src/ngircd/irc-write.c4
-rw-r--r--src/ngircd/irc.c2
-rw-r--r--src/ngircd/log.c2
-rw-r--r--src/ngircd/login.c4
-rw-r--r--src/ngircd/match.c1
-rw-r--r--src/ngircd/ngircd.c2
-rw-r--r--src/ngircd/numeric.c82
-rw-r--r--src/ngircd/pam.c2
-rw-r--r--src/ngircd/pam.h2
-rw-r--r--src/ngircd/parse.c10
-rw-r--r--src/ngircd/sighandlers.c4
26 files changed, 172 insertions, 196 deletions
diff --git a/src/ngircd/client.c b/src/ngircd/client.c
index 37b168ff..09bd6fde 100644
--- a/src/ngircd/client.c
+++ b/src/ngircd/client.c
@@ -87,7 +87,7 @@ Client_Init( void )
 		exit( 1 );
 	}
 
-	/* Client-Struktur dieses Servers */
+	/* Client structure for this server */
 	This_Server->next = NULL;
 	This_Server->type = CLIENT_SERVER;
 	This_Server->conn_id = NONE;
@@ -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;
 		}
@@ -513,7 +515,7 @@ GLOBAL bool
 Client_ModeAdd( CLIENT *Client, char Mode )
 {
 	/* Set Mode.
-	 * If Client already alread had Mode, return false.
+	 * If Client already had Mode, return false.
 	 * If the Mode was newly set, return true.
 	 */
 
@@ -589,7 +591,7 @@ Client_Search( const char *Nick )
 
 
 /**
- * Serach first CLIENT structure matching a given mask of a server.
+ * Search first CLIENT structure matching a given mask of a server.
  *
  * The order of servers is arbitrary, but this function makes sure that the
  * local server is always returned if the mask matches it.
@@ -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);
 
@@ -950,6 +957,14 @@ Client_HasMode( CLIENT *Client, char Mode )
 } /* Client_HasMode */
 
 
+GLOBAL bool
+Client_HasFlag( CLIENT *Client, char Flag )
+{
+	assert( Client != NULL );
+	return strchr( Client->flags, Flag ) != NULL;
+} /* Client_HasFlag */
+
+
 GLOBAL char *
 Client_Away( CLIENT *Client )
 {
@@ -1326,8 +1341,6 @@ MyCount( CLIENT_TYPE Type )
 static CLIENT *
 New_Client_Struct( void )
 {
-	/* Neue CLIENT-Struktur pre-initialisieren */
-
 	CLIENT *c;
 
 	c = (CLIENT *)malloc( sizeof( CLIENT ));
@@ -1362,7 +1375,7 @@ Generate_MyToken( CLIENT *Client )
 	{
 		if( c->mytoken == token )
 		{
-			/* Das Token wurde bereits vergeben */
+			/* The token is already in use */
 			token++;
 			c = My_Clients;
 			continue;
@@ -1513,9 +1526,6 @@ Destroy_UserOrService(CLIENT *Client, const char *Txt, const char *FwdMsg, bool
 /**
  * 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.
@@ -1524,43 +1534,92 @@ static void
 cb_introduceClient(CLIENT *To, CLIENT *Prefix, void *data)
 {
 	CLIENT *c = (CLIENT *)data;
+
+	(void)Client_Announce(To, Prefix, c);
+
+} /* cb_introduceClient */
+
+
+/**
+ * Announce an user or service to a server.
+ *
+ * This function differentiates between RFC1459 and RFC2813 server links and
+ * generates the appropriate commands to register the user or service.
+ *
+ * @param Client	Server
+ * @param Prefix	Prefix for the generated commands
+ * @param User		User to announce
+ */
+GLOBAL bool
+Client_Announce(CLIENT * Client, CLIENT * Prefix, CLIENT * User)
+{
 	CONN_ID conn;
 	char *modes, *user, *host;
 
-	modes = Client_Modes(c);
-	user = Client_User(c) ? Client_User(c) : "-";
-	host = Client_Hostname(c) ? Client_Hostname(c) : "-";
+	modes = Client_Modes(User);
+	user = Client_User(User) ? Client_User(User) : "-";
+	host = Client_Hostname(User) ? Client_Hostname(User) : "-";
 
-	conn = Client_Conn(To);
+	conn = Client_Conn(Client);
 	if (Conn_Options(conn) & CONN_RFC1459) {
 		/* RFC 1459 mode: separate NICK and USER commands */
-		Conn_WriteStr(conn, "NICK %s :%d", Client_ID(c),
-			      Client_Hops(c) + 1);
-		Conn_WriteStr(conn, ":%s USER %s %s %s :%s",
-			      Client_ID(c), user, host,
-			      Client_ID(Client_Introducer(c)), Client_Info(c));
-		if (modes[0])
-			Conn_WriteStr(conn, ":%s MODE %s +%s",
-				      Client_ID(c), Client_ID(c), modes);
+		if (! Conn_WriteStr(conn, "NICK %s :%d",
+				    Client_ID(User), Client_Hops(User) + 1))
+			return DISCONNECTED;
+		if (! Conn_WriteStr(conn, ":%s USER %s %s %s :%s",
+				     Client_ID(User), user, host,
+				     Client_ID(Client_Introducer(User)),
+				     Client_Info(User)))
+			return DISCONNECTED;
+		if (modes[0]) {
+			if (! Conn_WriteStr(conn, ":%s MODE %s +%s",
+				     Client_ID(User), Client_ID(User),
+				     modes))
+				return DISCONNECTED;
+		}
 	} else {
 		/* RFC 2813 mode: one combined NICK or SERVICE command */
-		if (Client_Type(c) == CLIENT_SERVICE
-		    && strchr(Client_Flags(To), 'S'))
-			IRC_WriteStrClientPrefix(To, Prefix,
-						 "SERVICE %s %d * +%s %d :%s",
-						 Client_Mask(c),
-						 Client_MyToken(Client_Introducer(c)),
-						 Client_Modes(c), Client_Hops(c) + 1,
-						 Client_Info(c));
-		else
-			IRC_WriteStrClientPrefix(To, Prefix,
-						 "NICK %s %d %s %s %d +%s :%s",
-						 Client_ID(c), Client_Hops(c) + 1,
-						 user, host,
-						 Client_MyToken(Client_Introducer(c)),
-						 modes, Client_Info(c));
+		if (Client_Type(User) == CLIENT_SERVICE
+		    && strchr(Client_Flags(Client), 'S')) {
+			if (!IRC_WriteStrClientPrefix(Client, Prefix,
+					"SERVICE %s %d * +%s %d :%s",
+					Client_Mask(User),
+					Client_MyToken(Client_Introducer(User)),
+					modes, Client_Hops(User) + 1,
+					Client_Info(User)))
+				return DISCONNECTED;
+		} else {
+			if (!IRC_WriteStrClientPrefix(Client, Prefix,
+					"NICK %s %d %s %s %d +%s :%s",
+					Client_ID(User), Client_Hops(User) + 1,
+					user, host,
+					Client_MyToken(Client_Introducer(User)),
+					modes, Client_Info(User)))
+				return DISCONNECTED;
+		}
 	}
-} /* cb_introduceClient */
+
+	if (strchr(Client_Flags(Client), 'M')) {
+		/* Synchronize metadata */
+		if (Client_HostnameCloaked(User)) {
+			if (!IRC_WriteStrClientPrefix(Client, Prefix,
+					"METADATA %s cloakhost :%s",
+					Client_ID(User),
+					Client_HostnameCloaked(User)))
+				return DISCONNECTED;
+		}
+
+		if (Conn_GetCertFp(Client_Conn(User))) {
+			if (!IRC_WriteStrClientPrefix(Client, Prefix,
+					"METADATA %s certfp :%s",
+					Client_ID(User),
+					Conn_GetCertFp(Client_Conn(User))))
+				return DISCONNECTED;
+		}
+	}
+
+	return CONNECTED;
+} /* Client_Announce */
 
 
 #ifdef DEBUG
diff --git a/src/ngircd/client.h b/src/ngircd/client.h
index c248d1ba..6d5298fc 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 */
@@ -93,6 +93,8 @@ GLOBAL CLIENT *Client_ThisServer PARAMS(( void ));
 
 GLOBAL CLIENT *Client_GetFromToken PARAMS(( CLIENT *Client, int Token ));
 
+GLOBAL bool Client_Announce PARAMS(( CLIENT *Client, CLIENT *Prefix, CLIENT *User ));
+
 GLOBAL CLIENT *Client_Search PARAMS(( const char *ID ));
 GLOBAL CLIENT *Client_SearchServer PARAMS(( const char *ID ));
 GLOBAL CLIENT *Client_First PARAMS(( void ));
@@ -124,6 +126,7 @@ GLOBAL char *Client_Away PARAMS(( CLIENT *Client ));
 GLOBAL time_t Client_StartTime PARAMS(( CLIENT *Client ));
 
 GLOBAL bool Client_HasMode PARAMS(( CLIENT *Client, char Mode ));
+GLOBAL bool Client_HasFlag PARAMS(( CLIENT *Client, char Flag ));
 
 GLOBAL void Client_SetHostname PARAMS(( CLIENT *Client, const char *Hostname ));
 GLOBAL void Client_SetID PARAMS(( CLIENT *Client, const char *Nick ));
diff --git a/src/ngircd/conf.c b/src/ngircd/conf.c
index 70c96092..79376b80 100644
--- a/src/ngircd/conf.c
+++ b/src/ngircd/conf.c
@@ -317,7 +317,7 @@ opers_puts(void)
  * This function waits for a keypress of the user when stdin/stdout are valid
  * tty's ("you can read our nice message and we can read in your keypress").
  *
- * @return	0 on succes, 1 on failure(s); therefore the result code can
+ * @return	0 on success, 1 on failure(s); therefore the result code can
  * 		directly be used by exit() when running "ngircd --configtest".
  */
 GLOBAL int
@@ -2319,7 +2319,7 @@ Conf_DebugDump(void)
 #endif
 
 /**
- * Initialize server configuration structur to default values.
+ * Initialize server configuration structure to default values.
  *
  * @param Server	Pointer to server structure to initialize.
  */
diff --git a/src/ngircd/conn-encoding.c b/src/ngircd/conn-encoding.c
index 71ab5884..98cd29a3 100644
--- a/src/ngircd/conn-encoding.c
+++ b/src/ngircd/conn-encoding.c
@@ -123,7 +123,7 @@ Convert_Message(iconv_t Handle, char *Message)
 	out_left = sizeof(Encoding_Buffer) - 1;
 
 	if (iconv(Handle, &Message, &in_left, &out, &out_left) == (size_t)(-1)) {
-		/* An error occured! */
+		/* An error occurred! */
 		LogDebug("Error converting message encoding!");
 		strlcpy(Encoding_Buffer, Message, sizeof(Encoding_Buffer));
 		iconv(Handle, NULL, NULL, NULL, NULL);
diff --git a/src/ngircd/conn-func.c b/src/ngircd/conn-func.c
index 96476744..b56e0f07 100644
--- a/src/ngircd/conn-func.c
+++ b/src/ngircd/conn-func.c
@@ -137,8 +137,6 @@ Conn_Flag( CONN_ID Idx )
 GLOBAL void
 Conn_SetFlag( CONN_ID Idx, int Flag )
 {
-	/* Connection markieren */
-
 	assert( Idx > NONE );
 	My_Connections[Idx].flag = Flag;
 } /* Conn_SetFlag */
@@ -147,9 +145,6 @@ Conn_SetFlag( CONN_ID Idx, int Flag )
 GLOBAL CONN_ID
 Conn_First( void )
 {
-	/* Connection-Struktur der ersten Verbindung liefern;
-	 * Ist keine Verbindung vorhanden, wird NONE geliefert. */
-
 	CONN_ID i;
 	
 	for( i = 0; i < Pool_Size; i++ )
@@ -163,9 +158,6 @@ Conn_First( void )
 GLOBAL CONN_ID
 Conn_Next( CONN_ID Idx )
 {
-	/* Naechste Verbindungs-Struktur liefern; existiert keine
-	 * weitere, so wird NONE geliefert. */
-
 	CONN_ID i = NONE;
 
 	assert( Idx > NONE );
diff --git a/src/ngircd/conn-ssl.c b/src/ngircd/conn-ssl.c
index 7141eaca..0bca9335 100644
--- a/src/ngircd/conn-ssl.c
+++ b/src/ngircd/conn-ssl.c
@@ -633,7 +633,7 @@ ConnSSL_Connect( CONNECTION *c )
 }
 
 static int
-ConnSSL_InitFingerprint( CONNECTION *c )
+ConnSSL_InitCertFp( CONNECTION *c )
 {
 	const char hex[] = "0123456789abcdef";
 	int i;
@@ -723,7 +723,7 @@ ConnectAccept( CONNECTION *c, bool connect)
 	if (ret)
 		return ConnSSL_HandleError(c, ret, "gnutls_handshake");
 #endif /* _GNUTLS */
-	(void)ConnSSL_InitFingerprint(c);
+	(void)ConnSSL_InitCertFp(c);
 
 	Conn_OPTION_DEL(c, (CONN_SSL_WANT_WRITE|CONN_SSL_WANT_READ|CONN_SSL_CONNECT));
 	ConnSSL_LogCertInfo(c);
@@ -817,13 +817,13 @@ ConnSSL_GetCipherInfo(CONNECTION *c, char *buf, size_t len)
 }
 
 char *
-ConnSSL_GetFingerprint(CONNECTION *c)
+ConnSSL_GetCertFp(CONNECTION *c)
 {
 	return c->ssl_state.fingerprint;
 }
 
 bool
-ConnSSL_SetFingerprint(CONNECTION *c, const char *fingerprint)
+ConnSSL_SetCertFp(CONNECTION *c, const char *fingerprint)
 {
 	assert (c != NULL);
 	c->ssl_state.fingerprint = strdup(fingerprint);
diff --git a/src/ngircd/conn-ssl.h b/src/ngircd/conn-ssl.h
index fc705f13..1e995fd7 100644
--- a/src/ngircd/conn-ssl.h
+++ b/src/ngircd/conn-ssl.h
@@ -26,8 +26,8 @@ GLOBAL ssize_t ConnSSL_Write PARAMS(( CONNECTION *c, const void *buf, size_t cou
 GLOBAL ssize_t ConnSSL_Read PARAMS(( CONNECTION *c, void *buf, size_t count));
 
 GLOBAL bool ConnSSL_GetCipherInfo PARAMS(( CONNECTION *c, char *buf, size_t len ));
-GLOBAL char *ConnSSL_GetFingerprint PARAMS(( CONNECTION *c ));
-GLOBAL bool ConnSSL_SetFingerprint PARAMS(( CONNECTION *c, const char *fingerprint ));
+GLOBAL char *ConnSSL_GetCertFp PARAMS(( CONNECTION *c ));
+GLOBAL bool ConnSSL_SetCertFp PARAMS(( CONNECTION *c, const char *fingerprint ));
 
 #endif /* SSL_SUPPORT */
 #endif /* conn_ssl_h */
diff --git a/src/ngircd/conn.c b/src/ngircd/conn.c
index 9c6baef2..01253a2a 100644
--- a/src/ngircd/conn.c
+++ b/src/ngircd/conn.c
@@ -128,7 +128,7 @@ time_t idle_t = 0;
  * Get number of sockets available from systemd(8).
  *
  * ngIRCd needs to implement its own sd_listen_fds(3) function and can't
- * use the one provided by systemd itself, becaus the sockets will be
+ * use the one provided by systemd itself, because the sockets will be
  * used in a forked child process with a new PID, and this would trigger
  * an error in the standard implementation.
  *
@@ -402,14 +402,13 @@ cb_clientserver_ssl(int sock, UNUSED short what)
 
 
 /**
- * Initialize connecion module.
+ * Initialize connection module.
  */
 GLOBAL void
 Conn_Init( void )
 {
 	CONN_ID i;
 
-	/* Speicher fuer Verbindungs-Pool anfordern */
 	Pool_Size = CONNECTION_POOL;
 	if ((Conf_MaxConnections > 0) &&
 		(Pool_Size > Conf_MaxConnections))
@@ -923,7 +922,7 @@ Conn_Handler(void)
 		 * which is the granularity with witch we handle "penalty
 		 * times" for example.
 		 * Note: tv_sec/usec are undefined(!) after io_dispatch()
-		 * returns, so we have to set it beforce each call to it! */
+		 * returns, so we have to set it before each call to it! */
 		tv.tv_usec = 0;
 		tv.tv_sec = 1;
 
@@ -1008,7 +1007,7 @@ va_dcl
 		 *
 		 * So we have a big problem here: we should send more bytes
 		 * to the network than we are allowed to and we don't know
-		 * the originator (any more). The "old" behaviour of blaming
+		 * the originator (any more). The "old" behavior of blaming
 		 * the receiver ("next hop") is a bad idea (it could be just
 		 * an other server only routing the message!), so the only
 		 * option left is to shorten the string and to hope that the
@@ -1709,7 +1708,7 @@ Socket2Index( int Sock )
 
 
 /**
- * Read data from the network to the read buffer. If an error occures,
+ * Read data from the network to the read buffer. If an error occurs,
  * the socket of this connection will be shut down.
  *
  * @param Idx	Connection index.
@@ -1858,7 +1857,7 @@ Handle_Buffer(CONN_ID Idx)
 		maxcmd = (int)(Client_UserCount() / 5)
 		       + MAX_COMMANDS_SERVER_MIN;
 		/* Allow servers to handle even more commands while peering
-		 * to speed up server login and network synchronisation. */
+		 * to speed up server login and network synchronization. */
 		if (Conn_LastPing(Idx) == 0)
 			maxcmd *= 5;
 		break;
@@ -2352,7 +2351,7 @@ cb_Connect_to_Server(int fd, UNUSED short events)
 
 /**
  * Read results of a resolver sub-process from the pipe and update the
- * apropriate connection/client structure(s): hostname and/or IDENT user name.
+ * appropriate connection/client structure(s): hostname and/or IDENT user name.
  *
  * @param r_fd		File descriptor of the pipe to the sub-process.
  * @param events	(ignored IO specification)
@@ -2579,7 +2578,7 @@ Conn_SetAuthPing(CONN_ID Idx, long ID)
 #ifdef SSL_SUPPORT
 
 /**
- * Get information about used SSL chiper.
+ * Get information about used SSL cipher.
  *
  * @param Idx	Connection index number.
  * @param buf	Buffer for returned information text.
@@ -2613,22 +2612,22 @@ Conn_UsesSSL(CONN_ID Idx)
 
 
 GLOBAL char *
-Conn_GetFingerprint(CONN_ID Idx)
+Conn_GetCertFp(CONN_ID Idx)
 {
 	if (Idx < 0)
 		return NULL;
 	assert(Idx < (int) array_length(&My_ConnArray, sizeof(CONNECTION)));
-	return ConnSSL_GetFingerprint(&My_Connections[Idx]);
+	return ConnSSL_GetCertFp(&My_Connections[Idx]);
 }
 
 
 GLOBAL bool
-Conn_SetFingerprint(CONN_ID Idx, const char *fingerprint)
+Conn_SetCertFp(CONN_ID Idx, const char *fingerprint)
 {
 	if (Idx < 0)
 		return false;
 	assert(Idx < (int) array_length(&My_ConnArray, sizeof(CONNECTION)));
-	return ConnSSL_SetFingerprint(&My_Connections[Idx], fingerprint);
+	return ConnSSL_SetCertFp(&My_Connections[Idx], fingerprint);
 }
 #else
 GLOBAL bool
@@ -2639,14 +2638,14 @@ Conn_UsesSSL(UNUSED CONN_ID Idx)
 
 
 GLOBAL char *
-Conn_GetFingerprint(UNUSED CONN_ID Idx)
+Conn_GetCertFp(UNUSED CONN_ID Idx)
 {
 	return NULL;
 }
 
 
 GLOBAL bool
-Conn_SetFingerprint(UNUSED CONN_ID Idx, UNUSED const char *fingerprint)
+Conn_SetCertFp(UNUSED CONN_ID Idx, UNUSED const char *fingerprint)
 {
 	return true;
 }
diff --git a/src/ngircd/conn.h b/src/ngircd/conn.h
index a6cf53a4..c642541f 100644
--- a/src/ngircd/conn.h
+++ b/src/ngircd/conn.h
@@ -139,8 +139,8 @@ GLOBAL CONN_ID Conn_GetFromProc PARAMS((int fd));
 GLOBAL CLIENT* Conn_GetClient PARAMS((CONN_ID i));
 GLOBAL PROC_STAT* Conn_GetProcStat PARAMS((CONN_ID i));
 
-GLOBAL char *Conn_GetFingerprint PARAMS((CONN_ID Idx));
-GLOBAL bool Conn_SetFingerprint PARAMS((CONN_ID Idx, const char *fingerprint));
+GLOBAL char *Conn_GetCertFp PARAMS((CONN_ID Idx));
+GLOBAL bool Conn_SetCertFp PARAMS((CONN_ID Idx, const char *fingerprint));
 GLOBAL bool Conn_UsesSSL PARAMS((CONN_ID Idx));
 
 #ifdef SSL_SUPPORT
diff --git a/src/ngircd/irc-channel.c b/src/ngircd/irc-channel.c
index 16501bec..07a6e5a5 100644
--- a/src/ngircd/irc-channel.c
+++ b/src/ngircd/irc-channel.c
@@ -175,7 +175,7 @@ join_set_channelmodes(CHANNEL *chan, CLIENT *target, const char *flags)
 /**
  * Forward JOIN command to a specific server
  *
- * This function diffentiates between servers using RFC 2813 mode that
+ * This function differentiates 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.
@@ -253,7 +253,7 @@ join_forward(CLIENT *Client, CLIENT *target, CHANNEL *chan,
 } /* join_forward */
 
 /**
- * Aknowledge user JOIN request and send "channel info" numerics.
+ * Acknowledge 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
@@ -495,7 +495,7 @@ IRC_TOPIC( CLIENT *Client, REQUEST *Req )
 					  Client_ID(from), Req->argv[0]);
 
 	/* Only remote servers and channel members are allowed to change the
-	 * channel topic, and IRC opreators when the Conf_OperCanMode option
+	 * channel topic, and IRC operators when the Conf_OperCanMode option
 	 * is set in the server configuration. */
 	if (Client_Type(Client) != CLIENT_SERVER) {
 		topic_power = Client_HasMode(from, 'o');
@@ -745,7 +745,7 @@ IRC_CHANINFO( CLIENT *Client, REQUEST *Req )
 		}
 	}
 
-	/* Forward CHANINFO to other serevrs */
+	/* Forward CHANINFO to other servers */
 	if (Req->argc == 5)
 		IRC_WriteStrServersPrefixFlag(Client, from, 'C',
 					      "CHANINFO %s %s %s %s :%s",
diff --git a/src/ngircd/irc-info.c b/src/ngircd/irc-info.c
index bc27b8d0..6fb2e31c 100644
--- a/src/ngircd/irc-info.c
+++ b/src/ngircd/irc-info.c
@@ -387,11 +387,11 @@ IRC_WHOIS_SendReply(CLIENT *Client, CLIENT *from, CLIENT *c)
 			return DISCONNECTED;
 
 		/* Certificate fingerprint? */
-		if (Conn_GetFingerprint(Client_Conn(c)) &&
+		if (Conn_GetCertFp(Client_Conn(c)) &&
 		    from == c &&
 		    !IRC_WriteStrClient(from, RPL_WHOISCERTFP_MSG,
 					Client_ID(from), Client_ID(c),
-					Conn_GetFingerprint(Client_Conn(c))))
+					Conn_GetCertFp(Client_Conn(c))))
 			return DISCONNECTED;
 	}
 
@@ -462,10 +462,10 @@ Show_MOTD_SSLInfo(CLIENT *Client)
 			return false;
 	}
 
-	if (Conn_GetFingerprint(Client_Conn(Client))) {
+	if (Conn_GetCertFp(Client_Conn(Client))) {
 		snprintf(buf, sizeof(buf),
 			 "Your client certificate fingerprint is: %s",
-			 Conn_GetFingerprint(Client_Conn(Client)));
+			 Conn_GetCertFp(Client_Conn(Client)));
 		if (!IRC_WriteStrClient(Client, RPL_MOTD_MSG,
 					Client_ID(Client), buf))
 			return false;
@@ -1404,7 +1404,7 @@ IRC_Send_LUSERS(CLIENT *Client)
 
 	assert(Client != NULL);
 
-	/* Users, services and serevers in the network */
+	/* Users, services and servers in the network */
 	if (!IRC_WriteStrClient(Client, RPL_LUSERCLIENT_MSG, Client_ID(Client),
 				Client_UserCount(), Client_ServiceCount(),
 				Client_ServerCount()))
diff --git a/src/ngircd/irc-login.c b/src/ngircd/irc-login.c
index cfb94f60..1915a6d7 100644
--- a/src/ngircd/irc-login.c
+++ b/src/ngircd/irc-login.c
@@ -544,7 +544,7 @@ IRC_SERVICE(CLIENT *Client, REQUEST *Req)
 	/* Validate service name ("nickname") */
 	c = Client_Search(nick);
 	if(c) {
-		/* Nickname collission: disconnect (KILL) both clients! */
+		/* Nickname collision: disconnect (KILL) both clients! */
 		Log(LOG_ERR, "Server %s introduces already registered service \"%s\"!",
 		    Client_ID(Client), nick);
 		Kill_Nick(nick, "Nick collision");
diff --git a/src/ngircd/irc-metadata.c b/src/ngircd/irc-metadata.c
index d64ffb21..3c8a4a85 100644
--- a/src/ngircd/irc-metadata.c
+++ b/src/ngircd/irc-metadata.c
@@ -70,7 +70,7 @@ IRC_METADATA(CLIENT *Client, REQUEST *Req)
 		 Req->argv[1], Req->argv[2]);
 
 	/* Mark client: it has receiveda a METADATA command */
-	if (!strchr(Client_Flags(target), 'M')) {
+	if (!Client_HasFlag(target, 'M')) {
 		snprintf(new_flags, sizeof new_flags, "%sM",
 			 Client_Flags(target));
 		Client_SetFlags(target, new_flags);
@@ -97,7 +97,7 @@ IRC_METADATA(CLIENT *Client, REQUEST *Req)
 	else if (*Req->argv[2] && strcasecmp(Req->argv[1], "user") == 0)
 		Client_SetUser(target, Req->argv[2], true);
 	else if (*Req->argv[2] && strcasecmp(Req->argv[1], "certfp") == 0)
-		Conn_SetFingerprint(Client_Conn(target), Req->argv[2]);
+		Conn_SetCertFp(Client_Conn(target), Req->argv[2]);
 	else
 		Log(LOG_WARNING,
 		    "Ignored metadata update from \"%s\" for client \"%s\": \"%s=%s\" - unknown key!",
diff --git a/src/ngircd/irc-mode.c b/src/ngircd/irc-mode.c
index a51369f0..cebddd22 100644
--- a/src/ngircd/irc-mode.c
+++ b/src/ngircd/irc-mode.c
@@ -54,7 +54,7 @@ static bool Send_ListChange PARAMS((const bool IsAdd, const char ModeChar,
  * Handler for the IRC "MODE" command.
  *
  * This function detects whether user or channel modes should be modified
- * and calls the apropriate sub-functions.
+ * and calls the appropriate sub-functions.
  *
  * @param Client The client from which this command has been received.
  * @param Req Request structure with prefix and all parameters.
@@ -354,7 +354,7 @@ Client_Mode( CLIENT *Client, REQUEST *Req, CLIENT *Origin, CLIENT *Target )
 		}
 
 		if (send_RPL_HOSTHIDDEN_MSG && Client_Conn(Target) > NONE) {
-			/* A new (cloaked) hostname must be annoucned */
+			/* A new (cloaked) hostname must be announced */
 			IRC_WriteStrClientPrefix(Target, Origin,
 						 RPL_HOSTHIDDEN_MSG,
 						 Client_ID(Target),
@@ -1035,7 +1035,7 @@ Add_To_List(char what, CLIENT *Prefix, CLIENT *Client, CHANNEL *Channel,
 }
 
 /**
- * Delete entries from channel invite, ban and exeption lists.
+ * Delete entries from channel invite, ban and exception lists.
  *
  * @param what Can be 'I' for invite, 'b' for ban, and 'e' for exception list.
  * @param Prefix The originator of the command.
diff --git a/src/ngircd/irc-server.c b/src/ngircd/irc-server.c
index a8b82c96..7770be85 100644
--- a/src/ngircd/irc-server.c
+++ b/src/ngircd/irc-server.c
@@ -82,7 +82,7 @@ IRC_SERVER( CLIENT *Client, REQUEST *Req )
 			if (strcasecmp(Req->argv[0], Conf_Server[i].name) == 0)
 				break;
 
-		/* Makre sure the remote server is configured here */
+		/* Make sure the remote server is configured here */
 		if (i >= MAX_SERVERS) {
 			Log(LOG_ERR,
 			    "Connection %d: Server \"%s\" not configured here!",
@@ -152,17 +152,17 @@ IRC_SERVER( CLIENT *Client, REQUEST *Req )
 		Client_SetType(Client, CLIENT_UNKNOWNSERVER);
 
 #ifdef ZLIB
-		if (strchr(Client_Flags(Client), 'Z')
+		if (Client_HasFlag(Client, 'Z')
 		    && !Zip_InitConn(Client_Conn(Client))) {
 			Conn_Close(Client_Conn(Client),
-				   "Can't inizialize compression (zlib)!",
+				   "Can't initialize compression (zlib)!",
 				   NULL, false );
 			return DISCONNECTED;
 		}
 #endif
 
 #ifdef IRCPLUS
-		if (strchr(Client_Flags(Client), 'H')) {
+		if (Client_HasFlag(Client, 'H')) {
 			LogDebug("Peer supports IRC+ extended server handshake ...");
 			if (!IRC_Send_ISUPPORT(Client))
 				return DISCONNECTED;
diff --git a/src/ngircd/irc-write.c b/src/ngircd/irc-write.c
index 16aac9a0..ea9b9a02 100644
--- a/src/ngircd/irc-write.c
+++ b/src/ngircd/irc-write.c
@@ -311,7 +311,7 @@ IRC_WriteStrServersPrefixFlag_CB(CLIENT *ExceptOf, CLIENT *Prefix, char Flag,
 		if (Client_Type(c) == CLIENT_SERVER && Client_Conn(c) > NONE &&
 		    c != Client_ThisServer() && c != ExceptOf) {
 			/* Found a target server, do the flags match? */
-			if (Flag == '\0' || strchr(Client_Flags(c), Flag))
+			if (Flag == '\0' || Client_HasFlag(c, Flag))
 				callback(c, Prefix, cb_data);
 		}
 		c = Client_Next(c);
@@ -321,7 +321,7 @@ IRC_WriteStrServersPrefixFlag_CB(CLIENT *ExceptOf, CLIENT *Prefix, char Flag,
 
 /**
  * send message to all clients that are in the same channels as the client sending this message.
- * only send message once per reote server.
+ * only send message once per remote server.
  */
 #ifdef PROTOTYPES
 GLOBAL bool
diff --git a/src/ngircd/irc.c b/src/ngircd/irc.c
index dbce773b..ddef7d02 100644
--- a/src/ngircd/irc.c
+++ b/src/ngircd/irc.c
@@ -111,7 +111,7 @@ IRC_ERROR(CLIENT *Client, REQUEST *Req)
 /**
  * Handler for the IRC "KILL" command.
  *
- * This function implements the IRC command "KILL" wich is used to selectively
+ * This function implements the IRC command "KILL" which is used to selectively
  * disconnect clients. It can be used by IRC operators and servers, for example
  * to "solve" nick collisions after netsplits. See RFC 2812 section 3.7.1.
  *
diff --git a/src/ngircd/log.c b/src/ngircd/log.c
index e5bed791..028f4353 100644
--- a/src/ngircd/log.c
+++ b/src/ngircd/log.c
@@ -160,7 +160,7 @@ va_dcl
  * suitable for the mode ngIRCd is running in (daemon vs. non-daemon).
  * If LOG_snotice is set, the log messages goes to all user with the mode +s
  * set and the local &SERVER channel, too.
- * Please note: you sould use LogDebug(...) for debug messages!
+ * Please note: you should use LogDebug(...) for debug messages!
  * @param Level syslog level (LOG_xxx)
  * @param Format Format string like printf().
  * @param ... Further arguments.
diff --git a/src/ngircd/login.c b/src/ngircd/login.c
index d8c8c40a..bbde6359 100644
--- a/src/ngircd/login.c
+++ b/src/ngircd/login.c
@@ -90,7 +90,7 @@ Login_User(CLIENT * Client)
 #ifdef PAM
 	if (!Conf_PAM) {
 		/* Don't do any PAM authentication at all, instead emulate
-		 * the beahiour of the daemon compiled without PAM support:
+		 * the behavior of the daemon compiled without PAM support:
 		 * because there can't be any "server password", all
 		 * passwords supplied are classified as "wrong". */
 		if(Conn_Password(conn)[0] == '\0')
@@ -194,7 +194,7 @@ Login_User_PostAuth(CLIENT *Client)
 #ifdef PAM
 
 /**
- * Read result of the authenticatior sub-process from pipe
+ * Read result of the authenticator sub-process from pipe
  *
  * @param r_fd		File descriptor of the pipe.
  * @param events	(ignored IO specification)
diff --git a/src/ngircd/match.c b/src/ngircd/match.c
index 75bf4358..dad3e7bc 100644
--- a/src/ngircd/match.c
+++ b/src/ngircd/match.c
@@ -55,7 +55,6 @@ static int Matche_After_Star PARAMS(( const char *p, const char *t ));
 GLOBAL bool
 Match( const char *Pattern, const char *String )
 {
-	/* Pattern mit String vergleichen */
 	if( Matche( Pattern, String ) == MATCH_VALID ) return true;
 	else return false;
 } /* Match */
diff --git a/src/ngircd/ngircd.c b/src/ngircd/ngircd.c
index e28c370b..e075e0a7 100644
--- a/src/ngircd/ngircd.c
+++ b/src/ngircd/ngircd.c
@@ -551,7 +551,7 @@ Pidfile_Create(pid_t pid)
 
 
 /**
- * Redirect stdin, stdout and stderr to apropriate file handles.
+ * Redirect stdin, stdout and stderr to appropriate file handles.
  *
  * @param fd	The file handle stdin, stdout and stderr should be redirected to.
  */
diff --git a/src/ngircd/numeric.c b/src/ngircd/numeric.c
index f7f3ac91..f2c61e8a 100644
--- a/src/ngircd/numeric.c
+++ b/src/ngircd/numeric.c
@@ -52,7 +52,7 @@ Announce_Channel(CLIENT *Client, CHANNEL *Chan)
 
 	/* Check features of remote server */
 	njoin = Conn_Options(Client_Conn(Client)) & CONN_RFC1459 ? false : true;
-	xop = strchr(Client_Flags(Client), 'X') ? true : false;
+	xop = Client_HasFlag(Client, 'X') ? true : false;
 
 	/* Get all the members of this channel */
 	cl2chan = Channel_FirstMember(Chan);
@@ -150,80 +150,6 @@ Announce_Server(CLIENT * Client, CLIENT * Server)
 } /* Announce_Server */
 
 
-/**
- * Announce existing user to a new server
- * @param Client New server
- * @param User Existing user in the network
- */
-static bool
-Announce_User(CLIENT * Client, CLIENT * User)
-{
-	CONN_ID conn;
-	char *modes;
-
-	conn = Client_Conn(Client);
-	if (Conn_Options(conn) & CONN_RFC1459) {
-		/* RFC 1459 mode: separate NICK and USER commands */
-		if (! Conn_WriteStr(conn, "NICK %s :%d",
-				    Client_ID(User), Client_Hops(User) + 1))
-			return DISCONNECTED;
-		if (! Conn_WriteStr(conn, ":%s USER %s %s %s :%s",
-				     Client_ID(User), Client_User(User),
-				     Client_Hostname(User),
-				     Client_ID(Client_Introducer(User)),
-				     Client_Info(User)))
-			return DISCONNECTED;
-		modes = Client_Modes(User);
-		if (modes[0]) {
-			return Conn_WriteStr(conn, ":%s MODE %s +%s",
-				     Client_ID(User), Client_ID(User),
-				     modes);
-		}
-	} else {
-		/* RFC 2813 mode: one combined NICK or SERVICE command */
-		if (Client_Type(User) == CLIENT_SERVICE
-		    && strchr(Client_Flags(Client), 'S')) {
-			if (!IRC_WriteStrClient(Client,
-					"SERVICE %s %d * +%s %d :%s",
-					Client_Mask(User),
-					Client_MyToken(Client_Introducer(User)),
-					Client_Modes(User), Client_Hops(User) + 1,
-					Client_Info(User)))
-				return DISCONNECTED;
-		} else {
-			if (!IRC_WriteStrClient(Client,
-					"NICK %s %d %s %s %d +%s :%s",
-					Client_ID(User), Client_Hops(User) + 1,
-					Client_User(User), Client_Hostname(User),
-					Client_MyToken(Client_Introducer(User)),
-					Client_Modes(User), Client_Info(User)))
-				return DISCONNECTED;
-		}
-	}
-
-	if (strchr(Client_Flags(Client), 'M')) {
-		/* Synchronize metadata */
-		if (Client_HostnameCloaked(User)) {
-			if (!IRC_WriteStrClient(Client,
-						"METADATA %s cloakhost :%s",
-						Client_ID(User),
-						Client_HostnameCloaked(User)))
-				return DISCONNECTED;
-		}
-	}
-
-	if (Conn_GetFingerprint(conn)) {
-		if (!IRC_WriteStrClient(Client,
-					"METADATA %s certfp :%s",
-					Client_ID(User),
-					Conn_GetFingerprint(conn)))
-			return DISCONNECTED;
-	}
-
-	return CONNECTED;
-} /* Announce_User */
-
-
 #ifdef IRCPLUS
 
 /**
@@ -380,7 +306,7 @@ IRC_Num_ENDOFMOTD(CLIENT * Client, UNUSED REQUEST * Req)
 	while (c) {
 		if (Client_Type(c) == CLIENT_USER ||
 		    Client_Type(c) == CLIENT_SERVICE) {
-			if (!Announce_User(Client, c))
+			if (!Client_Announce(Client, Client_ThisServer(), c))
 				return DISCONNECTED;
 		}
 		c = Client_Next(c);
@@ -395,7 +321,7 @@ IRC_Num_ENDOFMOTD(CLIENT * Client, UNUSED REQUEST * Req)
 		}
 #ifdef IRCPLUS
 		/* Send CHANINFO if the peer supports it */
-		if (strchr(Client_Flags(Client), 'C')) {
+		if (Client_HasFlag(Client, 'C')) {
 			if (!Send_CHANINFO(Client, chan))
 				return DISCONNECTED;
 		}
@@ -409,7 +335,7 @@ IRC_Num_ENDOFMOTD(CLIENT * Client, UNUSED REQUEST * Req)
 	}
 
 #ifdef IRCPLUS
-	if (strchr(Client_Flags(Client), 'L')) {
+	if (Client_HasFlag(Client, 'L')) {
 		LogDebug("Synchronizing INVITE- and BAN-lists ...");
 		if (!Synchronize_Lists(Client))
 			return DISCONNECTED;
diff --git a/src/ngircd/pam.c b/src/ngircd/pam.c
index 88872c47..ed56497d 100644
--- a/src/ngircd/pam.c
+++ b/src/ngircd/pam.c
@@ -15,7 +15,7 @@
 
 /**
  * @file
- * PAM User Authentification
+ * PAM User Authentication
  */
 
 #include "imp.h"
diff --git a/src/ngircd/pam.h b/src/ngircd/pam.h
index ba31d50a..8c8e8f64 100644
--- a/src/ngircd/pam.h
+++ b/src/ngircd/pam.h
@@ -16,7 +16,7 @@
 
 /**
  * @file
- * PAM User Authentification (header)
+ * PAM User Authentication (header)
  */
 
 GLOBAL bool PAM_Authenticate PARAMS((CLIENT *Client));
diff --git a/src/ngircd/parse.c b/src/ngircd/parse.c
index 46164ce1..c92da4d2 100644
--- a/src/ngircd/parse.c
+++ b/src/ngircd/parse.c
@@ -127,7 +127,7 @@ static COMMAND My_Commands[] =
 	{ "GET",  IRC_QUIT_HTTP, CLIENT_UNKNOWN, 0, 0, 0 },
 	{ "POST", IRC_QUIT_HTTP, CLIENT_UNKNOWN, 0, 0, 0 },
 #endif
-	{ NULL, NULL, 0x0, 0, 0, 0 } /* Ende-Marke */
+	{ NULL, NULL, 0x0, 0, 0, 0 } /* End-Mark */
 };
 
 static void Init_Request PARAMS(( REQUEST *Req ));
@@ -157,7 +157,7 @@ Parse_GetCommandStruct( void )
  * Parse a command ("request") received from a client.
  * 
  * This function is called after the connection layer received a valid CR+LF
- * terminated line of text: we asume that this is a valid IRC command and
+ * terminated line of text: we assume that this is a valid IRC command and
  * try to do something useful with it :-)
  *
  * All errors are reported to the client from which the command has been
@@ -169,7 +169,7 @@ Parse_GetCommandStruct( void )
  * @param Idx Index of the connection from which the command has been received.
  * @param Request NULL terminated line of text (the "command").
  * @return true on success (valid command or "regular" error), false if a
- * 	fatal error occured and the connection has been shut down.
+ * 	fatal error occurred and the connection has been shut down.
  */
 GLOBAL bool
 Parse_Request( CONN_ID Idx, char *Request )
@@ -271,8 +271,6 @@ Parse_Request( CONN_ID Idx, char *Request )
 static void
 Init_Request( REQUEST *Req )
 {
-	/* Neue Request-Struktur initialisieren */
-
 	int i;
 
 	assert( Req != NULL );
@@ -367,7 +365,7 @@ Validate_Command( UNUSED CONN_ID Idx, UNUSED REQUEST *Req, bool *Closed )
 	*Closed = false;
 
 	return true;
-} /* Validate_Comman */
+} /* Validate_Command */
 
 
 static bool
diff --git a/src/ngircd/sighandlers.c b/src/ngircd/sighandlers.c
index 6d5ea8f8..effef44d 100644
--- a/src/ngircd/sighandlers.c
+++ b/src/ngircd/sighandlers.c
@@ -257,7 +257,7 @@ Signal_Callback(int fd, short UNUSED what)
 /**
  * Initialize the signal handlers, catch
  * those signals we are interested in and sets SIGPIPE to be ignored.
- * @return true if initialization was sucessful.
+ * @return true if initialization was successful.
  */
 bool
 Signals_Init(void)
@@ -304,7 +304,7 @@ Signals_Init(void)
 } /* Signals_Init */
 
 /**
- * Restores signals to their default behaviour.
+ * Restores signals to their default behavior.
  *
  * This should be called after a fork() in the new
  * child prodcess, especially when we are about to call