Hello community,

here is the log from the commit of package linuxrc for openSUSE:Factory checked 
in at 2014-07-02 15:04:31
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/linuxrc (Old)
 and      /work/SRC/openSUSE:Factory/.linuxrc.new (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "linuxrc"

Changes:
--------
--- /work/SRC/openSUSE:Factory/linuxrc/linuxrc.changes  2014-06-26 
08:00:56.000000000 +0200
+++ /work/SRC/openSUSE:Factory/.linuxrc.new/linuxrc.changes     2014-07-02 
15:04:39.000000000 +0200
@@ -1,0 +2,14 @@
+Wed Jul  2 08:01:51 CEST 2014 - [email protected]
+
+- check for a selection of 0 when returning from dia_list to choose the network
+  device (bnc #885231)
+- 4.2.38
+
+-------------------------------------------------------------------
+Tue Jul  1 11:29:55 CEST 2014 - [email protected]
+
+- move udev start script to /scripts dir
+- added new 'ifcfg' option to configure network
+- 4.2.37
+
+-------------------------------------------------------------------

Old:
----
  linuxrc-4.2.36.tar.xz

New:
----
  linuxrc-4.2.38.tar.xz

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ linuxrc.spec ++++++
--- /var/tmp/diff_new_pack.jLF2dj/_old  2014-07-02 15:04:40.000000000 +0200
+++ /var/tmp/diff_new_pack.jLF2dj/_new  2014-07-02 15:04:40.000000000 +0200
@@ -25,9 +25,9 @@
 Summary:        SUSE Installation Program
 License:        GPL-3.0+
 Group:          System/Boot
-Version:        4.2.36
+Version:        4.2.38
 Release:        0
-Source:         linuxrc-4.2.36.tar.xz
+Source:         linuxrc-4.2.38.tar.xz
 BuildRoot:      %{_tmppath}/%{name}-%{version}-build
 
 %description

++++++ linuxrc-4.2.36.tar.xz -> linuxrc-4.2.38.tar.xz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/linuxrc-4.2.36/VERSION new/linuxrc-4.2.38/VERSION
--- old/linuxrc-4.2.36/VERSION  2014-06-25 15:59:47.000000000 +0200
+++ new/linuxrc-4.2.38/VERSION  2014-07-02 08:01:43.000000000 +0200
@@ -1 +1 @@
-4.2.36
+4.2.38
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/linuxrc-4.2.36/changelog new/linuxrc-4.2.38/changelog
--- old/linuxrc-4.2.36/changelog        2014-06-25 15:59:49.000000000 +0200
+++ new/linuxrc-4.2.38/changelog        2014-07-02 08:01:45.000000000 +0200
@@ -1,4 +1,19 @@
-2014-06-25:    HEAD
+2014-07-02:    HEAD
+       - Merge pull request #10 from openSUSE/bnc885231
+       - Check for a selection of 0 when returning from dia_list to choose the 
network device
+       - Check for a selection of 0 when returning from dia_list to choose the 
network device.
+
+2014-07-01:    4.2.37
+       - move udev start script to /script dir
+       - added new 'ifcfg' option to configure network
+       - Simple examples are ifcfg=*=dhcp (configure all devices with dhcp) or
+       - ifcfg=eth0=10.0.1.1/24,10.0.1.254 (eth0: static setup, ip 10.0.1.1,
+       - netmask 255.255.255.0, gateway 10.0.1.254). See linuxrc docu for more.
+       - The main difference to the existing (old) network setup strategy is 
that
+       - 'ifcfg' just creates config files in /etc/sysconfig/network and runs 
wicked.
+       - It doesn't 'try' the config on every interface until one works.
+
+2014-06-25:    4.2.36
        - tag ibft interface as persistent
        - ignore ibft data if we can't find a matching interface (bnc #883712, 
bnc #874795)
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/linuxrc-4.2.36/file.c new/linuxrc-4.2.38/file.c
--- old/linuxrc-4.2.36/file.c   2014-06-24 10:25:13.000000000 +0200
+++ new/linuxrc-4.2.38/file.c   2014-06-27 11:55:08.000000000 +0200
@@ -308,6 +308,7 @@
   { key_wicked,         "Wicked",         kf_cfg + kf_cmd + kf_cmd_early },
   { key_withipoib,      "WithIPoIB",      kf_cfg + kf_cmd_early          },
   { key_upgrade,        "Upgrade",        kf_cfg + kf_cmd                },
+  { key_ifcfg,          "ifcfg",          kf_cfg + kf_cmd_early          },
 };
 
 static struct {
@@ -1648,6 +1649,10 @@
         if(f->is.numeric) config.upgrade = f->nvalue;
         break;
 
+      case key_ifcfg:
+        if(*f->value) slist_append_str(&config.ifcfg.list, f->value);
+        break;
+
       default:
         break;
     }
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/linuxrc-4.2.36/file.h new/linuxrc-4.2.38/file.h
--- old/linuxrc-4.2.36/file.h   2014-06-23 12:56:43.000000000 +0200
+++ new/linuxrc-4.2.38/file.h   2014-06-26 10:58:36.000000000 +0200
@@ -53,7 +53,7 @@
   key_osahwaddr, key_zen, key_zenconfig, key_udevrule, key_dhcpfail,
   key_namescheme, key_ptoptions, key_is_ptoption, key_withfcoe, key_digests,
   key_plymouth, key_sslcerts, key_restart, key_restarted, key_wicked, 
key_autoyast2,
-  key_withipoib, key_upgrade
+  key_withipoib, key_upgrade, key_ifcfg
 } file_key_t;
 
 typedef enum {
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/linuxrc-4.2.36/global.h new/linuxrc-4.2.38/global.h
--- old/linuxrc-4.2.36/global.h 2014-06-25 15:56:18.000000000 +0200
+++ new/linuxrc-4.2.38/global.h 2014-06-26 15:38:32.000000000 +0200
@@ -625,6 +625,12 @@
     } wlan;
   } net;
 
+  struct {
+    slist_t *list;             /* list of ifcfg options */
+    slist_t *initial;          /* list of initially setup network interfaces */
+  } ifcfg;
+
+
 #if defined(__s390__) || defined(__s390x__)
   /* hwcfg file parameters */
   struct {
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/linuxrc-4.2.36/linuxrc.c new/linuxrc-4.2.38/linuxrc.c
--- old/linuxrc-4.2.36/linuxrc.c        2014-06-24 10:55:54.000000000 +0200
+++ new/linuxrc-4.2.38/linuxrc.c        2014-07-01 11:20:54.000000000 +0200
@@ -879,16 +879,15 @@
     system("/sbin/insmod /modules/edd.ko 2>/dev/null");
   }
 
+  util_set_stderr(config.stderr_name);
+
   if(!config.test) {
-    fprintf(stderr, "Starting udev... ");
-    fflush(stderr);
-    system("/bin/myudevstart >/dev/null 2>&1");
-    fprintf(stderr, "ok\n");
-    unlink("/devz");   /* cf. util_mkdevs() */
+    printf("Starting udev... ");
+    fflush(stdout);
+    util_run_script("udev_setup");
+    printf("ok\n");
   }
 
-  util_set_stderr(config.stderr_name);
-
   if(config.had_segv) config.manual = 1;
 
   if(!config.test && !config.had_segv) {
@@ -1098,7 +1097,9 @@
     }
   }
 
-  net_setup_localhost();
+  net_write_initial_ifcfg();
+
+  util_run_script("network_setup");
 
   if(config.manual) file_read_info_file("cmdline", kf_cmd);
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/linuxrc-4.2.36/net.c new/linuxrc-4.2.38/net.c
--- old/linuxrc-4.2.36/net.c    2014-06-06 08:19:37.000000000 +0200
+++ new/linuxrc-4.2.38/net.c    2014-07-02 08:00:42.000000000 +0200
@@ -89,8 +89,9 @@
 static int net_dhcp6(void);
 
 static void net_ask_domain(void);
-static int write_ifcfg(void);
+static int write_ifcfg(char *device, slist_t *cfg);
 static char *inet2str(inet_t *inet, int type);
+static slist_t *ifcfg_split(char *ifcfg);
 
 
 /*
@@ -438,90 +439,6 @@
 
 
 /*
- * Configure loopback interface.
- */
-int net_setup_localhost()
-{
-    char                address_ti [20];
-    struct in_addr      ipaddr_ri;
-    int                 socket_ii;
-    struct ifreq        interface_ri;
-    struct sockaddr_in  sockaddr_ri;
-    int                 error_ii = FALSE;
-
-    if(config.test) return 0;
-
-    fprintf (stderr, "Setting up localhost...");
-    fflush (stdout);
-
-    if(!util_check_exist("/etc/hosts")) system("echo 127.0.0.1 localhost 
>/etc/hosts");
-
-    socket_ii = socket (AF_INET, SOCK_DGRAM, 0);
-    if (socket_ii == -1)
-        return (socket_ii);
-
-    memset (&interface_ri, 0, sizeof (struct ifreq));
-    strcpy (interface_ri.ifr_name, "lo");
-
-    sockaddr_ri.sin_family = AF_INET;
-    sockaddr_ri.sin_port = 0;
-    strcpy (address_ti, "127.0.0.1");
-    if (!inet_aton (address_ti, &ipaddr_ri))
-        error_ii = TRUE;
-    sockaddr_ri.sin_addr = ipaddr_ri;
-    memcpy (&interface_ri.ifr_addr, &sockaddr_ri, sizeof (sockaddr_ri));
-    if (ioctl (socket_ii, SIOCSIFADDR, &interface_ri) < 0)
-        {
-        HERE
-        error_ii = TRUE;
-        }
-
-    strcpy (address_ti, "255.0.0.0");
-    if (!inet_aton (address_ti, &ipaddr_ri))
-        error_ii = TRUE;
-    sockaddr_ri.sin_addr = ipaddr_ri;
-    memcpy (&interface_ri.ifr_netmask, &sockaddr_ri, sizeof (sockaddr_ri));
-    if (ioctl (socket_ii, SIOCSIFNETMASK, &interface_ri) < 0)
-        if (config.net.netmask.ip.s_addr)
-            {
-            HERE
-            error_ii = TRUE;
-            }
-
-    strcpy (address_ti, "127.255.255.255");
-    if (!inet_aton (address_ti, &ipaddr_ri))
-        error_ii = TRUE;
-    sockaddr_ri.sin_addr = ipaddr_ri;
-    memcpy (&interface_ri.ifr_broadaddr, &sockaddr_ri, sizeof (sockaddr_ri));
-    if (ioctl (socket_ii, SIOCSIFBRDADDR, &interface_ri) < 0)
-        if (config.net.broadcast.ip.s_addr != 0xffffffff)
-            {
-            HERE
-            error_ii = TRUE;
-            }
-
-    if (ioctl (socket_ii, SIOCGIFFLAGS, &interface_ri) < 0)
-        {
-        HERE
-        error_ii = TRUE;
-        }
-
-    interface_ri.ifr_flags |= IFF_UP | IFF_RUNNING | IFF_LOOPBACK | 
IFF_BROADCAST;
-    if (ioctl (socket_ii, SIOCSIFFLAGS, &interface_ri) < 0)
-        {
-        HERE
-        error_ii = TRUE;
-        }
-
-    close (socket_ii);
-
-  fprintf (stderr, "%s\n", error_ii ? "failure" : "done");
-
-  return error_ii;
-}
-
-
-/*
  * Setup network interface and write name server config.
  *
  * Return:
@@ -554,7 +471,7 @@
 
   if(!err4 || !err6) {
     net_setup_nameserver();
-    if(!config.net.dhcp_active) write_ifcfg();
+    if(!config.net.dhcp_active) write_ifcfg(NULL, NULL);
   }
 
   // at least one should have worked
@@ -1471,12 +1388,14 @@
   }
 #if defined(__s390__) || defined(__s390x__)
   else {
-    char path[PATH_MAX]="";
-    char *type;
-    sprintf(path, "/sys/class/net/%s/device/layer2", item_devs[choice - 1]);
-    type = util_get_attr(path);
-    if(!strncmp(type, "1", sizeof "1" )) {config.hwp.layer2=1; }
-    else {config.hwp.layer2=0;}
+    if(choice > 0) {
+      char path[PATH_MAX]="";
+      char *type;
+      sprintf(path, "/sys/class/net/%s/device/layer2", item_devs[choice - 1]);
+      type = util_get_attr(path);
+      if(!strncmp(type, "1", sizeof "1" )) {config.hwp.layer2=1; }
+      else {config.hwp.layer2=0;}
+    }
   }
 #endif
 
@@ -1908,7 +1827,7 @@
   char cmd[256], file[256];
   window_t win;
   int got_ip = 0, i, rc;
-  FILE *fp;
+  slist_t *cfg = NULL;
 
   if(config.net.dhcp_active || config.net.keep) return 0;
 
@@ -1928,12 +1847,9 @@
     fflush(stdout);
   }
 
-  snprintf(file, sizeof file, "/etc/sysconfig/network/ifcfg-%s", 
config.net.device);
-
-  fp = fopen(file, "w");
-  fprintf(fp, "BOOTPROTO='dhcp%s'\n", net_dhcp_type());
-  fprintf(fp, "STARTMODE='auto'\n");
-  fclose(fp);
+  cfg = slist_new();
+  strprintf(&cfg->key, "dhcp%s", net_dhcp_type());
+  write_ifcfg(config.net.device, cfg);
 
   net_apply_ethtool(config.net.device, config.net.hwaddr);
 
@@ -3094,110 +3010,254 @@
 }
 
 
-int write_ifcfg()
+/*
+ * Write ifcfg/ifroute files for device.
+ *
+ * - cfg may be a dhcp or static config
+ * - if device or cfg are NULL use current data from global config
+ * - if global config is used we always create a ***static*** config
+ */
+int write_ifcfg(char *device, slist_t *cfg)
 {
   char *fname, *s;
   FILE *fp, *fp2;
+  char *gw = NULL;     // static
+  char *ns = NULL;     // allocated
+  char *domain = NULL; // allocated
+  int global_values = 0;
+  int is_dhcp = 0;
+  slist_t *sl;
+  slist_t *sl_ifcfg = NULL;
+  slist_t *sl_ifroute = NULL;
 
   if(!config.wicked) return 0;
 
-  if(!config.net.device) return 0;
+  // use global values
+  if(!device || !cfg) global_values = 1;
 
-  if(!config.net.hostname.ok) return 0;
+  fprintf(stderr, "global = %d, cfg = %s\n", global_values, cfg ? cfg->key : 
"NULL");
 
-  // calculate prefix from netmask if missing
-  if(
-    config.net.hostname.ipv4 &&
-    !config.net.hostname.prefix4 &&
-    config.net.netmask.ok &&
-    config.net.netmask.ip.s_addr
-  ) {
-    int i = 1;
-    uint32_t u = ntohl(config.net.netmask.ip.s_addr);
+  if(global_values) {
+    device = config.net.device;
+
+    if(!config.net.hostname.ok) return 0;
+
+    // calculate prefix from netmask if missing
+    if(
+      config.net.hostname.ipv4 &&
+      !config.net.hostname.prefix4 &&
+      config.net.netmask.ok &&
+      config.net.netmask.ip.s_addr
+    ) {
+      int i = 1;
+      uint32_t u = ntohl(config.net.netmask.ip.s_addr);
 
-    while(u <<= 1) i++;
+      while(u <<= 1) i++;
 
-    if(config.debug) fprintf(stderr, "netmask to prefix: %d\n", i);
+      if(config.debug) fprintf(stderr, "netmask to prefix: %d\n", i);
 
-    config.net.hostname.prefix4 = i;
+      config.net.hostname.prefix4 = i;
+    }
   }
 
-  if(asprintf(&fname, "/etc/sysconfig/network/ifcfg-%s", config.net.device) == 
-1) fname = NULL;
+  if(!device) return 0;
 
-  if((fp = fopen(fname, "w"))) {
-    fprintf(fp, "BOOTPROTO='static'\n");
-    fprintf(fp, "STARTMODE='auto'\n");
+  // 1. maybe dhcp config, but only if passed explicitly
+  if(!global_values && !strncmp(cfg->key, "dhcp", sizeof "dhcp" - 1)) {
+    sl = slist_append(&sl_ifcfg, slist_new());
+    strprintf(&sl->key, "BOOTPROTO='%s'", cfg->key);
+    is_dhcp = 1;
+  }
 
-    if((s = inet2str(&config.net.hostname, 4))) {
-      fprintf(fp, "IPADDR='%s/%u'\n", s, config.net.hostname.prefix4);
+  // 2. create ifcfg entries
+
+  if(!is_dhcp) slist_append_str(&sl_ifcfg, "BOOTPROTO='static'");
+  slist_append_str(&sl_ifcfg, "STARTMODE='auto'");
+
+  if(!is_dhcp) {
+    if(global_values) {
+      char *ip1 = NULL, *ip2 = NULL;
+
+      if((s = inet2str(&config.net.hostname, 4))) {
+        if(asprintf(&ip1, "%s/%u", s, config.net.hostname.prefix4) == -1) ip1 
= NULL;
+      }
+
+      if((s = inet2str(&config.net.hostname, 6))) {
+        if(asprintf(&ip2, "%s/%u", s, config.net.hostname.prefix6) == -1) ip2 
= NULL;
+      }
+
+      if(ip1 && ip2) {
+        sl = slist_append(&sl_ifcfg, slist_new());
+        strprintf(&sl->key, "IPADDR_1='%s'", ip1);
+        sl = slist_append(&sl_ifcfg, slist_new());
+        strprintf(&sl->key, "IPADDR_2='%s'", ip2);
+      }
+      else {
+        if(!ip1) {
+          ip1 = ip2;
+          ip2 = NULL;
+        }
+        sl = slist_append(&sl_ifcfg, slist_new());
+        strprintf(&sl->key, "IPADDR='%s'", ip1);
+      }
+
+      free(ip1);
+      free(ip2);
+
+      // net_apply_ethtool()
+      // ETHTOOL_OPTIONS
     }
+    else {
+      int i;
+      slist_t *sl0, *sl1;
+      char *ip = cfg->key;
+
+      if((sl1 = cfg->next)) {
+        gw = sl1->key;
+        if((sl1 = sl1->next)) {
+          str_copy(&ns, sl1->key);
+          if((sl1 = sl1->next)) {
+            str_copy(&domain, sl1->key);
+            // extra stuff
+          }
+        }
+      }
 
-    if((s = inet2str(&config.net.hostname, 6))) {
-      fprintf(fp, "IPADDR='%s/%u'\n", s, config.net.hostname.prefix6);
+      sl0 = slist_split(' ', ip);
+
+      if(!sl0->next) {
+        sl = slist_append(&sl_ifcfg, slist_new());
+        strprintf(&sl->key, "IPADDR='%s'", sl0->key);
+      }
+      else {
+        for(i = 0, sl1 = sl0; sl1; sl1 = sl1->next) {
+          sl = slist_append(&sl_ifcfg, slist_new());
+          strprintf(&sl->key, "IPADDR_%d='%s'", ++i, sl1->key);
+        }
+      }
+    }
+  }
+
+  if(sl_ifcfg) {
+    if(asprintf(&fname, "/etc/sysconfig/network/ifcfg-%s", device) == -1) 
fname = NULL;
+    fprintf(stderr, "creating ifcfg-%s:\n", device);
+    if(fname && (fp = fopen(fname, "w"))) {
+      for(sl = sl_ifcfg; sl; sl = sl->next) {
+        fprintf(fp, "%s\n", sl->key);
+      }
+
+      fclose(fp);
     }
 
-    fclose(fp);
+    for(sl = sl_ifcfg; sl; sl = sl->next) {
+      fprintf(stderr, "  %s\n", sl->key);
+    }
+
+    free(fname);
   }
 
-  free(fname);
+  // 3. create ifroute entries
 
-  if(config.net.gateway.ok) {
-    if(asprintf(&fname, "/etc/sysconfig/network/ifroute-%s", 
config.net.device) == -1) fname = NULL;
+  if(!is_dhcp) {
+    if((global_values && config.net.gateway.ok) || gw) {
+      if(global_values) {
+        if((s = inet2str(&config.net.gateway, 4))) {
+          sl = slist_append(&sl_ifroute, slist_new());
+          strprintf(&sl->key, "default %s - %s", s, device);
+        }
 
-    if((fp = fopen(fname, "w"))) {
-      if((s = inet2str(&config.net.gateway, 4))) {
-        fprintf(fp, "default %s - %s\n", s, config.net.device);
+        if((s = inet2str(&config.net.gateway, 6))) {
+          sl = slist_append(&sl_ifroute, slist_new());
+          strprintf(&sl->key, "default %s - %s", s, device);
+        }
+      }
+      else {
+        sl = slist_append(&sl_ifroute, slist_new());
+        strprintf(&sl->key, "default %s - %s", gw, device);
       }
+    }
+  }
 
-      if((s = inet2str(&config.net.gateway, 6))) {
-        fprintf(fp, "default %s - %s\n", s, config.net.device);
+  if(sl_ifroute) {
+    if(asprintf(&fname, "/etc/sysconfig/network/ifroute-%s", device) == -1) 
fname = NULL;
+
+    fprintf(stderr, "creating ifroute-%s:\n", device);
+    if(fname && (fp = fopen(fname, "w"))) {
+      for(sl = sl_ifroute; sl; sl = sl->next) {
+        fprintf(fp, "%s\n", sl->key);
       }
 
       fclose(fp);
     }
 
+    for(sl = sl_ifroute; sl; sl = sl->next) {
+      fprintf(stderr, "  %s\n", sl->key);
+    }
+
     free(fname);
   }
 
-  if((fp = fopen("/etc/sysconfig/network/config", "r"))) {
-    if((fp2 = fopen("/etc/sysconfig/network/config.tmp", "w"))) {
-      char buf[1024];
-      unsigned u, first;
-
-      while(fgets(buf, sizeof buf, fp)) {
-        if(
-          !strncmp(buf, "NETCONFIG_DNS_STATIC_SEARCHLIST=", sizeof 
"NETCONFIG_DNS_STATIC_SEARCHLIST=" - 1) &&
-          config.net.domain
-        ) {
-          fprintf(fp2, "NETCONFIG_DNS_STATIC_SEARCHLIST=\"%s\"\n", 
config.net.domain);
-        }
-        else if(
-          !strncmp(buf, "NETCONFIG_DNS_STATIC_SERVERS=", sizeof 
"NETCONFIG_DNS_STATIC_SERVERS=" - 1) &&
-          config.net.nameserver[0].ok
-        ) {
-          fprintf(fp2, "NETCONFIG_DNS_STATIC_SERVERS=\"");
-          for(u = 0, first = 1; u < config.net.nameservers; u++) {
-            if(config.net.nameserver[u].ok) {
-              fprintf(fp2, "%s%s", first ? "" : " ", 
config.net.nameserver[u].name);
-              first = 0;
-            }
+  // 4. set nameserver and search list
+
+  if(!is_dhcp) {
+    if(global_values) {
+      str_copy(&domain, config.net.domain);
+      if(config.net.nameserver[0].ok) {
+        unsigned u, first;
+
+        for(u = 0, first = 1; u < config.net.nameservers; u++) {
+          if(config.net.nameserver[u].ok) {
+            strprintf(&ns, "%s%s%s", ns ?: "", first ? "" : " ", 
config.net.nameserver[u].name);
+            first = 0;
           }
-          fprintf(fp2, "\"\n");
-        }
-        else {
-          fputs(buf, fp2);
         }
       }
-
-      fclose(fp2);
     }
 
-    fclose(fp);
+    if(ns || domain) {
+      fprintf(stderr, "adjusting network/config:\n");
+      if(ns) fprintf(stderr, "  NETCONFIG_DNS_STATIC_SERVERS=\"%s\"\n", ns);
+      if(domain) fprintf(stderr, "  NETCONFIG_DNS_STATIC_SEARCHLIST=\"%s\"\n", 
domain);
+
+      if((fp = fopen("/etc/sysconfig/network/config", "r"))) {
+        if((fp2 = fopen("/etc/sysconfig/network/config.tmp", "w"))) {
+          char buf[1024];
+
+          while(fgets(buf, sizeof buf, fp)) {
+            if(
+              domain &&
+              !strncmp(buf, "NETCONFIG_DNS_STATIC_SEARCHLIST=", sizeof 
"NETCONFIG_DNS_STATIC_SEARCHLIST=" - 1)
+            ) {
+              fprintf(fp2, "NETCONFIG_DNS_STATIC_SEARCHLIST=\"%s\"\n", domain);
+            }
+            else if(
+              ns &&
+              !strncmp(buf, "NETCONFIG_DNS_STATIC_SERVERS=", sizeof 
"NETCONFIG_DNS_STATIC_SERVERS=" - 1)
+            ) {
+              fprintf(fp2, "NETCONFIG_DNS_STATIC_SERVERS=\"%s\"\n", ns);
+            }
+            else {
+              fputs(buf, fp2);
+            }
+          }
+
+          fclose(fp2);
+        }
 
-    rename("/etc/sysconfig/network/config.tmp", 
"/etc/sysconfig/network/config");
+        fclose(fp);
+
+        rename("/etc/sysconfig/network/config.tmp", 
"/etc/sysconfig/network/config");
+      }
+    }
   }
 
-  return 0;
+  str_copy(&ns, NULL);
+  str_copy(&domain, NULL);
+
+  slist_free(sl_ifcfg);
+  slist_free(sl_ifroute);
+
+  return 1;
 }
 
 
@@ -3215,3 +3275,101 @@
   return t;
 }
 
+
+/*
+ *
+ */
+#if 0
+ifcfg=10.10.0.1/24;10.10.0.254;10.10.1.1;suse.de
+ifcfg=dhcp
+ifcfg=eth*=10.10.0.1/24;10.10.0.254;10.10.1.1;suse.de
+ifcfg=eth*=dhcp
+#endif
+void net_write_initial_ifcfg()
+{
+  slist_t *sl, *sl1;
+  int matched;
+  hd_t *net_list, *hd;
+  hd_res_t *res;
+  char *device, *hwaddr, *type;
+
+  // this file always exists
+  slist_append_str(&config.ifcfg.initial, "lo");
+
+  if(!config.ifcfg.list) return;
+
+  update_device_list(0);
+  net_list = hd_list(config.hd_data, hw_network_ctrl, 0, NULL);
+
+  for(hd = net_list; hd; hd = hd->next) {
+    for(hwaddr = NULL, res = hd->res; res; res = res->next) {
+      if(res->any.type == res_hwaddr) {
+        hwaddr = res->hwaddr.addr;
+        break;
+      }
+    }
+
+    for(sl = config.ifcfg.list; sl; sl = sl->next) {
+      if(sl->value) continue;          // already used
+      sl1 = ifcfg_split(sl->key);
+      device = slist_key(sl1, 0);
+      type = slist_key(sl1, 1);
+      if(!type) continue;
+      matched = 0;
+      if(device && *device) {
+        matched = match_netdevice(hd->unix_dev_name, hwaddr, device);
+      }
+
+      if(matched) {
+        // static config may be used only once
+        if(!type || strncmp(type, "dhcp", sizeof "dhcp" - 1)) sl->value = 
strdup("");
+
+        if(write_ifcfg(hd->unix_dev_name, sl1->next)) {
+          slist_append_str(&config.ifcfg.initial, hd->unix_dev_name);
+          printf("%s: network config created\n", hd->unix_dev_name);
+        }
+        else {
+          printf("%s: failed to create network config\n", hd->unix_dev_name);
+        }
+      }
+
+      slist_free(sl1);
+    }
+  }
+
+  hd_free_hd_list(net_list);
+}
+
+
+slist_t *ifcfg_split(char *ifcfg)
+{
+  slist_t *sl, *sl0;
+
+  if(!ifcfg) return NULL;
+
+  // fprintf(stderr, "ifcfg split: %s\n", ifcfg);
+
+  sl0 = slist_new();
+  sl0->next = sl = slist_split(',', ifcfg);
+
+  if(sl) {
+    char *t;
+    if((t = strchr(sl->key, '='))) {
+      *t++ = 0;
+      sl0->key = sl->key;
+      sl->key = strdup(t);
+    }
+    else {
+      sl0->key = strdup("");
+    }
+  }
+
+#if 0
+  for(sl = sl0; sl; sl = sl->next) {
+    fprintf(stderr, "  >%s<<\n", sl->key);
+  }
+#endif
+
+  return sl0;
+}
+
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/linuxrc-4.2.36/net.h new/linuxrc-4.2.38/net.h
--- old/linuxrc-4.2.36/net.h    2014-05-20 10:55:55.000000000 +0200
+++ new/linuxrc-4.2.38/net.h    2014-06-30 15:15:56.000000000 +0200
@@ -14,7 +14,6 @@
 void net_smb_get_mount_options(char *options, inet_t *server, char *user, char 
*password, char *workgroup);
 void net_stop(void);
 int net_check_address(inet_t *inet, int do_dns);
-int net_setup_localhost(void);
 int net_activate_ns(void);
 int net_activate_s390_devs(void);
 int net_dhcp(void);
@@ -26,3 +25,4 @@
 void net_apply_ethtool(char *device, char *hwaddr);
 int wlan_setup(void);
 char *net_dhcp_type(void);
+void net_write_initial_ifcfg(void);
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/linuxrc-4.2.36/util.c new/linuxrc-4.2.38/util.c
--- old/linuxrc-4.2.36/util.c   2014-06-25 15:56:54.000000000 +0200
+++ new/linuxrc-4.2.38/util.c   2014-06-27 11:32:43.000000000 +0200
@@ -2267,6 +2267,19 @@
 
 
 /*
+ * return index-th key
+ */
+char *slist_key(slist_t *sl, int index)
+{
+  while(sl && index-- > 0) {
+    sl = sl->next;
+  }
+
+  return sl ? sl->key : NULL;
+}
+
+
+/*
  * Clear 'inet' und add 'name' to it.
  *
  * 'inet' is unchanged if 'name' is NULL.
@@ -3803,7 +3816,7 @@
 
   if(!config.hd_data) force = 1;
 
-  if(stat("/dev/.udev/uevent_seqnum", &sbuf)) {
+  if(stat("/run/udev/queue.bin", &sbuf)) {
     force = 1;
   }
   else if(last_time != sbuf.st_mtime) {
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/linuxrc-4.2.36/util.h new/linuxrc-4.2.38/util.h
--- old/linuxrc-4.2.36/util.h   2014-04-24 14:35:53.000000000 +0200
+++ new/linuxrc-4.2.38/util.h   2014-06-27 11:32:38.000000000 +0200
@@ -62,6 +62,7 @@
 slist_t *slist_sort(slist_t *sl0, int (*cmp_func)(const void *, const void *));
 slist_t *slist_split(char del, char *text);
 char *slist_join(char *del, slist_t *str);
+char *slist_key(slist_t *sl, int index);
 
 char *util_attach_loop(char *file, int ro);
 int util_detach_loop(char *dev);

-- 
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to