[debian-edu-commits] debian-edu/ 01/01: Implement script to remove duplicate udev network rules, to work around bug #765577. This avoid complete network failure on machines affected by this bug.
Petter Reinholdtsen
pere at moszumanska.debian.org
Fri Oct 24 09:12:04 UTC 2014
This is an automated email from the git hooks/post-receive script.
pere pushed a commit to branch master
in repository debian-edu-config.
commit 455ad3104e7f2002b25a1a7a49442bba81bf3a9a
Author: Petter Reinholdtsen <pere at hungry.com>
Date: Fri Oct 24 11:11:52 2014 +0200
Implement script to remove duplicate udev network rules, to work around bug #765577. This avoid complete network failure on machines affected by this bug.
---
Makefile | 1 +
debian/changelog | 3 +
share/debian-edu-config/d-i/pre-pkgsel | 7 +++
.../tools/workaround-udev-bug-765577 | 71 ++++++++++++++++++++++
4 files changed, 82 insertions(+)
diff --git a/Makefile b/Makefile
index 827b887..2586b7d 100644
--- a/Makefile
+++ b/Makefile
@@ -388,6 +388,7 @@ install: install-testsuite
share/debian-edu-config/tools/subnet-change \
share/debian-edu-config/tools/update-iceweasel-homepage \
share/debian-edu-config/tools/update-proxy-from-wpad \
+ share/debian-edu-config/tools/workaround-udev-bug-765577 \
share/debian-edu-config/tools/wpad-extract \
share/debian-edu-config/ltspfs-mounter-kde \
share/ltsp/get-ldap-ltsp-config \
diff --git a/debian/changelog b/debian/changelog
index fa5ba1c..679fee5 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -14,6 +14,9 @@ debian-edu-config (1.813) UNRELEASED; urgency=low
* Correct check for bug #765577 (duplicate udev rules for network
card) to also work when more than one network card is present in the
machine.
+ * Implement script to remove duplicate udev network rules, to work
+ around bug #765577. This avoid complete network failure on
+ machines affected by this bug.
-- Petter Reinholdtsen <pere at debian.org> Thu, 23 Oct 2014 10:35:10 +0200
diff --git a/share/debian-edu-config/d-i/pre-pkgsel b/share/debian-edu-config/d-i/pre-pkgsel
index c298731..34d47a9 100644
--- a/share/debian-edu-config/d-i/pre-pkgsel
+++ b/share/debian-edu-config/d-i/pre-pkgsel
@@ -209,6 +209,13 @@ EOF
echo "$MAILNAME" > /target/etc/mailname
fi
+ # Workaround for bug in d-i/udev, causing duplicate entries in
+ # /etc/udev/rules.d/70-persistent-net.rules in both d-i and
+ # /target/. See bug $765577 for the details.
+ if in-target /usr/share/debian-edu-config/tools/workaround-udev-bug-765577 ; then
+ error "disabled duplicate udev rule (bug #765577)"
+ fi
+
# Make sure that the interfaces are there for the cfengine run if
# network isn't already configured
if route | grep -q default ; then
diff --git a/share/debian-edu-config/tools/workaround-udev-bug-765577 b/share/debian-edu-config/tools/workaround-udev-bug-765577
new file mode 100755
index 0000000..7054c58
--- /dev/null
+++ b/share/debian-edu-config/tools/workaround-udev-bug-765577
@@ -0,0 +1,71 @@
+#!/usr/bin/perl
+#
+# Implement workaround for bug #765577 by removing duplicate entries
+# from the persistent network interface name rule before rebooting for
+# the first time, to make sure eth0 is present on the machines with
+# fixed network setup in /etc/network/interfaces
+
+use strict;
+use warnings;
+use Getopt::Std;
+
+my $bugurl = "https://bugs.debian.org/765577";
+
+my $rulefile = "/etc/udev/rules.d/70-persistent-net.rules";
+my $newfile = "$rulefile.new";
+
+my $debug = 0;
+my %linecache;
+my $modified = 0;
+my %opts;
+
+sub usage {
+ my $retval = shift;
+ print <<EOF;
+Usage: $0: [-dn]
+Fix
+ -d enable debugging
+ -n do not modify $rulefile
+EOF
+ exit($retval) if $retval;
+}
+
+getopts("dn", \%opts) || usage(1);
+
+open(my $rh, '<', $rulefile) || die "error: unable to read from $rulefile";
+my $wh;
+if (!$opts{'n'}) {
+ open($wh, '>', "$newfile") || die "error: unable to write to $newfile";
+}
+my $shortline;
+while (my $line = <$rh>) {
+ $shortline = $line;
+ $shortline =~ s/, NAME="[^"]+"//;
+ print STDERR "shortline: '$shortline'\n" if $opts{'d'};
+ if ($shortline !~ m/^\s*$/
+ && $shortline =~ m/^SUBSYSTEM=/
+ && exists $linecache{$shortline}) {
+ # Seen the same line before, skip it.
+ print STDERR "skipping line\n" if $opts{'d'};
+ $modified = 1;
+ if (!$opts{'n'}) {
+ print $wh "# Duplicate entry disabled, workaround for $bugurl\n#$line";
+ }
+ next;
+ }
+ $linecache{$shortline} = 1;
+ if (!$opts{'n'}) {
+ print $wh $line;
+ }
+}
+close($rh);
+if (!$opts{'n'}) {
+ close($wh);
+ if ($modified) {
+ rename("$newfile", "$rulefile") || die "error: unable to rename $newfile to $rulefile";
+ } else {
+ unlink $newfile;
+ }
+} else {
+}
+exit ! $modified;
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-edu/debian-edu-config.git
More information about the debian-edu-commits
mailing list