From 16db298a85dd83cbaed722a368f6ce3a27a6395f Mon Sep 17 00:00:00 2001 From: Michael Poole Date: Wed, 11 May 2005 04:15:04 +0000 Subject: [PATCH] Avoid sending MODE +o to local channel creator, and more code coverage. git-svn-id: file:///home/klmitch/undernet-ircu/undernet-ircu-svn/ircu2/trunk@1403 c9e4aea6-c8fd-4c43-8297-357d70d61c8c --- ChangeLog | 16 +++++++++++++++- ircd/channel.c | 2 +- ircd/test/channel-1.cmd | 2 -- ircd/test/client-1.cmd | 12 ++++++++---- ircd/test/die.cmd | 5 +++++ ircd/test/gline-1.cmd | 26 ++++++++++++++++++++++++++ ircd/test/ircd-t1.conf | 3 +++ ircd/test/run-tests.sh | 12 ++++++++++++ ircd/test/test-driver.pl | 4 ++++ ircd/umkpasswd.c | 2 +- 10 files changed, 75 insertions(+), 9 deletions(-) create mode 100644 ircd/test/die.cmd create mode 100644 ircd/test/gline-1.cmd create mode 100755 ircd/test/run-tests.sh diff --git a/ChangeLog b/ChangeLog index 6913b1c..11c9d8b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,4 +1,18 @@ -n2005-08-09 Michael Poole +2005-08-10 Michael Poole + + * ircd/channel.c (joinbuf_join): Do not send a MODE +o when a + local user creates a channel. + + * ircd/umkpasswd.c (crypt_pass): Allocate the proper amount of + memory for the tagged output string. + + * ircd/test/test-driver.pl: Add -vhost=... option. + + * ircd/test/ircd-t1.conf: Add new Operator blocks. + + * ircd/test/*.cmd: Rearrange and add more coverage tests. + +2005-08-09 Michael Poole * ircd/ircd_parser.y: Move error tokens to top level of parse, and make ';' a synchronizing token for them. This avoids crashes in diff --git a/ircd/channel.c b/ircd/channel.c index 472d927..4f30a65 100644 --- a/ircd/channel.c +++ b/ircd/channel.c @@ -3416,7 +3416,7 @@ joinbuf_join(struct JoinBuf *jbuf, struct Channel *chan, unsigned int flags) sendcmdto_channel_butserv_butone(jbuf->jb_source, CMD_JOIN, chan, NULL, 0, "%H", chan); /* send an op, too, if needed */ - if (flags & CHFL_CHANOP) + if (flags & CHFL_CHANOP && (oplevel < MAXOPLEVEL || !MyUser(jbuf->jb_source))) sendcmdto_channel_butserv_butone((chan->mode.apass[0] ? &me : jbuf->jb_source), CMD_MODE, chan, NULL, 0, "%H +o %C", chan, jbuf->jb_source); diff --git a/ircd/test/channel-1.cmd b/ircd/test/channel-1.cmd index 5d8c586..dfdcb8c 100644 --- a/ircd/test/channel-1.cmd +++ b/ircd/test/channel-1.cmd @@ -45,6 +45,4 @@ connect cl2 Bubb bubb %srv% :Test client 2 :cl2 wait cl1 :cl2 mode #test2 -D :cl2 mode #test +v Alex -:cl1 oper oper1 oper1 :cl1 wait cl2 -:cl1 raw die :testing over diff --git a/ircd/test/client-1.cmd b/ircd/test/client-1.cmd index ffb4853..9a588c1 100644 --- a/ircd/test/client-1.cmd +++ b/ircd/test/client-1.cmd @@ -1,11 +1,15 @@ define srv localhost:7701 connect cl1 Alex alex %srv% :Test client 1 -connect cl2 Bubb bubb %srv% :Test client 2 :cl1 oper oper1 oper1 -:cl2 wait cl1 +connect cl2 Bubb bubb %srv% :Test client 2 :cl2 oper oper3 oper4 +:cl2 oper oldoper wrongpass +:cl2 oper md5oper wrongpass +:cl2 oper cryptoper wrongpass :cl2 oper oper2 oper2 -:cl1 raw :privs Bubb :cl2 raw :privs Alex Alex -sync cl1,cl2 +:cl1 wait cl2 +:cl1 raw :privs Bubb +:cl1 nick A +:cl1 nick Alexey diff --git a/ircd/test/die.cmd b/ircd/test/die.cmd new file mode 100644 index 0000000..1ef7d95 --- /dev/null +++ b/ircd/test/die.cmd @@ -0,0 +1,5 @@ +connect cl1 Alex alex localhost:7701 :Test client 1 +:cl1 oper oper1 oper1 +:cl1 raw :restart brb +:cl1 oper oper1 oper1 +:cl1 raw :die :testing over diff --git a/ircd/test/gline-1.cmd b/ircd/test/gline-1.cmd new file mode 100644 index 0000000..aa08dcc --- /dev/null +++ b/ircd/test/gline-1.cmd @@ -0,0 +1,26 @@ +define srv localhost:7701 + +connect cl1 Alex alex %srv% :Test client 1 +:cl1 oper oper1 oper1 +:cl1 raw :gline !+$Rbubb 30 :Bubb is not welcome here +:cl1 sleep 35 +:cl1 raw :gline !+127.2.* 3600 :Localclone? +:cl1 sleep 5 +:cl1 raw :gline !+127.2.* 3600 :Localclone? +connect cl2 Bubb bubb %srv% :Test client 2 +:cl1 raw :gline +:cl1 raw :gline $Rbubb +:cl1 raw :gline -$Rbubb +:cl1 wait cl2 +:cl1 raw :gline !+$Rbubb * 3600 :Bubb is not welcome here +:cl1 sleep 5 +:cl1 raw :gline -$Rbubb +:cl1 raw :gline +#warez 30 :Warez r bad mmkay +:cl2 wait cl1 +:cl2 join #warez +:cl1 sleep 35 +:cl1 raw :stats glines +:cl1 raw :gline !+*@127.0.0.2 3600 :Localclone? +:cl1 raw :gline !+127.1.* 3600 :Localclone? +:cl1 raw :stats memory +:cl2 raw :gline diff --git a/ircd/test/ircd-t1.conf b/ircd/test/ircd-t1.conf index 1662d12..92243ff 100644 --- a/ircd/test/ircd-t1.conf +++ b/ircd/test/ircd-t1.conf @@ -70,6 +70,9 @@ Jupe { Operator { name = "oper1"; host = "*@*"; password = "$PLAIN$oper1"; class = "Opers"; }; Operator { name = "oper2"; host = "*@*"; password = "$PLAIN$oper2"; class = "Opers"; local = yes; }; +Operator { name = "oldoper"; host = "*@*"; password = "Xlfc26b4eYGWs"; class = "Opers"; }; +Operator { name = "md5oper"; host = "*@*"; password = "$SMD5$2O$4O.rSAmhE4Fg05MmG.047/"; class = "Opers"; }; +Operator { name = "cryptoper"; host = "*@*"; password = "$CRYPT$41ndrxPQu3B66"; class = "Opers"; }; Kill { username = "sub7"; realname = "s*7*"; reason = "You are infected with a Trojan"; }; Kill { realname = "Chloe"; reason = "drones"; }; diff --git a/ircd/test/run-tests.sh b/ircd/test/run-tests.sh new file mode 100755 index 0000000..a2ef7c0 --- /dev/null +++ b/ircd/test/run-tests.sh @@ -0,0 +1,12 @@ +#! /bin/sh +set -e +srcdir=$1 +for script in channel-1 client-1 stats-1 gline-1 ; do + echo "Running test $script." + ${srcdir}/test-driver.pl ${srcdir}/${script}.cmd +done +echo "Terminating server." +${srcdir}/test-driver.pl ${srcdir}/die.cmd +../ircd -? +../ircd -v +../ircd -x 6 -k -d ${srcdir} -f ircd-t1.conf -c user@127.0.0.1 diff --git a/ircd/test/test-driver.pl b/ircd/test/test-driver.pl index 546c63c..7ee09cd 100755 --- a/ircd/test/test-driver.pl +++ b/ircd/test/test-driver.pl @@ -132,6 +132,8 @@ sub drv_start { $heap->{irc_debug} = 1; } elsif ($arg =~ /^-V$/) { $heap->{verbose} = 1; + } elsif ($arg =~ /^-vhost=(.*)$/) { + $heap->{vhost} = $1; } else { die "Extra command-line argument $arg\n" if $heap->{script}; $heap->{script} = new FileHandle($arg, 'r') @@ -215,6 +217,8 @@ sub drv_heartbeat { Debug => $heap->{irc_debug}, } }; + $client->params->{LocalAddr} = $heap->{vhost} + if $heap->{vhost}; $heap->{clients}->{$client->{name}} = $client; $heap->{sessions}->{$client->{irc}} = $client; $kernel->call($client->{irc}, 'register', 'all'); diff --git a/ircd/umkpasswd.c b/ircd/umkpasswd.c index 2eee9c0..27668bf 100644 --- a/ircd/umkpasswd.c +++ b/ircd/umkpasswd.c @@ -310,7 +310,7 @@ char* salt, *untagged, *tagged; salt = make_salt(default_salts); untagged = (char *)CryptFunc(crypt_mech->mech)(pw, salt); - tagged = (char *)MyMalloc(strlen(salt)+CryptTokSize(crypt_mech->mech)+1); + tagged = (char *)MyMalloc(strlen(untagged)+CryptTokSize(crypt_mech->mech)+1); memset(tagged, 0, strlen(untagged)+CryptTokSize(crypt_mech->mech)+1); strncpy(tagged, CryptTok(crypt_mech->mech), CryptTokSize(crypt_mech->mech)); strncpy(tagged+CryptTokSize(crypt_mech->mech), untagged, strlen(untagged)); -- 2.20.1