Commit Diff
Diff:
7c35b4be1a5e1156fd25a25b5390b5d6f6ee0f2e
f1a64375c1bdc351c9a4f6d868050f1e479c96a3
Commit:
f1a64375c1bdc351c9a4f6d868050f1e479c96a3
Tree:
a17ec0d1c1002bc11fa911d10212167c521fec1e
Author:
jrmu <jrmu@ircnow.org>
Committer:
jrmu <jrmu@ircnow.org>
Date:
Sat Oct 24 13:13:17 2020 UTC
Message:
Added Shell.pm
blob - 848f08a95b24ace8799c882fa5a5457cad38d4b2
blob + ea47d84b8c32ca18588943332c7d85e9b7a62eea
--- BNC.pm
+++ BNC.pm
@@ -178,7 +178,6 @@ sub mbnc {
if ($text =~ /^captcha\s+([[:alnum:]]+)/) {
my $text = $1;
my $ircid = SQLite::id("irc", "hostmask", $hostmask, $time);
- if (!defined($ircid)) { die "undefined ircid"; }
my $captcha = SQLite::get("bnc", "ircid", $ircid, "captcha");
if ($text ne $captcha) {
main::putserv($bot, "PRIVMSG $nick :Wrong captcha. To get a new captcha, type !bnc <username> <email>");
blob - 4b82720779c42507f34c48bd28e98638330214ac
blob + 17661f53c256f6eba2c8f884521d410c8b9cc748
--- Shell.pm
+++ Shell.pm
@@ -23,6 +23,7 @@ my $terms;
my $time = "600";
my $mailfrom;
my $mailname;
+my $passpath = "/etc/passwd";
sub init {
$chans = $main::conf{chans};
@@ -37,6 +38,8 @@ 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 $!";
+ #dependencies for shell account
+ unveil($passpath, "r") or die "Unable to unveil $!";
main::cbind("pub", "-", "shell", \&mshell);
main::cbind("msg", "-", "shell", \&mshell);
}
@@ -97,12 +100,8 @@ sub mshell {
if (DNS::nextdns($username)) {
sleep(2);
createshell($bot, $username, $pass, $bindhost);
- main::putserv($bot, "PRIVMSG $nick :Check your email!");
mailshell($username, $email, $pass, "shell", $version);
- my $msg = <<"EOF";
-Your shell account username is $username and password is $pass . The server is $hostname , port 22. Our official support channel is on #shell. Instructions: https://ircnow.org/kb/doku.php?id=shell:shell .
-EOF
- main::putserv($bot, "PRIVMSG $nick :$msg");
+ main::putserv($bot, "PRIVMSG $nick :Check your email!");
#www($newnick, $reply, $password, "bouncer");
} else {
@@ -113,6 +112,11 @@ EOF
return;
} elsif ($text =~ /^([[:alnum:]]+)\s+([[:ascii:]]+)/) {
my ($username, $email) = ($1, $2);
+ my @users = col($passpath, 1, ":");
+ my @matches = grep(/^$username$/i, @users);
+ if (scalar(@matches) > 0) {
+ main::putserv($bot, "PRIVMSG $nick :Sorry, username taken. Please choose another username, or contact staff for help.");
+ }
# 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(2147483647));
@@ -232,5 +236,18 @@ sub createshell {
return 1;
}
+#TODO Fix for $i
+# Return column $i from $filename as an array with file separator $FS
+sub col {
+ my ($filename, $i, $FS) = @_;
+ my @rows = main::readarray($filename);
+ my @results;
+ foreach my $row (@rows) {
+ if ($row =~ /^(.*?)$FS/) {
+ push(@results, $1);
+ }
+ }
+ return @results;
+}
#unveil("./newacct", "rx") or die "Unable to unveil $!";
1; # MUST BE LAST STATEMENT IN FILE
blob - 71e0910afd05778613469df8579c0f0336815f06
blob + 87767b047c025a8b27374b06946e51c9352befe1
--- botnow.pl
+++ botnow.pl
@@ -310,8 +310,7 @@ while(my @ready = $sel->can_read) {
if ($text =~ /^(PING|VERSION|TIME|USERINFO) (.*)$/i) {
my ($key, $val) = ($1, $2);
my $id = SQLite::id("irc", "nick", $nick, $time);
- if (!defined($id)) { die "undefined id"; }
- SQLite::set("irc", "id", $id, lc($key), $val);
+ SQLite::set("irc", "id", $id, "ctcp".lc($key), $val);
SQLite::set("irc", "id", $id, "localtime", gettime());
}
}
@@ -366,25 +365,21 @@ while(my @ready = $sel->can_read) {
my ($sender, $key) = ($1, "registered");
$val = $2 eq ":is a registered nick" ? "True" : "$2";
my $id = SQLite::id("irc", "nick", $sender, $time);
- if (!defined($id)) { die "undefined id"; }
SQLite::set("irc", "id", $id, "identified", $val);
debug(ALL, "$key: $val");
} elsif ($code == 311 && $text =~ /^([-_\|`a-zA-Z0-9]+) ([^:]+)\s+([^:]+) \* :([^:]*)/) {
my ($sender, $key, $val) = ($1, "hostmask", "$1\!$2\@$3");
my $id = SQLite::id("irc", "nick", $sender, $time);
- if (!defined($id)) { die "undefined id"; }
SQLite::set("irc", "id", $id, $key, $val);
debug(ALL, "$key: $val");
} elsif ($code == 312 && $text =~ /^([-_\|`a-zA-Z0-9]+) ([^:]+) :([^:]+)/) {
my ($sender, $key, $val) = ($1, "server", $2);
my $id = SQLite::id("irc", "nick", $sender, $time);
- if (!defined($id)) { die "undefined id"; }
SQLite::set("irc", "id", $id, $key, $val);
debug(ALL, "$key: $val");
} elsif ($code == 313 && $text =~ /^([-_\|`a-zA-Z0-9]+) :?(.*)/) {
my ($sender, $key, $val) = ($1, "oper", ($2 eq "is an IRC operator" ? "True" : "$2"));
my $id = SQLite::id("irc", "nick", $sender, $time);
- if (!defined($id)) { die "undefined id"; }
SQLite::set("irc", "id", $id, $key, $val);
debug(ALL, "$key: $val");
} elsif ($code == 315 && $text =~ /^([-_\|`a-zA-Z0-9]+) :End of \/?WHOIS list/) {
@@ -392,7 +387,6 @@ while(my @ready = $sel->can_read) {
} elsif ($code == 317 && $text =~ /^([-_\|`a-zA-Z0-9]+) (\d+) (\d+) :?(.*)/) {
($sender, my $idle, my $epochtime) = ($1, $2, $3);
my $id = SQLite::id("irc", "nick", $sender, $time);
- if (!defined($id)) { die "undefined id"; }
SQLite::set("irc", "id", $id, "idle", $idle);
# SQLite::set("irc", "id", $id, "epochtime", time());
debug(ALL, "idle: $idle, epochtime: $epochtime");
@@ -401,32 +395,27 @@ while(my @ready = $sel->can_read) {
} elsif ($code == 319 && $text =~ /^([-_\|`a-zA-Z0-9]+) :(.*)/) {
my ($sender, $key, $val) = ($1, "chans", $2);
my $id = SQLite::id("irc", "nick", $sender, $time);
- if (!defined($id)) { die "undefined id"; }
SQLite::set("irc", "id", $id, $key, $val);
debug(ALL, "$key: $val");
} elsif ($code == 330 && $text =~ /^([-_\|`a-zA-Z0-9]+) ([-_\|`a-zA-Z0-9]+) :?(.*)/) {
my ($sender, $key, $val) = ($1, "identified", ($3 eq "is logged in as" ? "True" : $2));
my $id = SQLite::id("irc", "nick", $sender, $time);
- if (!defined($id)) { die "undefined id"; }
SQLite::set("irc", "id", $id, $key, $val);
debug(ALL, "$key: $val");
} elsif ($code == 338 && $text =~ /^([-_\|`a-zA-Z0-9]+) ([0-9a-fA-F:.]+) :actually using host/) {
my ($sender, $key, $val) = ($1, "ip", $2);
my $id = SQLite::id("irc", "nick", $sender, $time);
- if (!defined($id)) { die "undefined id"; }
SQLite::set("irc", "id", $id, $key, $val);
debug(ALL, "$key: $val");
#Unexpected: efnet.port80.se 338 jrmu 206.253.167.44 :actually using host
} elsif ($code == 378 && $text =~ /^([-_\|`a-zA-Z0-9]+) :is connecting from ([^ ]+)\s*([0-9a-fA-F:.]+)?/) {
my ($sender, $key, $val) = ($1, "ip", $3);
my $id = SQLite::id("irc", "nick", $sender, $time);
- if (!defined($id)) { die "undefined id"; }
SQLite::set("irc", "id", $id, $key, $val);
debug(ALL, "$key: $val");
} elsif ($code == 671 && $text =~ /^([-_\|`a-zA-Z0-9]+) :is using a secure connection/) {
my ($sender, $key, $val) = ($1, "ssl", "True");
my $id = SQLite::id("irc", "nick", $sender, $time);
- if (!defined($id)) { die "undefined id"; }
SQLite::set("irc", "id", $id, $key, $val);
debug(ALL, "$key: $val");
} elsif ($code =~ /^332$/) { # Topic