Commit Diff


commit - 731127fc2f8eb6e363d5aed54f26050229b14c70
commit + 81c6ff6c7174ced998e24357d834889ab446359d
blob - 09c129831bc7593b34bed9ae7164f6d2638878b9
blob + 951fd3a461a511df6420e340331e3b0e786452cb
--- BNC.pm
+++ BNC.pm
@@ -48,6 +48,19 @@ main::cbind("msgm", "-", "*", \&mcontrolpanel);
 main::cbind("msg", "-", "taillog", \&mtaillog);
 main::cbind("msg", "-", "lastseen", \&mlastseen);
 
+sub init {
+	unveil("/usr/local/bin/figlet", "rx") or die "Unable to unveil $!";
+	unveil("/usr/lib/libc.so.95.1", "r") or die "Unable to unveil $!";
+	unveil("/usr/libexec/ld.so", "r") or die "Unable to unveil $!";
+	unveil("/usr/bin/tail", "rx") or die "Unable to unveil $!";
+	unveil("$netpath", "r") or die "Unable to unveil $!";
+	
+	@networks = readnetworks($netpath);
+	
+	# networks must be sorted to avoid multiple connections
+	@networks = sort @networks;
+}
+
 # Return list of networks from filename
 # To add multiple servers for a single network, simply create a new entry with
 # the same net name; znc ignores addnetwork commands when a network already exists
@@ -76,19 +89,6 @@ sub readnetworks {
 		}
 	}
 	return @networks;
-}
-
-sub init {
-	unveil("/usr/local/bin/figlet", "rx") or die "Unable to unveil $!";
-	unveil("/usr/lib/libc.so.95.1", "r") or die "Unable to unveil $!";
-	unveil("/usr/libexec/ld.so", "r") or die "Unable to unveil $!";
-	unveil("/usr/bin/tail", "rx") or die "Unable to unveil $!";
-	unveil("$netpath", "r") or die "Unable to unveil $!";
-	
-	@networks = readnetworks($netpath);
-	
-	# networks must be sorted to avoid multiple connections
-	@networks = sort @networks;
 }
 
 sub mbnc {
@@ -121,7 +121,7 @@ sub mbnc {
 		sleep 3;
 		main::putserv($bot, "PRIVMSG *controlpanel :get Nick cloneuser");
 	}
-	### TODO: Check duplicate emails ###
+	### Check duplicate hostmasks ###
 	my @rows = SQLite::selectrows("irc", "hostmask", $hostmask);
 	foreach my $row (@rows) {
 		my $password = SQLite::get("bnc", "ircid", $row->{id}, "password");
@@ -130,6 +130,7 @@ sub mbnc {
 			return;
 		}
 	}
+
 	if ($text =~ /^captcha\s+([[:alnum:]]+)/) {
 		my $text = $1;
 		# TODO avoid using host mask because cloaking can cause problems
@@ -160,6 +161,16 @@ sub mbnc {
 		return;
 	} elsif ($text =~ /^([[:alnum:]]+)\s+([[:ascii:]]+)/) {
 		my ($username, $email) = ($1, $2);
+		my @userrows = SQLite::selectrows("bnc", "username", $username);
+		my @emailrows = SQLite::selectrows("bnc", "email", $email);
+		foreach my $row (@rows @emailrows) {
+			if (defined($password)) {
+				main::putserv($bot, "PRIVMSG $nick :Sorry, only one account per person. Please contact staff if you need help.");
+				return;
+			}
+		}
+
+
 #		my @users = treeget($znctree, "User", "Node");
 		foreach my $user (@users) {
 			if ($user eq $username) {
@@ -167,6 +178,7 @@ sub mbnc {
 				return;
 			}
 		}
+
 		#my $captcha = join'', map +(0..9,'a'..'z','A'..'Z')[rand(10+26*2)], 1..4;
 		my $captcha = int(rand(999));
 		my $ircid = int(rand(9223372036854775807));
blob - /dev/null
blob + fda779d624330233a717d3355525c9b210ae8a8f (mode 644)
--- /dev/null
+++ install
@@ -0,0 +1,43 @@
+#!/bin/ksh
+
+USERNAME="botnow"
+HOMEDIR="/home/botnow"
+HTDOCS="/var/www/htdocs/botnow"
+DATABASE="/var/www/botnow/"
+ZONES="/var/nsd/zones/master/"
+ZNCUSER="znc"
+ZNCDIR="/home/znc/home/znc/"
+HTTPDCONF="/etc/httpd.conf"
+ACMECONF="/etc/acme-client.conf"
+
+pkg_add figlet-2.2.5 php-8.0.8 php-sqlite p5-DBI p5-DBD-SQLite sqlite3 p5-Class-DBI-SQLite
+cc -o blowfish.o blowfish.c
+cp blowfish.o ${HOMEDIR}/
+
+useradd -m -g =uid -c ${USERNAME} -d ${HOMEDIR} -s /bin/ksh ${USERNAME}
+chmod go-rx ${HOMEDIR}
+mkdir ${DATABASE}
+chmod o-rx ${DATABASE}
+touch ${DATABASE}/www
+chown -R www:${USERNAME} ${DATABASE}
+chmod -R ug+rwx ${DATABASE}
+mkdir ${HTDOCS}
+cp words ${HTDOCS}/
+cp register.php ${HTDOCS}/
+chown -R www:daemon ${HTDOCS}
+chmod o-rwx ${HTDOCS}
+usermod -G daemon ${USERNAME}
+usermod -G wheel ${USERNAME}
+chown -R _nsd:daemon ${ZONES}
+chmod ug+rwx ${ZONES}
+chmod ug+rw ${ZONES}/*
+chmod g+rw ${HTTPDCONF} ${ACMECONF}
+echo "permit nopass ${USERNAME} as _nsd cmd nsd-control" >> /etc/doas.conf
+cp captcha.png register.php ${HTDOCS}/
+cp LICENSE README botnow.pl botnow.conf.example BNC.pm DNS.pm Mail.pm SQLite.pm Shell.pm table.sql Hash.pm Help.pm install networks captcha.png register.php words ${HOMEDIR}/
+chown -R ${USERNAME}:${USERNAME} ${HOMEDIR}
+chmod u+x ${HOMEDIR}/botnow
+chown -R ${ZNCUSER}:daemon ${ZNCDIR}
+chmod -R ug+r ${ZNCDIR}
+find ${ZNCDIR} -type d -exec chmod ug+rx {} +
+echo "Installation complete. To run botnow, type $ ./botnow.pl"