Re: [master&rhel6-branch 1/3] Correctly pass netdev name from linuxrc.s390 to loader (#595382)

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

 



-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Ack.  The commit message could be a bit less verbose, but I will apply this
patch to master and rhel6-branch.

On Mon, 31 May 2010, Steffen Maier wrote:

Loader has 3 ways to configure the network:
1) interactive user input
2) boot parameters
3) readNetInfo
Option 3 is used to transfer the configuration of the already configured
network of linuxrc.s390. Linuxrc.s390 has to configure the network early
since the default terminals on s390 provide line mode but no full screen.
The user then logs in over ssh to provide a full screen terminal in which
loader can be executed. Since linuxrc already did the network config,
we want to skip interactive user input in loader. Hence, 3 replaces 1 and 2
on s390.
Before 0d5f432a39178f78754698e33a89905440584e4c, loader's readNetinfo
iterated over all existing ifcfg files, which is only fine for s390
where linuxrc currently only ever configures at most one network device.
Since readNetInfo is called for all platforms there could maybe exist
more than one ifcfg file so we need a way for linuxrc to tell loader the
name of the specific configured device.
Linuxrc.s390 has 3 ways to activate loader:
1) ssh login as user install, which has /sbin/loader as login shell
2) ssh login as user root (/bin/bash) and executing loader manually
3) boot option RUNKS=1
Passing exported environment variables only works for 3 where loader
is a child of linuxrc. 2 only worked by accident since linuxrc wrote
the content of /tmp/install.cfg into /etc/profile so root could see it.
However, in the general and often used case 1 there is neither an ancestor
relationship between linuxrc and loader nor a shell involved.
Therefore, introduce a new file /tmp/s390net to pass the name to loader.
This works the same for all three cases.
Since QETHPARM and CHANDEV are no longer used, we can get rid of
the old /tmp/install.cfg entirely.
---
booty/bootloaderInfo.py |   15 ---------------
loader/linuxrc.s390     |   45 +++++++--------------------------------------
loader/loader.c         |   40 ++++++++++++++++++++++++++++++++++------
3 files changed, 41 insertions(+), 59 deletions(-)

diff --git a/booty/bootloaderInfo.py b/booty/bootloaderInfo.py
index d019edf..a0a7b4d 100644
--- a/booty/bootloaderInfo.py
+++ b/booty/bootloaderInfo.py
@@ -172,26 +172,11 @@ class KernelArguments:

    def __init__(self, anaconda):
        newArgs = []
-        cfgFilename = "/tmp/install.cfg"

        self.anaconda = anaconda

        if iutil.isS390():
            self.cargs = []
-            f = open(cfgFilename)
-            for line in f:
-                try:
-                    (vname,vparm) = line.split('=', 1)
-                    vname = vname.strip()
-                    vparm = vparm.replace('"','')
-                    vparm = vparm.strip()
-                    if vname == "CHANDEV":
-                        self.cargs.append(vparm)
-                    if vname == "QETHPARM":
-                        self.cargs.append(vparm)
-                except Exception, e:
-                    pass
-            f.close()

        # look for kernel arguments we know should be preserved and add them
        ourargs = ["speakup_synth", "apic", "noapic", "apm", "ide", "noht",
diff --git a/loader/linuxrc.s390 b/loader/linuxrc.s390
index 99e5192..b421062 100644
--- a/loader/linuxrc.s390
+++ b/loader/linuxrc.s390
@@ -2971,49 +2971,18 @@ done
#    [ "$ipv6" ] && echo "IPV6=yes"

# transfer options into install environment
-cat > /tmp/install.cfg << EOF
-LANG="$LANG"
-S390ARCH="$S390ARCH"
-TEXTDOMAIN="$TEXTDOMAIN"
-TEXTDOMAINDIR="$TEXTDOMAINDIR"
-PORTNAME="$PORTNAME"
-HOSTNAME="$HOSTNAME"
-DEVICE="$DEVICE"
-NETTYPE="$NETTYPE"
-IPADDR="$IPADDR"
-GATEWAY="$GATEWAY"
-MTU="$MTU"
-NETWORK="$NETWORK"
-NETMASK="$NETMASK"
-BROADCAST="$BROADCAST"
-SEARCHDNS="$SEARCHDNS"
-PEERID="$PEERID"
-SUBCHANNELS="$SUBCHANNELS"
-ONBOOT="yes"
-CTCPROT="$CTCPROT"
-EOF
+# loader now uses ifcfg instead of install.cfg to receive our network config
+
+# additionally, loader's readNetInfo needs to know our DEVICE name
+echo $DEVICE > /tmp/s390net
+
if [ "$ipv6" ]; then
    DNS1=$(echo $DNS | cut -d ',' -f 1)
-    echo DNS=\"$DNS1\" >> /tmp/install.cfg
-    echo DNS1=\"$DNS1\" >> /tmp/install.cfg
-    echo DNS2=\"$(echo $DNS | cut -d ',' -f 2)\" >> /tmp/install.cfg
+    DNS2=$(echo $DNS | cut -d ',' -f 2)
else
    DNS1=$(echo $DNS | cut -d ':' -f 1)
-    echo DNS=\"$DNS1\" >> /tmp/install.cfg
-    echo DNS1=\"$DNS1\" >> /tmp/install.cfg
-    echo DNS2=\"$(echo $DNS | cut -d ':' -f 2)\" >> /tmp/install.cfg
+    DNS2=$(echo $DNS | cut -d ':' -f 2)
fi
-cat >> /tmp/install.cfg << EOF
-export LANG PORTNAME S390ARCH TEXTDOMAIN TEXTDOMAINDIR
-export HOSTNAME DEVICE NETTYPE IPADDR GATEWAY MTU
-export NETWORK NETMASK BROADCAST DNS DNS1 DNS2 SEARCHDNS
-export PEERID ONBOOT SUBCHANNELS CTCPROT
-EOF
-# immediately read it in again to export these into the shell below
-. /tmp/install.cfg
-if [ -z "$testing" ]; then
-    cat /tmp/install.cfg >> /etc/profile
-fi # testing

NETSCRIPTS="/etc/sysconfig/network-scripts"
IFCFGFILE="$NETSCRIPTS/ifcfg-$DEVICE"
diff --git a/loader/loader.c b/loader/loader.c
index fbbd13b..5f49cc0 100644
--- a/loader/loader.c
+++ b/loader/loader.c
@@ -633,20 +633,48 @@ static void writeVNCPasswordFile(char *pfile, char *password) {
 */
static void readNetInfo(struct loaderData_s ** ld) {
    struct loaderData_s * loaderData = *ld;
-    char *cfgfile = NULL;
-    gchar *contents = NULL;
+    char *cfgfile = NULL, *devfile = "/tmp/s390net";
+    gchar *contents = NULL, *device = NULL;
    gchar **lines = NULL, **line = NULL;
    GError *e = NULL;

-    /* when this function is called, the DEVICE environment variable
+    /* when this function is called, /tmp/s390net
     * contains the device name whose ifcfg file we want to read
     */
-    if (!getenv("DEVICE")) {
+    if (!g_file_test(devfile, G_FILE_TEST_EXISTS)) {
+        logMessage(DEBUGLVL, "readNetInfo %s not found, early return", devfile);
+        return;
+    }
+    if (!g_file_get_contents(devfile, &contents, NULL, &e)) {
+        logMessage(ERROR, "error reading %s: %s", devfile, e->message);
+        g_error_free(e);
+        abort();
+    }
+    line = lines = g_strsplit(contents, "\n", 0);
+    g_free(contents);
+    while (*line != NULL) {
+        gchar *tmp = g_strdup(*line);
+        tmp = g_strstrip(tmp);
+        logMessage(DEBUGLVL, "readNetInfo stripped line: %s", tmp);
+        if (strlen(tmp) > 0) {
+            device = strdup(tmp);
+            g_free(tmp);
+            logMessage(DEBUGLVL, "readNetInfo found device: %s", device);
+            break;
+        }
+        g_free(tmp);
+        line++;
+    }
+    free(cfgfile);
+    g_strfreev(lines);
+    if (strlen(device) == 0) {
        return;
+        logMessage(DEBUGLVL, "readNetInfo no device found");
    }

    checked_asprintf(&cfgfile, "/etc/sysconfig/network-scripts/ifcfg-%s",
-                     getenv("DEVICE"));
+                     device);
+    logMessage(INFO, "readNetInfo cfgfile: %s", cfgfile);

    /* make sure everything is NULL before we begin copying info */
    loaderData->ipv4 = NULL;
@@ -1485,7 +1513,7 @@ static char *doLoaderMain(struct loaderData_s *loaderData,

                logMessage(INFO, "going to do getNetConfig");

-                /* s390 provides all config info by way of the CMS conf file */
+                /* s390 provides all config info by way of linuxrc.s390 */
                if (FL_HAVE_CMSCONF(flags)) {
                    loaderData->ipinfo_set = 1;
#ifdef ENABLE_IPV6


- -- David Cantrell <dcantrell@xxxxxxxxxx>
Red Hat / Honolulu, HI

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.14 (GNU/Linux)

iEYEARECAAYFAkwGa5QACgkQ5hsjjIy1Vkl9bQCdHJvuSVE4mwVeiW8LxP+bBQZ/
1LoAnRR/C2FnNsYmIVRNeJQUD9QSIXq6
=PxLt
-----END PGP SIGNATURE-----

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/anaconda-devel-list


[Index of Archives]     [Kickstart]     [Fedora Users]     [Fedora Legacy List]     [Fedora Maintainers]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]
  Powered by Linux