Commit 190a6a07 authored by Tails developers's avatar Tails developers

Add monitor for detecting network blockage.

Since we enable MAC spoofing by default, users may experience network
connection issues on networks emplying MAC address blocking.
Unfortunately NetworkManager does not seem to offer any nice hook into
its error-handling, so when MAC spoofing is enabled we run (from T-G)
this crufty script which analyzes NM's log and tries to identify
connection failures that is unrelated to more common errors, like
entering an incorrect WPA passphrase. At the moment the script only
handles wifi networks, not wired, WAN, etc.
parent f16f5f31
#!/usr/bin/env perl
use strict;
use warnings;
=head1 NAME
=head1 VERSION
Version X.XX
=head1 AUTHOR
Tails dev team <>
use File::Tail;
use Parse::Syslog;
use Locale::gettext;
use POSIX;
setlocale(LC_MESSAGES, "");
sub notify_maybe_blocked {
my $summary = gettext('Network connection blocked?');
my $body = gettext(
'It looks like you are blocked from the network. This may be ' .
'related to the MAC spoofing feature. For more information, see the ' .
'<a href=\"file:///usr/share/doc/tails/website/doc/advanced_topics/' .
'mac_changer.en.html#blocked\">MAC spoofing documentation</a>.');
# We can't use Desktop::Notify since this script is supposed to be run
# as root (for access to syslog), started in an env without DESKTOP etc,
# which also causes issues with opening links in the text body.
system("/usr/local/sbin/tails-notify-user '$summary' '$body' 30000");
my %state = ();
my $syslog = File::Tail->new(name => "/var/log/syslog",
maxinterval => 1,
interval => 1);
my $parser = Parse::Syslog->new($syslog, allow_future => 1);
while(my $sl = $parser->next) {
next if !($sl->{program} eq "NetworkManager");
my $text = $sl->{text};
if ($text =~ /Activation \(([^)]+)\) starting connection/) {
# The beginning of *all* (not only wireless) new
# connections. We drop any previous state so it won't
# interfere.
$state{$1} = undef;
} elsif ($text =~ /\(([^)]+)\): supplicant connection state:.*-> (.*)$/) {
# Wireless connection state transition.
$state{$1} = $2;
} elsif ($text =~ /Activation \(([^)]+)\/[^)]*\): association took too long/) {
# Wireless connection failure. If it happens during
# "associating" it *may* indicate that the AP is blocking the
# MAC address in use.
if ($state{$1} eq "associating") {
......@@ -50,6 +50,9 @@ liblocale-gettext-perl
# needed by
# for /usr/local/sbin/tails-blocked-network-detector
### Software
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment