about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/ngircd/conf.c16
-rw-r--r--src/ngircd/conf.h3
-rw-r--r--src/ngircd/irc-info.c4
-rw-r--r--src/ngircd/irc-oper.c6
-rw-r--r--src/ngircd/messages.h1
-rw-r--r--src/portab/portabtest.c172
6 files changed, 176 insertions, 26 deletions
diff --git a/src/ngircd/conf.c b/src/ngircd/conf.c
index 16275877..bdbb506f 100644
--- a/src/ngircd/conf.c
+++ b/src/ngircd/conf.c
@@ -369,6 +369,7 @@ Conf_Test( void )
 		printf("  MotdPhrase = %s\n", array_bytes(&Conf_Motd)
 		       ? (const char*) array_start(&Conf_Motd) : "");
 	}
+	printf("  Network = %s\n", Conf_Network);
 #ifndef PAM
 	printf("  Password = %s\n", Conf_ServerPwd);
 #endif
@@ -749,6 +750,7 @@ Set_Defaults(bool InitServers)
 	strcpy(Conf_ServerAdminMail, "");
 	snprintf(Conf_ServerInfo, sizeof Conf_ServerInfo, "%s %s",
 		 PACKAGE_NAME, PACKAGE_VERSION);
+	strcpy(Conf_Network, "");
 	free(Conf_ListenAddress);
 	Conf_ListenAddress = NULL;
 	array_free(&Conf_ListenPorts);
@@ -1409,6 +1411,7 @@ Handle_GLOBAL(const char *File, int Line, char *Var, char *Arg )
 	struct group *grp;
 	size_t len;
 	const char *section;
+	char *ptr;
 
 	assert(File != NULL);
 	assert(Line > 0);
@@ -1491,6 +1494,19 @@ Handle_GLOBAL(const char *File, int Line, char *Var, char *Arg )
 		Using_MotdFile = false;
 		return;
 	}
+	if (strcasecmp(Var, "Network") == 0) {
+		len = strlcpy(Conf_Network, Arg, sizeof(Conf_Network));
+		if (len >= sizeof(Conf_Network))
+			Config_Error_TooLong(File, Line, Var);
+		ptr = strchr(Conf_Network, ' ');
+		if (ptr) {
+			Config_Error(LOG_WARNING,
+				     "%s, line %d: \"Network\" can't contain spaces!",
+				     File, Line);
+			*ptr = '\0';
+		}
+		return;
+	}
 	if(strcasecmp(Var, "Password") == 0) {
 		len = strlcpy(Conf_ServerPwd, Arg, sizeof(Conf_ServerPwd));
 		if (len >= sizeof(Conf_ServerPwd))
diff --git a/src/ngircd/conf.h b/src/ngircd/conf.h
index 02d23315..aa80b8dd 100644
--- a/src/ngircd/conf.h
+++ b/src/ngircd/conf.h
@@ -109,6 +109,9 @@ GLOBAL char Conf_ServerAdmin1[CLIENT_INFO_LEN];
 GLOBAL char Conf_ServerAdmin2[CLIENT_INFO_LEN];
 GLOBAL char Conf_ServerAdminMail[CLIENT_INFO_LEN];
 
+/** Network name (optional, no spaces allowed) */
+GLOBAL char Conf_Network[CLIENT_INFO_LEN];
+
 /** Message of the day (MOTD) of this server */
 GLOBAL array Conf_Motd;
 
diff --git a/src/ngircd/irc-info.c b/src/ngircd/irc-info.c
index 56cae2ac..aa98a5b5 100644
--- a/src/ngircd/irc-info.c
+++ b/src/ngircd/irc-info.c
@@ -1539,6 +1539,10 @@ IRC_Send_NAMES(CLIENT * Client, CHANNEL * Chan)
 GLOBAL bool
 IRC_Send_ISUPPORT(CLIENT * Client)
 {
+	if (Conf_Network[0] && !IRC_WriteStrClient(Client, RPL_ISUPPORTNET_MSG,
+						   Client_ID(Client),
+						   Conf_Network))
+		return DISCONNECTED;
 	if (!IRC_WriteStrClient(Client, RPL_ISUPPORT1_MSG, Client_ID(Client),
 				CHANTYPES, CHANTYPES, Conf_MaxJoins))
 		return DISCONNECTED;
diff --git a/src/ngircd/irc-oper.c b/src/ngircd/irc-oper.c
index ab4023ac..49768bc7 100644
--- a/src/ngircd/irc-oper.c
+++ b/src/ngircd/irc-oper.c
@@ -387,6 +387,7 @@ IRC_xLINE(CLIENT *Client, REQUEST *Req)
 	CLIENT *from, *c, *c_next;
 	char reason[COMMAND_LEN], class_c;
 	struct list_head *list;
+	time_t timeout;
 	int class;
 
 	assert(Client != NULL);
@@ -431,8 +432,11 @@ IRC_xLINE(CLIENT *Client, REQUEST *Req)
 		}
 	} else {
 		/* Add new mask to list */
+		timeout = atol(Req->argv[1]);
+		if (timeout > 0)
+			timeout += time(NULL);
 		if (Class_AddMask(class, Req->argv[0],
-				  time(NULL) + atol(Req->argv[1]),
+				  timeout,
 				  Req->argv[2])) {
 			Log(LOG_NOTICE|LOG_snotice,
 			    "\"%s\" added \"%s\" to %c-Line list: \"%s\" (%ld seconds).",
diff --git a/src/ngircd/messages.h b/src/ngircd/messages.h
index 53b96581..f3a0ba44 100644
--- a/src/ngircd/messages.h
+++ b/src/ngircd/messages.h
@@ -21,6 +21,7 @@
 #define RPL_YOURHOST_MSG		"002 %s :Your host is %s, running version ngircd-%s (%s/%s/%s)"
 #define RPL_CREATED_MSG			"003 %s :This server has been started %s"
 #define RPL_MYINFO_MSG			"004 %s %s ngircd-%s %s %s"
+#define RPL_ISUPPORTNET_MSG		"005 %s NETWORK=%s :is my network name"
 #define RPL_ISUPPORT1_MSG		"005 %s RFC2812 IRCD=ngIRCd CHARSET=UTF-8 CASEMAPPING=ascii PREFIX=(qaohv)~&@%%+ CHANTYPES=%s CHANMODES=beI,k,l,imMnOPQRstVz CHANLIMIT=%s:%d :are supported on this server"
 #define RPL_ISUPPORT2_MSG		"005 %s CHANNELLEN=%d NICKLEN=%d TOPICLEN=%d AWAYLEN=%d KICKLEN=%d MODES=%d MAXLIST=beI:%d EXCEPTS=e INVEX=I PENALTY :are supported on this server"
 
diff --git a/src/portab/portabtest.c b/src/portab/portabtest.c
index 09afbfd1..9e6bd228 100644
--- a/src/portab/portabtest.c
+++ b/src/portab/portabtest.c
@@ -1,6 +1,6 @@
 /*
  * ngIRCd -- The Next Generation IRC Daemon
- * Copyright (c)2001,2002 by Alexander Barton (alex@barton.de)
+ * Copyright (c)2001-2013 Alexander Barton (alex@barton.de) and Contributors.
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -24,40 +24,162 @@
 
 #include "exp.h"
 
+static void
+Panic(char *Reason)
+{
+	/* Oops, something failed!? */
+	fprintf(stderr, "Oops, test for %s failed!?\n", Reason);
+	exit(1);
+} /* Panic */
 
-static void Panic PARAMS (( char *Reason, int Code ));
+static void
+Check_snprintf(void)
+{
+	char str[5];
 
+	snprintf(str, sizeof(str), "%s", "1234567890");
+	if (str[4] != '\0')
+		Panic("snprintf NULL byte");
+	if (strlen(str) != 4)
+		Panic("snprintf string length");
+}
 
-GLOBAL int
-main( void )
+static void
+Check_strdup(void)
 {
-	/* validate datatypes */
-	if( false != 0 ) Panic( "false", 1 );
-	if( true != 1 ) Panic( "true", 1 );
-	if( sizeof( UINT8 ) != 1 ) Panic( "UINT8", 1 );
-	if( sizeof( UINT16 ) != 2 ) Panic( "UINT16", 1 );
-	if( sizeof( UINT32 ) != 4 ) Panic( "UINT32", 1 );
+	char *ptr;
+
+	ptr = strdup("1234567890");
+	if (!ptr)
+		Panic("strdup");
+	if (ptr[10] != '\0')
+		Panic("strdup NULL byte");
+	if (strlen(ptr) != 10)
+		Panic("strdup string length");
+	free(ptr);
+}
+
+static void
+Check_strndup(void)
+{
+	char *ptr;
+
+	ptr = strndup("1234567890", 5);
+	if (!ptr)
+		Panic("strndup");
+	if (ptr[5] != '\0')
+		Panic("strndup NULL byte");
+	if (strlen(ptr) != 5)
+		Panic("strndup string length");
+	free(ptr);
+}
+
+static void
+Check_strlcpy(void)
+{
+	char str[5];
+
+	if (strlcpy(str, "1234567890", sizeof(str)) != 10)
+		Panic("strlcpy return code");
+	if (str[4] != '\0')
+		Panic("strlcpy NULL byte");
+	if (strlen(str) != 4)
+		Panic("strlcpy string length");
+}
+
+static void
+Check_strlcat(void)
+{
+	char str[5];
+
+	if (strlcpy(str, "12", sizeof(str)) != 2)
+		Panic("strlcpy for strlcat");
+	if (strlcat(str, "1234567890", sizeof(str)) != 12)
+		Panic("strlcat return code");
+	if (str[4] != '\0')
+		Panic("strlcat NULL byte");
+	if (strlen(str) != 4)
+		Panic("strlcat string length");
+}
+
+static void
+Check_strtok_r(void)
+{
+	char *ptr, *last;
+
+	ptr = strdup("12,abc");
+
+	ptr = strtok_r(ptr, ",", &last);
+	if (!ptr)
+		Panic("strtok_r result #1");
+	if (strcmp(ptr, "12") != 0)
+		Panic("strtok_r token #1");
+
+	ptr = strtok_r(NULL, ",", &last);
+	if (!ptr)
+		Panic("strtok_r result #2");
+	if (strcmp(ptr, "abc") != 0)
+		Panic("strtok_r token #2");
+
+	ptr = strtok_r(NULL, ",", &last);
+	if (ptr)
+		Panic("strtok_r result #3");
+}
 
 #ifdef PROTOTYPES
-	/* check functions */
-	if( ! snprintf ) Panic( "snprintf", 2 );
-	if( ! vsnprintf ) Panic( "vsnprintf", 2 );
-	if( ! strlcpy ) Panic( "strlcpy", 2 );
-	if( ! strlcat ) Panic( "strlcat", 2 );
+static void
+Check_vsnprintf(const int Len, const char *Format, ...)
+#else
+static void
+Check_vsnprintf(Len, Format, va_alist)
+const int Len;
+const char *Format;
+va_dcl
 #endif
-	
-	/* ok, no error */
-	return 0;
-} /* portab_check_types */
+{
+	char str[5];
+	va_list ap;
 
+#ifdef PROTOTYPES
+	va_start(ap, Format);
+#else
+	va_start(ap);
+#endif
+	if (vsnprintf(str, sizeof(str), Format, ap) != Len)
+		Panic("vsnprintf return code");
+	va_end(ap);
 
-static void
-Panic( char *Reason, int Code )
+	if (str[4] != '\0')
+		Panic("vsnprintf NULL byte");
+	if (strlen(str) != 4)
+		Panic("vsnprintf string length");
+}
+
+GLOBAL int
+main(void)
 {
-	/* Oops, something failed!? */
-	fprintf( stderr, "Oops, test for %s failed!?", Reason );
-	exit( Code );
-} /* Panic */
+	/* validate datatypes */
+	if (false != 0)
+		Panic("false");
+	if (true != 1)
+		Panic("true");
+	if (sizeof(UINT8) != 1)
+		Panic("UINT8");
+	if (sizeof(UINT16) != 2)
+		Panic("UINT16");
+	if (sizeof(UINT32) != 4)
+		Panic("UINT32");
 
+	/* check functions */
+	Check_snprintf();
+	Check_strdup();
+	Check_strndup();
+	Check_strlcpy();
+	Check_strlcat();
+	Check_strtok_r();
+	Check_vsnprintf(2+10, "%s%s", "ab", "1234567890");
+	
+	return 0;
+}
 
 /* -eof- */