[PATCH 1/3] Configure network in kickstartNetworkUp() iff NM is not connected (#490518)

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

 



In kickstartNetworkUp(), call is_nm_connected() to see if we are in
NM_STATE_CONNECTED.  If we are in any other state, prompt for network
configuration and start NetworkManager.
---
 isys/iface.c |   20 ++++++++++++++++++++
 isys/iface.h |    6 ++++++
 loader/net.c |    3 +++
 3 files changed, 29 insertions(+), 0 deletions(-)

diff --git a/isys/iface.c b/isys/iface.c
index 1df5fa0..1371802 100644
--- a/isys/iface.c
+++ b/isys/iface.c
@@ -356,6 +356,26 @@ int iface_have_in6_addr(struct in6_addr *addr6) {
     return _iface_have_valid_addr(addr6, AF_INET6, INET6_ADDRSTRLEN);
 }
 
+/* Check if NM has an active connection */
+gboolean is_nm_connected(void) {
+    NMState state;
+    NMClient *client = NULL;
+
+    g_type_init();
+
+    client = nm_client_new();
+    if (!client)
+        return FALSE;
+
+    state = nm_client_get_state(client);
+    g_object_unref(client);
+
+    if (state == NM_STATE_CONNECTED)
+        return TRUE;
+    else
+        return FALSE;
+}
+
 /* Check if NM is already running */
 gboolean is_nm_running(void) {
     gboolean running;
diff --git a/isys/iface.h b/isys/iface.h
index c95c39b..16257bc 100644
--- a/isys/iface.h
+++ b/isys/iface.h
@@ -26,6 +26,7 @@
 #include <net/if.h>
 #include <netlink/cache.h>
 #include <netlink/socket.h>
+#include <glib.h>
 
 /* Enumerated types used in iface.c as well as loader's network code */
 enum { IPUNUSED, IPV4, IPV6 };
@@ -141,6 +142,11 @@ int iface_have_in_addr(struct in_addr *addr);
 int iface_have_in6_addr(struct in6_addr *addr6);
 
 /*
+ * Checks if NetworkManager has an active connection.
+ */
+gboolean is_nm_connected(void);
+
+/*
  * Start NetworkManager
  */
 int iface_start_NetworkManager(void);
diff --git a/loader/net.c b/loader/net.c
index 3a3fae9..47e2346 100644
--- a/loader/net.c
+++ b/loader/net.c
@@ -1893,6 +1893,9 @@ int chooseNetworkInterface(struct loaderData_s * loaderData) {
 int kickstartNetworkUp(struct loaderData_s * loaderData, iface_t * iface) {
     int rc, err;
 
+    if (is_nm_connected() == TRUE)
+        return 0;
+
     memset(iface, 0, sizeof(*iface));
 
     do {
-- 
1.6.2.2

_______________________________________________
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