summaryrefslogtreecommitdiffstats
path: root/loader2
diff options
context:
space:
mode:
authorDavid Cantrell <dcantrell@redhat.com>2006-10-17 15:18:11 +0000
committerDavid Cantrell <dcantrell@redhat.com>2006-10-17 15:18:11 +0000
commit1c92bf5934f2d283473422e2a1f411ce686bcccf (patch)
tree800b7c42b8d1f50681db53f7a1b49f18ef38f346 /loader2
parent04c6810d76f1c9605283a63287917a487ed682ba (diff)
downloadanaconda-1c92bf5934f2d283473422e2a1f411ce686bcccf.tar.gz
anaconda-1c92bf5934f2d283473422e2a1f411ce686bcccf.tar.xz
anaconda-1c92bf5934f2d283473422e2a1f411ce686bcccf.zip
* loader2/loader.c (readNetInfo): Rewrote the /tmp/netinfo parser so we
get loaderData populated with valid strings for inet_pton (#207991). * loader2/net.c (printLoaderDataIPINFO): Wrap debugging output in pipes so we can more easily see when space characters are present. * loader2/net.c (setupNetworkDeviceConfig): If the IP information in loaderData is invalid, set isDynamic flag to 0. * loader2/net.c (kickstartNetworkUp): Remove isDynamic initialization.
Diffstat (limited to 'loader2')
-rw-r--r--loader2/loader.c127
-rw-r--r--loader2/net.c24
2 files changed, 82 insertions, 69 deletions
diff --git a/loader2/loader.c b/loader2/loader.c
index 1dd55d907..56f2e7860 100644
--- a/loader2/loader.c
+++ b/loader2/loader.c
@@ -21,7 +21,6 @@
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
-
#include <ctype.h>
#include <errno.h>
#include <execinfo.h>
@@ -423,62 +422,76 @@ static void writeVNCPasswordFile(char *pfile, char *password) {
/* read information from /tmp/netinfo (written by linuxrc) */
static void readNetInfo(struct loaderData_s ** ld) {
- struct loaderData_s * loaderData = *ld;
- FILE *f;
- char *end;
- char buf[100], *vname, *vparm;
-
- f = fopen("/tmp/netinfo", "r");
- if (!f) {
- return;
- }
- vname = (char *)malloc(sizeof(char)*15);
- vparm = (char *)malloc(sizeof(char)*85);
-
- while(fgets(buf, 100, f)) {
- if ((vname = strtok(buf, "="))) {
- vparm = strtok(NULL, "=");
- while (isspace(*vparm))
- vparm++;
- end = strchr(vparm, '\0');
- while (isspace(*end))
- end--;
- end++;
- *end = '\0';
- if (strstr(vname, "IPADDR")) {
- loaderData->ip = strdup(vparm);
- loaderData->ipinfo_set = 1;
- }
- if (strstr(vname, "NETMASK")) {
- loaderData->netmask = strdup(vparm);
- }
- if (strstr(vname, "GATEWAY")) {
- loaderData->gateway = strdup(vparm);
- }
- if (strstr(vname, "DNS")) {
- loaderData->dns = strdup(vparm);
- }
- if (strstr(vname, "MTU")) {
- loaderData->mtu = atoi(vparm);
- }
- if (strstr(vname, "PEERID")) {
- loaderData->peerid = strdup(vparm);
- }
- if (strstr(vname, "SUBCHANNELS")) {
- loaderData->subchannels = strdup(vparm);
- }
- if (strstr(vname, "PORTNAME")) {
- loaderData->portname = strdup(vparm);
- }
- if (strstr(vname, "NETTYPE")) {
- loaderData->nettype = strdup(vparm);
- }
- if (strstr(vname, "CTCPROT")) {
- loaderData->ctcprot = strdup(vparm);
- }
- }
- }
- fclose(f);
+ int i;
+ struct loaderData_s * loaderData = *ld;
+ FILE *f;
+ /* FIXME: arbitrary size that works, but could blow up in the future */
+ int bufsiz = 100;
+ char buf[bufsiz], *vname, *vparm;
+
+ f = fopen("/tmp/netinfo", "r");
+ if (!f)
+ return;
+
+ /* FIXME: static buffers lead to pain */
+ vname = (char *)malloc(sizeof(char)*15);
+ vparm = (char *)malloc(sizeof(char)*85);
+
+ /*
+ * The /tmp/netinfo file is written out by /sbin/init on s390x (which is
+ * really the linuxrc.s390 script). It's a shell-sourcable file with
+ * various system settings needing for the system instance.
+ *
+ * The goal of this function is to read in only the network settings
+ * and populate the loaderData structure.
+ */
+ while(fgets(buf, bufsiz, f)) {
+ /* trim whitespace from end */
+ i = 0;
+ while (!isspace(buf[i]) && i < (bufsiz-1))
+ i++;
+ buf[i] = '\0';
+
+ /* break up var name and value */
+ if (strstr(buf, "=")) {
+ vname = strtok(buf, "=");
+ vparm = strtok(NULL, "=");
+
+ if (!strncmp(vname, "IPADDR", 6)) {
+ loaderData->ip = strdup(vparm);
+ loaderData->ipinfo_set = 1;
+ }
+
+ if (!strncmp(vname, "NETMASK", 7))
+ loaderData->netmask = strdup(vparm);
+
+ if (!strncmp(vname, "GATEWAY", 7))
+ loaderData->gateway = strdup(vparm);
+
+ if (!strncmp(vname, "DNS", 3))
+ loaderData->dns = strdup(vparm);
+
+ if (!strncmp(vname, "MTU", 3))
+ loaderData->mtu = atoi(vparm);
+
+ if (!strncmp(vname, "PEERID", 6))
+ loaderData->peerid = strdup(vparm);
+
+ if (!strncmp(vname, "SUBCHANNELS", 12))
+ loaderData->subchannels = strdup(vparm);
+
+ if (!strncmp(vname, "PORTNAME", 8))
+ loaderData->portname = strdup(vparm);
+
+ if (!strncmp(vname, "NETTYPE", 7))
+ loaderData->nettype = strdup(vparm);
+
+ if (!strncmp(vname, "CTCPROT", 7))
+ loaderData->ctcprot = strdup(vparm);
+ }
+ }
+
+ fclose(f);
}
/* parse anaconda or pxelinux-style ip= arguments
diff --git a/loader2/net.c b/loader2/net.c
index 4eccb9c08..ea1ed2984 100644
--- a/loader2/net.c
+++ b/loader2/net.c
@@ -310,17 +310,17 @@ static int getDnsServers(struct networkDeviceConfig * cfg) {
}
void printLoaderDataIPINFO(struct loaderData_s *loaderData) {
- logMessage(DEBUGLVL, "loaderData->ipinfo_set = %d", loaderData->ipinfo_set);
- logMessage(DEBUGLVL, "loaderData->ip = %s", loaderData->ip);
- logMessage(DEBUGLVL, "loaderData->netmask = %s", loaderData->netmask);
- logMessage(DEBUGLVL, "loaderData->gateway = %s", loaderData->gateway);
- logMessage(DEBUGLVL, "loaderData->dns = %s", loaderData->dns);
- logMessage(DEBUGLVL, "loaderData->hostname = %s", loaderData->hostname);
- logMessage(DEBUGLVL, "loaderData->noDns = %d", loaderData->noDns);
- logMessage(DEBUGLVL, "loaderData->netDev_set = %d", loaderData->netDev_set);
- logMessage(DEBUGLVL, "loaderData->netDev = %s", loaderData->netDev);
- logMessage(DEBUGLVL, "loaderData->netCls_set = %d", loaderData->netCls_set);
- logMessage(DEBUGLVL, "loaderData->netCls = %s", loaderData->netCls);
+ logMessage(DEBUGLVL, "loaderData->ipinfo_set = |%d|", loaderData->ipinfo_set);
+ logMessage(DEBUGLVL, "loaderData->ip = |%s|", loaderData->ip);
+ logMessage(DEBUGLVL, "loaderData->netmask = |%s|", loaderData->netmask);
+ logMessage(DEBUGLVL, "loaderData->gateway = |%s|", loaderData->gateway);
+ logMessage(DEBUGLVL, "loaderData->dns = |%s|", loaderData->dns);
+ logMessage(DEBUGLVL, "loaderData->hostname = |%s|", loaderData->hostname);
+ logMessage(DEBUGLVL, "loaderData->noDns = |%d|", loaderData->noDns);
+ logMessage(DEBUGLVL, "loaderData->netDev_set = |%d|", loaderData->netDev_set);
+ logMessage(DEBUGLVL, "loaderData->netDev = |%s|", loaderData->netDev);
+ logMessage(DEBUGLVL, "loaderData->netCls_set = |%d|", loaderData->netCls_set);
+ logMessage(DEBUGLVL, "loaderData->netCls = |%s|", loaderData->netCls);
}
/* given loader data from kickstart, populate network configuration struct */
@@ -413,6 +413,7 @@ void setupNetworkDeviceConfig(struct networkDeviceConfig * cfg,
cfg->preset = 1;
} else { /* invalid ip information, disable the setting of ip info */
loaderData->ipinfo_set = 0;
+ cfg->isDynamic = 0;
loaderData->ip = NULL;
}
}
@@ -1727,7 +1728,6 @@ int kickstartNetworkUp(struct loaderData_s * loaderData,
initLoopback();
memset(netCfgPtr, 0, sizeof(*netCfgPtr));
- netCfgPtr->isDynamic = 1;
do {
/* this is smart and does the right thing based on whether or not