Bug 50766 - potential enhancement for getting kickstart file via HTTP
potential enhancement for getting kickstart file via HTTP
Status: CLOSED RAWHIDE
Product: Red Hat Linux
Classification: Retired
Component: anaconda (Show other bugs)
7.1
i386 Linux
medium Severity medium
: ---
: ---
Assigned To: Brent Fox
Brock Organ
: FutureFeature
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2001-08-02 18:07 EDT by bruno
Modified: 2007-04-18 12:35 EDT (History)
0 users

See Also:
Fixed In Version:
Doc Type: Enhancement
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2001-08-02 18:07:20 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description bruno 2001-08-02 18:07:16 EDT
Description of problem:
below, are changes to loader.c and loader.h that may be used to enhance
'loader' to get kickstart files via HTTP.

Additional info:

===========================================
loader.c
===========================================
[bruno@frontend-0 loader]$ diff -uNr ../../../anaconda-7.1/loader/loader.c
loader.c
--- ../../../anaconda-7.1/loader/loader.c       Wed Apr  4 21:03:54 2001
+++ loader.c    Sat Jul 28 21:40:41 2001
@@ -76,6 +76,9 @@
 int cardmgr_main(int argc, char ** argv);
 int ourInsmodCommand(int argc, char ** argv);
 int kon_main(int argc, char ** argv);
+#ifdef SDSC
+int httpGetFileDesc(char * hostname, int port, char * remotename);
+#endif
 static int mountLoopback(char * fsystem, char * mntpoint, char * device);
 static int umountLoopback(char * mntpoint, char * device);
 
@@ -1103,7 +1106,13 @@
        or return LOADER_BACK, in which case we don't get here. */
     if (!deviceNums) return LOADER_ERROR;
 
-    if (deviceNums == 1 || FL_KICKSTART(flags) || FL_KSNFS(flags)) {
+#ifdef SDSC
+    if (deviceNums == 1 || FL_KICKSTART(flags) || FL_KSNFS(flags)
+                   || FL_KSHTTP(flags))
+#else
+    if (deviceNums == 1 || FL_KICKSTART(flags) || FL_KSNFS(flags))
+#endif
+    {
        *devNamePtr = devices[0];
        return 0;
     }
@@ -1961,7 +1970,11 @@
        } else if (!strcasecmp(argv[i], "serial"))
            flags |= LOADER_FLAGS_SERIAL;
         else if (!strcasecmp(argv[i], "ks")) {
+#ifdef SDSC
+           flags |= LOADER_FLAGS_KSHTTP;
+#else
            flags |= LOADER_FLAGS_KSNFS;
+#endif
            *ksSource = NULL;
         } else if (!strncasecmp(argv[i], "ks=cdrom:", 7)) {
            flags |= LOADER_FLAGS_KSCDROM;
@@ -1969,6 +1982,11 @@
         } else if (!strncasecmp(argv[i], "ks=nfs:", 7)) {
            flags |= LOADER_FLAGS_KSNFS;
            *ksSource = argv[i] + 7;
+#ifdef SDSC
+        } else if (!strncasecmp(argv[i], "ks=http://", 10)) {
+           flags |= LOADER_FLAGS_KSHTTP;
+           *ksSource = argv[i] + 10;
+#endif
         } else if (!strcasecmp(argv[i], "ks=floppy"))
            flags |= LOADER_FLAGS_KSFLOPPY;
        else if (!strncasecmp(argv[i], "display=", 8))
@@ -1993,6 +2011,109 @@
 }
 
 #ifdef INCLUDE_NETWORK
+#ifdef SDSC
+int kickstartFromHTTP(struct knownDevices * kd, char * location, 
+                    moduleInfoSet modInfo, moduleList modLoaded, 
+                    moduleDeps * modDepsPtr, int flags, char * ksSource,
+                    char * ksDevice)
+{
+    struct networkDeviceConfig netDev;
+    int                                httpfd;
+    int                                ksfd;
+    int                                bytesread;
+    char                       *ksPath;
+    char                       *devName;
+    char                       *ptr;
+    char                       *server;
+    char                       *file;
+    char                       buf[1024];
+
+    if (!ksDevice) {
+       if (ensureNetDevice(kd, modInfo, modLoaded, modDepsPtr, flags, 
+                           &devName))
+           return 1;
+    } else {
+       devName = ksDevice;
+    }
+
+    if (kickstartNetwork(&devName, &netDev, "dhcp", flags)) {
+        logMessage("no dhcp response received");
+       return 1;
+    }
+
+    writeNetInfo("/tmp/netinfo", &netDev, kd);
+
+    if (!(netDev.dev.set & PUMP_INTFINFO_HAS_NEXTSERVER)) {
+       logMessage("no bootserver was found");
+       return 1;
+    }
+
+    if (!(netDev.dev.set & PUMP_INTFINFO_HAS_BOOTFILE)) {
+       file = "/";
+       logMessage("bootp: no bootfile received");
+    } else {
+       file = netDev.dev.bootFile;
+    }
+
+    if (ksSource) {
+       ksPath = alloca(strlen(ksSource) + 1);
+       strcpy(ksPath, ksSource);
+    } else {
+       /*
+        * build the path to the kickstart file from the DHCP response
+        */
+       ksPath = alloca(strlen(file) + 
+                       strlen(inet_ntoa(netDev.dev.nextServer)) + 70);
+       strcpy(ksPath, inet_ntoa(netDev.dev.nextServer));
+       strcat(ksPath, file);
+    }
+
+    ptr = strchr(ksPath, '/');
+    if (ptr) {
+           file = strdup(ptr);
+    } else {
+           file = strdup("/");
+    }
+
+    /*
+     * peel off the web server name from the front of the string
+     */
+    server = strchr(ksPath, '/');
+    *server = 0;
+    server = ksPath;
+
+    /*
+     * get the kickstart file with http
+     */
+    if ((httpfd = httpGetFileDesc(server, 80, file)) < 0) {
+           logMessage("kickstartFromHTTP:httpGetFileDesc failed:httpfd
(%d)",
+                           httpfd);
+           free(file);
+           return(-1);
+    }
+
+    if ((ksfd = open(location, O_CREAT | O_RDWR, 0666)) < 0) {
+           logMessage("kickstartFromHTTP:open failed");
+           free(file);
+           return(-1);
+    }
+
+    while ((bytesread = read(httpfd, buf, sizeof(buf))) > 0) {
+           if (write(ksfd, buf, bytesread) != bytesread) {
+                   logMessage("kickstartFromHTTP:write failed:bytesread
(%d)",
+                       bytesread);
+           }
+    }
+
+    close(httpfd);
+    close(ksfd);
+
+    free(file);
+
+    return 0;
+}
+#endif
+
 int kickstartFromNfs(struct knownDevices * kd, char * location, 
                     moduleInfoSet modInfo, moduleList modLoaded, 
                     moduleDeps * modDepsPtr, int flags, char * ksSource,
@@ -2653,6 +2774,16 @@
 #endif
     
 #ifdef INCLUDE_NETWORK
+#ifdef SDSC
+    if (FL_KSHTTP(flags)) {
+       ksFile = "/tmp/ks.cfg";
+       startNewt(flags);
+       if (!kickstartFromHTTP(&kd, ksFile, modInfo, modLoaded, &modDeps,
+                             flags, ksSource, ksNetDevice))
+           flags |= LOADER_FLAGS_KICKSTART;
+    }
+#endif
+
     if (FL_KSNFS(flags)) {
        ksFile = "/tmp/ks.cfg";
        startNewt(flags);

===============================================
loader.h
===============================================
[bruno@frontend-0 loader]$ diff -uNr ../../../anaconda-7.1/loader/loader.h
loader.h
--- ../../../anaconda-7.1/loader/loader.h       Wed Apr  4 21:03:54 2001
+++ loader.h    Sat Jul 28 21:40:46 2001
@@ -25,6 +25,9 @@
 #define LOADER_FLAGS_NOFB               (1 << 19)
 #define LOADER_FLAGS_NOPCMCIA           (1 << 20)
 #define LOADER_FLAGS_RESCUE_NOMOUNT     (1 << 21)
+#ifdef SDSC
+#define LOADER_FLAGS_KSHTTP             (1 << 31)
+#endif
 
 #define FL_TESTING(a)      ((a) & LOADER_FLAGS_TESTING)
 #define FL_EXPERT(a)       ((a) & LOADER_FLAGS_EXPERT)
@@ -48,6 +51,9 @@
 #define FL_NOFB(a)          ((a) & LOADER_FLAGS_NOFB)
 #define FL_NOPCMCIA(a)     ((a) & LOADER_FLAGS_NOPCMCIA)
 #define FL_RESCUE_NOMOUNT(a) ((a) & LOADER_FLAGS_RESCUE_NOMOUNT)
+#ifdef SDSC
+#define FL_KSHTTP(a)       ((a) & LOADER_FLAGS_KSHTTP)
+#endif
 
 #define CODE_PCMCIA    1
Comment 1 Jeremy Katz 2001-08-02 18:30:01 EDT
Check out the beta released today (Roswell) as it actually already has support
for doing this :)

Note You need to log in before you can comment on or make changes to this bug.