summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatarJanik Kleinhoff <ilbelkyr@shalture.org>2016-12-25 19:08:11 +0000
committerLibravatarJanik Kleinhoff <ilbelkyr@shalture.org>2016-12-25 19:08:11 +0000
commite17a73b8591741d00e7727d2dc016e3509a62033 (patch)
tree72a0da5c5249d6eff6e008fe58e30ac3260920cd
parent29d448e4400c030fbea3210956ca8ac64399cbb2 (diff)
Split 'pass' option into 'server_pass', 'account_pass'
Also remove the --pass command-line option for now and introduce a backward compatibility check that warns when the old option is encountered. This check is now placed with the mysql option checks in a dedicated function. --- So one day, I looked over the AntiSpamMeta console log and noticed NickServ was echoing back part of the password to us in a "no such username" error. This is due to us using the 'pass' option for both nickserv and server password, so we sent PASS NickServPassword. However, the password happened to have a ':' in it, so services interpreted it as a user:password combination.
-rw-r--r--config-default/settings.json3
-rw-r--r--lib/ASM/Event.pm4
-rw-r--r--lib/ASM/Services.pm2
-rwxr-xr-xmeta.pl65
4 files changed, 41 insertions, 33 deletions
diff --git a/config-default/settings.json b/config-default/settings.json
index 6a9a796..aed9781 100644
--- a/config-default/settings.json
+++ b/config-default/settings.json
@@ -1,4 +1,5 @@
{
+ "account_pass" : "NICKSERV PASSWORD GOES HERE",
"altnicks" : [
"AntiSpamMeta_",
"AntiSpamMeta2"
@@ -18,12 +19,12 @@
},
"masterchan" : "#antispammeta",
"nick" : "AntiSpamMeta",
- "pass" : "NICKSERV/SERVER PASSWORD GOES HERE",
"port" : "6697",
"realname" : "https://antispammeta.net/",
"server" : [
"irc.freenode.net"
],
+ "server_pass" : "SERVER PASSWORD GOES HERE",
"ssl" : "1",
"username" : "MetaBot",
"web" : {
diff --git a/lib/ASM/Event.pm b/lib/ASM/Event.pm
index 5e0435c..8c1a54b 100644
--- a/lib/ASM/Event.pm
+++ b/lib/ASM/Event.pm
@@ -166,9 +166,9 @@ sub on_connect {
$conn->sl("MODE $event->{args}->[0] +Q");
if (lc $event->{args}->[0] ne lc $::settings->{nick}) {
ASM::Util->dprint('Attempting to regain my main nick', 'startup');
- $conn->sl("NickServ regain $::settings->{nick} $::settings->{pass}");
+ $conn->sl("NickServ regain $::settings->{nick} $::settings->{account_pass}");
}# else {
-# $conn->sl("NickServ identify $::settings->{nick} $::settings->{pass}");
+# $conn->sl("NickServ identify $::settings->{nick} $::settings->{account_pass}");
# }
$conn->sl('CAP REQ :extended-join multi-prefix account-notify'); #god help you if you try to use this bot off freenode
}
diff --git a/lib/ASM/Services.pm b/lib/ASM/Services.pm
index f3da82c..5aa0741 100644
--- a/lib/ASM/Services.pm
+++ b/lib/ASM/Services.pm
@@ -27,7 +27,7 @@ sub doServices {
if ( $event->{args}->[0] =~ /^Please identify/ || $event->{args}->[0] =~ /^This nickname is registered/ )
{
$::no_autojoins = 0;
- $conn->sl("NickServ identify $::settings->{nick} $::settings->{pass}" );
+ $conn->sl("NickServ identify $::settings->{nick} $::settings->{account_pass}" );
}
elsif ( $event->{args}->[0] =~ /^You are now identified/ )
{
diff --git a/meta.pl b/meta.pl
index 2e12008..bbd7a2e 100755
--- a/meta.pl
+++ b/meta.pl
@@ -36,7 +36,6 @@ no if $] >= 5.017011, warnings => 'experimental::smartmatch';
$|++;
$Data::Dumper::Useqq=1;
-$::pass = '';
@::nick_blacklist=();
$::netsplit = 0;
$::netsplit_ignore_lag = 0;
@@ -96,6 +95,38 @@ sub alarmdeath
$SIG{ALRM} = \&alarmdeath;
alarm 300;
+sub startup_checks {
+ my $config_bad = 0;
+
+ if (exists $::mysql->{table}) {
+ if ($::mysql->{table} ne 'alertlog') {
+ warn "FATAL - The 'table' option in mysql.json is no longer supported. Please ensure your table is named 'alertlog'.\n";
+ $config_bad++;
+ }
+ else {
+ warn "The 'table' option in mysql.json is no longer supported. Please remove it from the configuration.\n";
+ }
+ }
+ if (exists $::mysql->{actiontable}) {
+ if ($::mysql->{actiontable} ne 'actionlog') {
+ warn "FATAL - The 'actiontable' option in mysql.json is no longer supported. Please ensure your table is named 'actionlog'.\n";
+ $config_bad++;
+ }
+ else {
+ warn "The 'actiontable' option in mysql.json is no longer supported. Please remove it from the configuration.\n";
+ }
+ }
+
+ if (exists $::settings->{pass}) {
+ warn "The 'pass' option in settings.json has been split into 'server_pass' and 'account_pass'. Please update your configuration accordingly.\n";
+ $::settings->{server_pass} //= $::settings->{account_pass} //= $::settings->{pass};
+ }
+
+ if ($config_bad) {
+ die "The bot cannot operate with the current configuration.\n";
+ }
+}
+
sub init {
my ( $conn, $host );
$::version .= `git merge-base remotes/origin/master HEAD`; chomp $::version;
@@ -105,7 +136,6 @@ sub init {
$::version .= `git rev-parse HEAD`; chomp $::version;
my $irc = new Net::IRC;
GetOptions( 'debug|d!' => \$::debug,
- 'pass|p=s' => \$::pass,
'config|c=s' => \$::cset
);
if (-e "debugmode") {
@@ -114,7 +144,9 @@ sub init {
if ($::cset eq '') { $::cset = 'config-default'; }
else { $::cset = "config-$::cset"; }
ASM::Config->readConfig();
- $::pass = $::settings->{pass} if $::pass eq '';
+
+ startup_checks();
+
$::async = HTTP::Async->new();
$::dns = Net::DNS::Async->new(QueueSize => 5000, Retries => 3);
$host = ${$::settings->{server}}[rand @{$::settings->{server}}];
@@ -124,31 +156,6 @@ sub init {
$irc->debugsock(1);
}
- my $mysql_config_bad = 0;
-
- if (exists $::mysql->{table}) {
- if ($::mysql->{table} ne 'alertlog') {
- warn "The 'table' option in mysql.json is no longer supported. Please ensure your table is named 'alertlog'.\n";
- $mysql_config_bad++;
- }
- else {
- warn "The 'table' option in mysql.json is no longer supported. Please remove it from the configuration.\n";
- }
- }
- if (exists $::mysql->{actiontable}) {
- if ($::mysql->{actiontable} ne 'actionlog') {
- warn "The 'actiontable' option in mysql.json is no longer supported. Please ensure your table is named 'actionlog'.\n";
- $mysql_config_bad++;
- }
- else {
- warn "The 'actiontable' option in mysql.json is no longer supported. Please remove it from the configuration.\n";
- }
- }
-
- if ($mysql_config_bad) {
- die "The bot cannot operate with the current database configuration.\n";
- }
-
if (!$::mysql->{disable}) {
my $dsn;
if (exists $::mysql->{dsn}) {
@@ -168,7 +175,7 @@ sub init {
Nick => $::settings->{nick},
Ircname => $::settings->{realname},
Username => $::settings->{username},
- Password => $::settings->{pass},
+ Password => $::settings->{server_pass},
Pacing => 0 );
$conn->debug($::debug);
if (-e "debugsock") {