Re: [PATCH] If ks=nfs:... is given, don't try to find the file via boot options (#480210).

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

 



From a code standpoint, looks fine to me.  Unable to test locally as well.

Chris Lumens wrote:
---
 loader/nfsinstall.c |  134 ++++++++++++++++++++++++++-------------------------
 1 files changed, 68 insertions(+), 66 deletions(-)

diff --git a/loader/nfsinstall.c b/loader/nfsinstall.c
index 087c478..1a81547 100644
--- a/loader/nfsinstall.c
+++ b/loader/nfsinstall.c
@@ -387,88 +387,90 @@ int getFileFromNfs(char * url, char * dest, struct loaderData_s * loaderData) {
     /* if they just did 'linux ks', they want us to figure it out from
      * the dhcp/bootp information
      */
-    g_type_init();
+    if (!url) {
+        g_type_init();
- client = nm_client_new();
-    if (!client) {
-        logMessage(CRITICAL, "%s (%d): failure creating NM proxy",
-                   __func__, __LINE__);
-        return 1;
-    }
-
-    state = nm_client_get_state(client);
-    if (state != NM_STATE_CONNECTED) {
-        logMessage(ERROR, "%s (%d): no active network devices",
-                   __func__, __LINE__);
-        g_object_unref(client);
-        return 1;
-    }
-
-    devices = nm_client_get_devices(client);
-    for (i = 0; i < devices->len; i++) {
-        NMDevice *candidate = g_ptr_array_index(devices, i);
-        const char *devname = nm_device_get_iface(candidate);
-        NMDHCP4Config *dhcp = NULL;
-        const char *server_name = NULL;
-        const char *filename = NULL;
-        struct in_addr addr;
-        char nextserver[INET_ADDRSTRLEN+1];
-
-        if (nm_device_get_state(candidate) != NM_DEVICE_STATE_ACTIVATED)
-            continue;
-
-        if (strcmp(iface.device, devname))
-            continue;
-
-        dhcp = nm_device_get_dhcp4_config(candidate);
-        if (!dhcp) {
-            logMessage(ERROR, "no boot options received by DHCP");
-            continue;
+        client = nm_client_new();
+        if (!client) {
+            logMessage(CRITICAL, "%s (%d): failure creating NM proxy",
+                       __func__, __LINE__);
+            return 1;
         }
- server_name = nm_dhcp4_config_get_one_option(dhcp, "server_name");
-        if (!server_name) {
-            logMessage(ERROR, "no bootserver was found");
+        state = nm_client_get_state(client);
+        if (state != NM_STATE_CONNECTED) {
+            logMessage(ERROR, "%s (%d): no active network devices",
+                       __func__, __LINE__);
             g_object_unref(client);
             return 1;
         }
- /* 'server_name' may be a hostname or an IPv4 address */
-        memset(&nextserver, '\0', sizeof(nextserver));
-        if (inet_pton(AF_INET, server_name, &addr) >= 1) {
-            strcpy(nextserver, server_name);
-        } else {
-            struct hostent *he = gethostbyname(server_name);
-            if (he != NULL) {
-                if (inet_ntop(AF_INET, he->h_addr_list[0],
-                              nextserver, INET_ADDRSTRLEN) == NULL) {
-                    memset(&nextserver, '\0', sizeof(nextserver));
+        devices = nm_client_get_devices(client);
+        for (i = 0; i < devices->len; i++) {
+            NMDevice *candidate = g_ptr_array_index(devices, i);
+            const char *devname = nm_device_get_iface(candidate);
+            NMDHCP4Config *dhcp = NULL;
+            const char *server_name = NULL;
+            const char *filename = NULL;
+            struct in_addr addr;
+            char nextserver[INET_ADDRSTRLEN+1];
+
+            if (nm_device_get_state(candidate) != NM_DEVICE_STATE_ACTIVATED)
+                continue;
+
+            if (strcmp(iface.device, devname))
+                continue;
+
+            dhcp = nm_device_get_dhcp4_config(candidate);
+            if (!dhcp) {
+                logMessage(ERROR, "no boot options received by DHCP");
+                continue;
+            }
+
+            server_name = nm_dhcp4_config_get_one_option(dhcp, "server_name");
+            if (!server_name) {
+                logMessage(ERROR, "no bootserver was found");
+                g_object_unref(client);
+                return 1;
+            }
+
+            /* 'server_name' may be a hostname or an IPv4 address */
+            memset(&nextserver, '\0', sizeof(nextserver));
+            if (inet_pton(AF_INET, server_name, &addr) >= 1) {
+                strcpy(nextserver, server_name);
+            } else {
+                struct hostent *he = gethostbyname(server_name);
+                if (he != NULL) {
+                    if (inet_ntop(AF_INET, he->h_addr_list[0],
+                                  nextserver, INET_ADDRSTRLEN) == NULL) {
+                        memset(&nextserver, '\0', sizeof(nextserver));
+                    }
                 }
             }
-        }
- filename = nm_dhcp4_config_get_one_option(dhcp, "filename");
-        if (filename == NULL) {
-             if (asprintf(&url, "%s:/kickstart/", nextserver) == -1) {
-                 logMessage(CRITICAL, "%s: %d: %m", __func__, __LINE__);
-                 abort();
-             }
+            filename = nm_dhcp4_config_get_one_option(dhcp, "filename");
+            if (filename == NULL) {
+                 if (asprintf(&url, "%s:/kickstart/", nextserver) == -1) {
+                     logMessage(CRITICAL, "%s: %d: %m", __func__, __LINE__);
+                     abort();
+                 }
- logMessage(ERROR, "bootp: no bootfile received");
-        } else {
-             if (asprintf(&url, "%s:%s", nextserver, filename) == -1) {
-                 logMessage(CRITICAL, "%s: %d: %m", __func__, __LINE__);
-                 abort();
-             }
+                logMessage(ERROR, "bootp: no bootfile received");
+            } else {
+                 if (asprintf(&url, "%s:%s", nextserver, filename) == -1) {
+                     logMessage(CRITICAL, "%s: %d: %m", __func__, __LINE__);
+                     abort();
+                 }
- logMessage(INFO, "bootp: bootfile is %s", filename);
+                logMessage(INFO, "bootp: bootfile is %s", filename);
+            }
+
+            break;
         }
- break;
+        g_object_unref(client);
     }
- g_object_unref(client);
-
     /* get the IP of the target system */
     if ((ip = iface_ip2str(loaderData->netDev, AF_INET)) == NULL) {
         logMessage(ERROR, "iface_ip2str returned NULL");


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

_______________________________________________
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