summaryrefslogtreecommitdiffstats
path: root/loader
diff options
context:
space:
mode:
authorDavid Cantrell <dcantrell@redhat.com>2008-08-26 12:30:26 -1000
committerDavid Cantrell <dcantrell@redhat.com>2008-08-26 12:32:54 -1000
commit25f58fe7c701c453d39d2a9c5c0850eefce07f76 (patch)
treeb0c827c574c4462ee9a1af7436e078d6651ce112 /loader
parent8adc2377152affd70c7befec786950db0f97f2a9 (diff)
downloadanaconda-25f58fe7c701c453d39d2a9c5c0850eefce07f76.tar.gz
anaconda-25f58fe7c701c453d39d2a9c5c0850eefce07f76.tar.xz
anaconda-25f58fe7c701c453d39d2a9c5c0850eefce07f76.zip
Write to /etc/sysconfig/network-scripts/ifcfg-INTERFACE
Stop using /tmp/netinfo throughout the installer. Since we are using NetworkManager (and by extension, nm-system-settings), write static configuration info to /etc/sysconfig/network-scripts/ifcfg-INTERFACE.
Diffstat (limited to 'loader')
-rw-r--r--loader/linuxrc.s39023
-rw-r--r--loader/loader.c81
2 files changed, 85 insertions, 19 deletions
diff --git a/loader/linuxrc.s390 b/loader/linuxrc.s390
index 7facd3b19..395364795 100644
--- a/loader/linuxrc.s390
+++ b/loader/linuxrc.s390
@@ -609,7 +609,14 @@ EOF
# immediately read it in again to export these into the shell below
. /tmp/install.cfg
cat /tmp/install.cfg >> /etc/profile
-cat > /tmp/netinfo << EOF
+
+NETSCRIPTS="/etc/sysconfig/network-scripts"
+IFCFGFILE="$NETSCRIPTS/ifcfg-$DEVICE"
+if [ ! -d "$NETSCRIPTS" ]; then
+ mkdir -p $NETSCRIPTS
+fi
+
+cat > $IFCFGFILE << EOF
DEVICE=$DEVICE
ONBOOT=yes
BOOTPROTO=static
@@ -621,13 +628,13 @@ HOSTNAME=$HOSTNAME
MTU=$MTU
SUBCHANNELS=$SUBCHANNELS
EOF
-[ "$DNS" != "" ] && echo "DNS=`echo $DNS | cut -d ':' -f 1`" >> /tmp/netinfo
-[ "$NETTYPE" != "" ] && echo "NETTYPE=$NETTYPE" >> /tmp/netinfo
-[ "$PEERID" != "" ] && echo "PEERID=$PEERID" >> /tmp/netinfo
-[ "$PORTNAME" != "" ] && echo "PORTNAME=$PORTNAME" >> /tmp/netinfo
-[ "$CTCPROT" != "" ] && echo "CTCPROT=$CTCPROT" >> /tmp/netinfo
-[ "$LAYER2" != "" ] && echo "LAYER2=$LAYER2" >> /tmp/netinfo
-[ "$MACADDR" != "" ] && echo "MACADDR=$MACADDR" >> /tmp/netinfo
+[ "$DNS" != "" ] && echo "DNS=`echo $DNS | cut -d ':' -f 1`" >> $IFCFGFILE
+[ "$NETTYPE" != "" ] && echo "NETTYPE=$NETTYPE" >> $IFCFGFILE
+[ "$PEERID" != "" ] && echo "PEERID=$PEERID" >> $IFCFGFILE
+[ "$PORTNAME" != "" ] && echo "PORTNAME=$PORTNAME" >> $IFCFGFILE
+[ "$CTCPROT" != "" ] && echo "CTCPROT=$CTCPROT" >> $IFCFGFILE
+[ "$LAYER2" != "" ] && echo "LAYER2=$LAYER2" >> $IFCFGFILE
+[ "$MACADDR" != "" ] && echo "MACADDR=$MACADDR" >> $IFCFGFILE
# so that the vars get propagated into the sshd shells
mkdir /.ssh
diff --git a/loader/loader.c b/loader/loader.c
index 2aceea601..a4d4e4e88 100644
--- a/loader/loader.c
+++ b/loader/loader.c
@@ -42,6 +42,7 @@
#include <syslog.h>
#include <unistd.h>
#include <stdint.h>
+#include <dirent.h>
#include <arpa/inet.h>
#include <sys/ioctl.h>
@@ -596,22 +597,70 @@ static void writeVNCPasswordFile(char *pfile, char *password) {
fclose(f);
}
-/* read information from /tmp/netinfo (written by linuxrc) */
+/* XXX: read information from /etc/sysconfig/network-scripts/ifcfg-$INTERFACE
+ * (written by linuxrc), the linuxrc mess should be firing up NM too
+ */
static void readNetInfo(struct loaderData_s ** ld) {
int i;
struct loaderData_s * loaderData = *ld;
- FILE *f;
- /* FIXME: arbitrary size that works, but could blow up in the future */
+ DIR *dp = NULL;
+ FILE *f = NULL;
+ struct dirent *ent = NULL;
+ char *cfgfile = NULL;
int bufsiz = 100;
- char buf[bufsiz], *vname, *vparm;
+ char buf[bufsiz];
+ char *vname = NULL;
+ char *vparm = NULL;
+
+ /* when this function is called, we can assume only one network device
+ * config file has been written to /etc/sysconfig/network-scripts, so
+ * find it and read it
+ */
+ dp = opendir("/etc/sysconfig/network-scripts");
+ if (dp == NULL) {
+ return;
+ }
+
+ while ((ent = readdir(dp)) != NULL) {
+ if (!strncmp(ent->d_name, "ifcfg-", 6)) {
+ if (asprintf(&cfgfile, "/etc/sysconfig/network-scripts/%s",
+ ent->d_name) == -1) {
+ logMessage(DEBUGLVL, "%s (%d): %m", __func__, __LINE__);
+ abort();
+ }
- f = fopen("/tmp/netinfo", "r");
- if (!f)
+ break;
+ }
+ }
+
+ if (dp != NULL) {
+ if (closedir(dp) == -1) {
+ logMessage(DEBUGLVL, "%s (%d): %m", __func__, __LINE__);
+ abort();
+ }
+ }
+
+ if (cfgfile == NULL) {
+ logMessage(DEBUGLVL, "no ifcfg files found in /etc/sysconfig/network-scripts");
return;
+ }
- /* FIXME: static buffers lead to pain */
- vname = (char *)malloc(sizeof(char)*15);
- vparm = (char *)malloc(sizeof(char)*85);
+
+ if ((f = fopen(cfgfile, "r")) == NULL) {
+ logMessage(DEBUGLVL, "%s (%d): %m", __func__, __LINE__);
+ free(cfgfile);
+ return;
+ }
+
+ if ((vname = (char *) malloc(sizeof(char) * 15)) == NULL) {
+ logMessage(DEBUGLVL, "%s (%d): %m", __func__, __LINE__);
+ abort();
+ }
+
+ if ((vparm = (char *) malloc(sizeof(char) * 85)) == NULL) {
+ logMessage(DEBUGLVL, "%s (%d): %m", __func__, __LINE__);
+ abort();
+ }
/* make sure everything is NULL before we begin copying info */
loaderData->ipv4 = NULL;
@@ -701,10 +750,20 @@ static void readNetInfo(struct loaderData_s ** ld) {
}
}
- if (loaderData->ipv4 && loaderData->netmask)
+ if (loaderData->ipv4 && loaderData->netmask) {
flags |= LOADER_FLAGS_HAVE_CMSCONF;
+ }
- fclose(f);
+ if (fclose(f) == -1) {
+ logMessage(ERROR, "%s: %d: %m", __func__, __LINE__);
+ abort();
+ }
+
+ if (cfgfile != NULL) {
+ free(cfgfile);
+ }
+
+ return;
}
/* parse anaconda or pxelinux-style ip= arguments