[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: [PATCH 4/4] Disable ipv6 kernel modules if user disables IPv6 (#537887)



On Mon, 9 Aug 2010, David Cantrell wrote:

On Mon, 9 Aug 2010, Brian C. Lane wrote:

On 08/09/2010 10:57 AM, Brian C. Lane wrote:
On 08/06/2010 10:45 PM, dcantrell redhat com wrote:
From: David Cantrell <dcantrell redhat com>

+            f = open(c, "w+")
+            if header:
+                f.write(header)

header and check for isfile isn't needed, since this is the first time
it has been written, and you're using "w+" which will overwrite it anyway.


and I just realized there is no "w+" mode, r+ is read/write. It seems to
work, but should probably be changed to plain old "w"

"w"?  Based on what I'm seeing here:

   http://docs.python.org/library/functions.html

it should be "a".  But then there are "r+", "w+", and "a+" which open for
updating.  Looks like they got the USPS to guest-author this part of the
Python documentation.

New patch:


Disable ipv6 kernel modules if user disables IPv6 (#537887)

If the user passes 'noipv6' or otherwise disables IPv6 on the target
system for all network devices, write out /etc/modprobe.d/noipv6 with
these lines:

    # Disable IPv6 kernel modules (added by anaconda)
    alias net-pf-10 off
    alias ipv6 off
    options ipv6 disable=1

Based on a patch provided in the bug, but modified so that the lines are
written to 'noipv6' in /etc/modprobe.d rather than /etc/modprobe.conf
and so that the file is only written out if IPv6 is disabled on all
interfaces.
---
 network.py  |   21 +++++++++++++++++++++
 packages.py |    1 +
 2 files changed, 22 insertions(+), 0 deletions(-)

diff --git a/network.py b/network.py
index 6036b59..45aa7dc 100644
--- a/network.py
+++ b/network.py
@@ -603,3 +603,24 @@ class Network:
                 f.write("nameserver %s\n" % (ns,))

         f.close()
+
+        # /etc/modprobe.d/noipv6
+        if useIPv6 == "no":
+            d = instPath + "/etc/modprobe.d"
+            c = d + "/noipv6"
+            header = None
+
+            iutil.mkdirChain(d)
+
+            if os.path.isfile(c):
+                header = "\n"
+
+            f = open(c, "a")
+            if header:
+                f.write(header)
+
+            f.write("# Disable IPv6 kernel modules (added by anaconda)\n")
+            f.write("alias net-pf-10 off\n")
+            f.write("alias ipv6 off\n")
+            f.write("options ipv6 disable=1\n")
+            f.close()
diff --git a/packages.py b/packages.py
index a1a6e56..c030eba 100644
--- a/packages.py
+++ b/packages.py
@@ -209,6 +209,7 @@ def setFileCons(anaconda):
                  "/etc/blkid.tab", "/etc/blkid.tab.old",
                  "/etc/mtab", "/etc/fstab", "/etc/resolv.conf",
                  "/etc/modprobe.conf", "/etc/modprobe.conf~",
+                 "/etc/modprobe.d/noipv6",
                  "/var/log/wtmp", "/var/run/utmp",
                  "/dev/log", "/var/lib/rpm", "/", "/etc/raidtab",
                  "/etc/mdadm.conf", "/etc/hosts", "/etc/sysconfig/network",

--
David Cantrell <dcantrell redhat com>
Red Hat / Honolulu, HI


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]