Saves the bootfile if we get one so that it can be used later to construct the default kickstart file to try if the user boots with 'ks' as a boot parameter. --- loader2/net.c | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++++---- 1 files changed, 52 insertions(+), 4 deletions(-) diff --git a/loader2/net.c b/loader2/net.c index fbbde60..d25c1aa 100644 --- a/loader2/net.c +++ b/loader2/net.c @@ -1532,12 +1532,14 @@ int doDhcp(struct networkDeviceConfig *dev) { char *r = NULL, *class = NULL; char namebuf[HOST_NAME_MAX]; time_t timeout; - int loglevel, status, ret = 0, i; + int loglevel, status, ret = 0, i, sz = 0; int shmpump; DHCP_Preference pref = 0; pid_t pid; key_t key; int mturet; + int culvert[2]; + char buf[PATH_MAX]; /* clear existing IP addresses */ clearInterface(dev->dev.device); @@ -1602,9 +1604,16 @@ int doDhcp(struct networkDeviceConfig *dev) { strncpy(pumpdev->device, dev->dev.device, IF_NAMESIZE); + if (pipe(culvert) == -1) { + logMessage(ERROR, "%s: pipe(): %s", __func__, strerror(errno)); + return 1; + } + /* call libdhcp in a separate process because libdhcp is bad */ pid = fork(); if (pid == 0) { + close(culvert[0]); + if (pumpdev->set & PUMP_INTFINFO_HAS_MTU) { mturet = nl_set_device_mtu((char *) pumpdev->device, pumpdev->mtu); @@ -1658,14 +1667,25 @@ int doDhcp(struct networkDeviceConfig *dev) { } } - /* we lose bootFile here, but you know, I just don't care, because - * we don't need it past doDhcp() calls, so whatever --dcantrell - */ + if (pumpdev->set & PUMP_INTFINFO_HAS_BOOTFILE) { + if (pumpdev->bootFile) { + if (write(culvert[1], pumpdev->bootFile, + strlen(pumpdev->bootFile) + 1) == -1) { + logMessage(ERROR, "failed to send bootFile to parent " + "in %s: %s", __func__, + strerror(errno)); + } + + close(culvert[1]); + } + } exit(0); } else if (pid == -1) { logMessage(CRITICAL, "dhcp client failed to start"); } else { + close(culvert[1]); + if (waitpid(pid, &status, 0) == -1) { logMessage(ERROR, "waitpid() failure in %s", __func__); } @@ -1733,6 +1753,34 @@ int doDhcp(struct networkDeviceConfig *dev) { } } + if (dev->dev.set & PUMP_INTFINFO_HAS_BOOTFILE) { + memset(&buf, '\0', sizeof(buf)); + + while ((sz = read(culvert[0], &buf, sizeof(buf))) > 0) { + if (dev->dev.bootFile == NULL) { + dev->dev.bootFile = calloc(sizeof(char), sz + 1); + if (dev->dev.bootFile == NULL) { + logMessage(ERROR, "unable to read bootfile"); + break; + } + + dev->dev.bootFile = strncpy(dev->dev.bootFile, buf, sz); + } else { + dev->dev.bootFile = realloc(dev->dev.bootFile, + strlen(dev->dev.bootFile) + + sz + 1); + if (dev->dev.bootFile == NULL) { + logMessage(ERROR, "unable to read bootfile"); + break; + } + + dev->dev.bootFile = strncat(dev->dev.bootFile, buf, sz); + } + } + + close(culvert[0]); + } + if (shmdt(pumpdev) == -1) { logMessage(ERROR, "%s: shmdt() pumpdev: %s", __func__, strerror(errno)); -- 1.6.3.3 _______________________________________________ Anaconda-devel-list mailing list Anaconda-devel-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/anaconda-devel-list