From 267339cd5c7b903facb2c6b36dca1f380cd536e1 Mon Sep 17 00:00:00 2001 From: CentOS Sources Date: Mar 05 2015 13:13:56 +0000 Subject: import netcf-0.2.6-3.el7 --- diff --git a/.gitignore b/.gitignore index be2831c..9506fd9 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1 @@ -SOURCES/netcf-0.2.3.tar.gz +SOURCES/netcf-0.2.6.tar.gz diff --git a/.netcf.metadata b/.netcf.metadata index 7ad09a9..2ba5475 100644 --- a/.netcf.metadata +++ b/.netcf.metadata @@ -1 +1 @@ -deeaf0204e4f32867362a4c64e23f80564bec1aa SOURCES/netcf-0.2.3.tar.gz +6a82d86efe821a64ac157837ba895a54edef7105 SOURCES/netcf-0.2.6.tar.gz diff --git a/SOURCES/netcf-Better-messages-on-failure-reading-sys-class-net-dev.patch b/SOURCES/netcf-Better-messages-on-failure-reading-sys-class-net-dev.patch new file mode 100644 index 0000000..ab3451f --- /dev/null +++ b/SOURCES/netcf-Better-messages-on-failure-reading-sys-class-net-dev.patch @@ -0,0 +1,73 @@ +From 2e2fabd1acc704b938f7a0df1b091efd68d58072 Mon Sep 17 00:00:00 2001 +From: Laine Stump +Date: Mon, 26 Jan 2015 16:22:35 -0500 +Subject: [PATCH 1/2] Better messages on failure reading + /sys/class/net/$dev/(operstate|speed) + +add_link_info() sets an error message when it fails to read +/sys/class/net/$dev/operstate, but unfortunately frees the path string +just prior to setting the error message, so the error string has +"(null)" instead (thanks to glibc's asprintf noticing the null +pointer). + +Additionally, the macro used to create the log message, +ERR_THROW_STRERROR() already turns errno into a string in the locally +defined errbuf, but we aren't including it in the format string, so it +doesn't get printed. + +This patch makes sure the path isn't freed until it is really no +longer needed, and adds errbuf to the log message. + +This will hopefully help to find the root cause of + + https://bugzilla.redhat.com/show_bug.cgi?id=1185850 + +(cherry picked from commit 60772fefee8eb6ef5d34ba8f0bc36d4ea7a6fc01) +--- + src/dutil_linux.c | 10 ++++++---- + 1 file changed, 6 insertions(+), 4 deletions(-) + +diff --git a/src/dutil_linux.c b/src/dutil_linux.c +index d2bbef4..52a7299 100644 +--- a/src/dutil_linux.c ++++ b/src/dutil_linux.c +@@ -1,7 +1,7 @@ + /* + * dutil_linux.c: Linux utility functions for driver backends. + * +- * Copyright (C) 2009-2012, 2014 Red Hat Inc. ++ * Copyright (C) 2009-2012, 2014-2015 Red Hat Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public +@@ -1040,14 +1040,15 @@ static void add_link_info(struct netcf *ncf, + xasprintf(&path, "/sys/class/net/%s/operstate", ifname); + ERR_NOMEM(!path, ncf); + state = read_file(path, &length); +- FREE(path); +- ERR_THROW_STRERROR(!state, ncf, EFILE, "Failed to read %s", path); ++ ERR_THROW_STRERROR(!state, ncf, EFILE, "Failed to read %s : %s", ++ path, errbuf); + if ((nl = strchr(state, '\n'))) + *nl = 0; + prop = xmlSetProp(link_node, BAD_CAST "state", BAD_CAST state); + ERR_NOMEM(!prop, ncf); + + if (!strcmp(state, "up")) { ++ FREE(path); + xasprintf(&path, "/sys/class/net/%s/speed", ifname); + ERR_NOMEM(path == NULL, ncf); + speed = read_file(path, &length); +@@ -1059,7 +1060,8 @@ static void add_link_info(struct netcf *ncf, + speed = strdup("0"); + ERR_NOMEM(!speed, ncf); + } +- ERR_THROW_STRERROR(!speed, ncf, EFILE, "Failed to read %s", path); ++ ERR_THROW_STRERROR(!speed, ncf, EFILE, "Failed to read %s : %s", ++ path, errbuf); + if ((nl = strchr(speed, '\n'))) + *nl = 0; + } else { +-- +1.8.3.1 + diff --git a/SOURCES/netcf-Don-t-return-error-if-sys-class-net-dev-operstate-is.patch b/SOURCES/netcf-Don-t-return-error-if-sys-class-net-dev-operstate-is.patch new file mode 100644 index 0000000..ca4824c --- /dev/null +++ b/SOURCES/netcf-Don-t-return-error-if-sys-class-net-dev-operstate-is.patch @@ -0,0 +1,53 @@ +From 64fcd67471ead7a0205f853a32eece6de4d7436b Mon Sep 17 00:00:00 2001 +From: Laine Stump +Date: Tue, 27 Jan 2015 11:46:10 -0500 +Subject: [PATCH 2/2] Don't return error if /sys/class/net/$dev/operstate isn't + found + +This can happen for alias "interfaces", e.g: "eth0:1" (which aren't +really an interface, but are a deprecated method of adding multiple IP +addresses to a single interface). Since only the base interface +("eth0") is really a device, only it has an entry in /sys/class/net. + +It's not important that such interfaces have truly meaningful +information in their element (as we don't really have any truly +meaningful state, and haven't historically provided other status for +alias interfaces (e.g. IP address). What *is* important is that we +don't return an error, as this breaks applications that rely on being +able to get back a successful (if empty) status for any interface +listed. + +This resolves the regression with virt-manager described here: + + https://bugzilla.redhat.com/show_bug.cgi?id=1185850 + +(cherry picked from commit 4d5d84bdec17dbb267b5e038fa649af9d730bda9) +--- + src/dutil_linux.c | 11 +++++++++-- + 1 file changed, 9 insertions(+), 2 deletions(-) + +diff --git a/src/dutil_linux.c b/src/dutil_linux.c +index 52a7299..a8788b6 100644 +--- a/src/dutil_linux.c ++++ b/src/dutil_linux.c +@@ -1040,8 +1040,15 @@ static void add_link_info(struct netcf *ncf, + xasprintf(&path, "/sys/class/net/%s/operstate", ifname); + ERR_NOMEM(!path, ncf); + state = read_file(path, &length); +- ERR_THROW_STRERROR(!state, ncf, EFILE, "Failed to read %s : %s", +- path, errbuf); ++ if (!state) { ++ /* missing operstate is *not* an error. It could be due to an ++ * alias interface, which has no entry in /sys/class/net at ++ * all, for example. This is similar to the situation where we ++ * can't find an ifindex in add_ethernet_info(). ++ */ ++ state = strdup(""); ++ ERR_NOMEM(!state, ncf); ++ } + if ((nl = strchr(state, '\n'))) + *nl = 0; + prop = xmlSetProp(link_node, BAD_CAST "state", BAD_CAST state); +-- +1.8.3.1 + diff --git a/SOURCES/netcf-Recognize-IPADDR0-PREFIX0-NETMASK0-GATEWAY0-in-redha.patch b/SOURCES/netcf-Recognize-IPADDR0-PREFIX0-NETMASK0-GATEWAY0-in-redha.patch new file mode 100644 index 0000000..0b9e2ad --- /dev/null +++ b/SOURCES/netcf-Recognize-IPADDR0-PREFIX0-NETMASK0-GATEWAY0-in-redha.patch @@ -0,0 +1,237 @@ +From 0015f8e8615458deac78cc3172b74c2983dbaaab Mon Sep 17 00:00:00 2001 +From: Laine Stump +Date: Thu, 30 Oct 2014 11:45:23 -0400 +Subject: [PATCH 2/2] Recognize IPADDR0/PREFIX0/NETMASK0/GATEWAY0 in redhat and + suse backends + +(another case of explanation taking longer than the patch...) + +This resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1147650 + +The redhat and suse backends for netcf convert from a raw xml-ized +representation of ifcfg file contents (produced by augeas) to the + xml element known by libvirt using two xsl stylesheets: + + data/xml/redhat-put.xsl + data/xml/suse-put.xsl + +(I am personally interested in redhat-put.xsl, but am making the patch +described below to suse-put.xsl as well since the files are nearly +identical). + +Examples of the "raw" xml can be seen in +tests/redhat/schema/*.xml. Basically each ifcfg setting is in an +element called "node", e.g: + + + + +The issue is that while the netcf stylesheets were written to use +IPADDR/PREFIX/NETMASK/GATEWAY, in certain versions of NetworkManager +(e.g. the version that is in RHEL7, but *not* the version that is in +Fedora 20) NetworkManager uses IPADDR0, PREFIX0, and GATEWAY0 to store +the interface IPv4 info, rather than IPADDR, PREFIX, and GATEWAY (In +those cases, it will still recognize IPADDR/PREFIX/GATEWAY, but when +it saves anything, it uses IPADDR0/PREFIX0/GATEWAY0). Initscripts, on +the other hand, recognizes IPADDR0 and PREFIX0, but doesn't understand +GATEWAY0, it only sees GATEWAY. + +The problem with the above comes when we do a dumpxml of an interface +created by NM (or anaconda, the Fedora installer, which also uses +IPADDR0), or worse yet when libvirt's virsh utility puts a bridge on +an ethernet by getting the current XML, modifying it, then writing +back the new config - since netcf doesn't see IPADDR0, the +element is empty in the original retrieved xml, and thus when the new +bridge interface is defined, it has no IP address info. + +The solution to this is to improve the *-put.xsl to recognize either +the old form *or* the ${var}0 form when converting into +XML. For maximum compatibility, the conversion back into ifcfg format +is left the same, as all versions of initscripts and NetworkManager +that I've tried continue to recognize them. + +Beyond what is done here, both NM and initscripts recognize IPADDRn +where "n" can be any number up to 255, and since we support multiple +IPv6 addresses in netcf, I would like to support multiple IPv4 +addresses as well. That is left for a future patch, as my XSL skills +simply are not up to that task (patches welcome!) + +(cherry picked from commit c0e7734cb3c616c102cfff4ce1aeee023e85659a) +--- + data/xml/redhat-put.xsl | 61 +++++++++++++++++++++++++++++++++++++------------ + data/xml/suse-put.xsl | 61 +++++++++++++++++++++++++++++++++++++------------ + 2 files changed, 94 insertions(+), 28 deletions(-) + +diff --git a/data/xml/redhat-put.xsl b/data/xml/redhat-put.xsl +index 579da12..ed800d6 100644 +--- a/data/xml/redhat-put.xsl ++++ b/data/xml/redhat-put.xsl +@@ -183,7 +183,8 @@ + + ++ select="count(node[@label = 'IPADDR']) + ++ count(node[@label = 'IPADDR0']) > 0"/> + + + +@@ -196,25 +197,57 @@ + + + +- +- +- +- +- +- +- +- +- +- +- +- +- ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ + + + + + + ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ + + + +diff --git a/data/xml/suse-put.xsl b/data/xml/suse-put.xsl +index f3903a2..7dd739a 100644 +--- a/data/xml/suse-put.xsl ++++ b/data/xml/suse-put.xsl +@@ -176,7 +176,8 @@ + + ++ select="count(node[@label = 'IPADDR']) + ++ count(node[@label = 'IPADDR0']) > 0"/> + + + +@@ -189,25 +190,57 @@ + + + +- +- +- +- +- +- +- +- +- +- +- +- +- ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ + + + + + + ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ + + + +-- +1.8.3.1 + diff --git a/SOURCES/netcf-Report-file-path-and-reason-when-aug_save-fails.patch b/SOURCES/netcf-Report-file-path-and-reason-when-aug_save-fails.patch new file mode 100644 index 0000000..11c6e4d --- /dev/null +++ b/SOURCES/netcf-Report-file-path-and-reason-when-aug_save-fails.patch @@ -0,0 +1,272 @@ +From 797bbe64030eb9146ae43fe0a14383bfc9c44a21 Mon Sep 17 00:00:00 2001 +From: Dominic Cleal +Date: Fri, 5 Sep 2014 09:21:18 +0100 +Subject: [PATCH 1/2] Report file path and reason when aug_save fails + +Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1138196 + +When aug_save fails, the /augeas metadata tree is now searched to find +a possible reason for the failure and an error is raised containing +the file path, Augeas error code (pointing to the action that failed) +and the message if supplied (from strerror). + +A failure to unlink a file now results in a message such as: + + error: unspecified error + error: aug_save failed on /etc/sysconfig/network-scripts/ifcfg-em1: + unlink_orig (Permission denied) + +Multiple failures aren't reported in detail, but will be printed if debug is +enabled. + +(cherry picked from commit 2c14cc1bccbe0282fcc3f99305afcbc309970c5f) +--- + AUTHORS | 1 + + src/drv_debian.c | 21 ++++----------------- + src/drv_redhat.c | 21 ++++----------------- + src/drv_suse.c | 21 ++++----------------- + src/dutil_linux.c | 41 +++++++++++++++++++++++++++++++++++++++++ + src/dutil_linux.h | 3 +++ + 6 files changed, 57 insertions(+), 51 deletions(-) + +diff --git a/AUTHORS b/AUTHORS +index c388e87..f2aeb40 100644 +--- a/AUTHORS ++++ b/AUTHORS +@@ -24,3 +24,4 @@ Contributions by: + Martin Wilck + Jincheng Miao + Jianwei Hu ++ Dominic Cleal +\ No newline at end of file +diff --git a/src/drv_debian.c b/src/drv_debian.c +index 440b233..59f0976 100644 +--- a/src/drv_debian.c ++++ b/src/drv_debian.c +@@ -912,10 +912,6 @@ struct netcf_if *drv_define(struct netcf *ncf, const char *xml_str) { + struct netcf_if *result = NULL; + xmlDocPtr ncf_xml = NULL, aug_xml = NULL; + char *name = NULL; +- int r; +- struct augeas *aug = get_augeas(ncf); +- +- ERR_BAIL(ncf); + + ncf_xml = parse_xml(ncf, xml_str); + ERR_BAIL(ncf); +@@ -941,12 +937,8 @@ struct netcf_if *drv_define(struct netcf *ncf, const char *xml_str) { + bond_setup(ncf, name, true); + ERR_BAIL(ncf); + +- r = aug_save(aug); +- if (r < 0 && NCF_DEBUG(ncf)) { +- fprintf(stderr, "Errors from aug_save:\n"); +- aug_print(aug, stderr, "/augeas//error"); +- } +- ERR_THROW(r < 0, ncf, EOTHER, "aug_save failed"); ++ aug_save_assert(ncf); ++ ERR_BAIL(ncf); + + result = make_netcf_if(ncf, name); + ERR_BAIL(ncf); +@@ -961,12 +953,7 @@ struct netcf_if *drv_define(struct netcf *ncf, const char *xml_str) { + } + + int drv_undefine(struct netcf_if *nif) { +- struct augeas *aug = NULL; + struct netcf *ncf = nif->ncf; +- int r; +- +- aug = get_augeas(ncf); +- ERR_BAIL(ncf); + + bond_setup(ncf, nif->name, false); + ERR_BAIL(ncf); +@@ -974,8 +961,8 @@ int drv_undefine(struct netcf_if *nif) { + rm_interface(ncf, nif->name); + ERR_BAIL(ncf); + +- r = aug_save(aug); +- ERR_COND_BAIL(r < 0, ncf, EOTHER); ++ aug_save_assert(ncf); ++ ERR_BAIL(ncf); + + return 0; + error: +diff --git a/src/drv_redhat.c b/src/drv_redhat.c +index 898601d..d8a2cb1 100644 +--- a/src/drv_redhat.c ++++ b/src/drv_redhat.c +@@ -865,10 +865,6 @@ struct netcf_if *drv_define(struct netcf *ncf, const char *xml_str) { + xmlDocPtr ncf_xml = NULL, aug_xml = NULL; + char *name = NULL; + struct netcf_if *result = NULL; +- int r; +- struct augeas *aug = get_augeas(ncf); +- +- ERR_BAIL(ncf); + + ncf_xml = parse_xml(ncf, xml_str); + ERR_BAIL(ncf); +@@ -894,12 +890,8 @@ struct netcf_if *drv_define(struct netcf *ncf, const char *xml_str) { + bond_setup(ncf, name, true); + ERR_BAIL(ncf); + +- r = aug_save(aug); +- if (r < 0 && NCF_DEBUG(ncf)) { +- fprintf(stderr, "Errors from aug_save:\n"); +- aug_print(aug, stderr, "/augeas//error"); +- } +- ERR_THROW(r < 0, ncf, EOTHER, "aug_save failed"); ++ aug_save_assert(ncf); ++ ERR_BAIL(ncf); + + result = make_netcf_if(ncf, name); + ERR_BAIL(ncf); +@@ -914,12 +906,7 @@ struct netcf_if *drv_define(struct netcf *ncf, const char *xml_str) { + } + + int drv_undefine(struct netcf_if *nif) { +- struct augeas *aug = NULL; + struct netcf *ncf = nif->ncf; +- int r; +- +- aug = get_augeas(ncf); +- ERR_BAIL(ncf); + + bond_setup(ncf, nif->name, false); + ERR_BAIL(ncf); +@@ -927,8 +914,8 @@ int drv_undefine(struct netcf_if *nif) { + rm_interface(ncf, nif->name); + ERR_BAIL(ncf); + +- r = aug_save(aug); +- ERR_COND_BAIL(r < 0, ncf, EOTHER); ++ aug_save_assert(ncf); ++ ERR_BAIL(ncf); + + return 0; + error: +diff --git a/src/drv_suse.c b/src/drv_suse.c +index b677c88..2c127e0 100644 +--- a/src/drv_suse.c ++++ b/src/drv_suse.c +@@ -1007,10 +1007,6 @@ struct netcf_if *drv_define(struct netcf *ncf, const char *xml_str) { + xmlDocPtr ncf_xml = NULL, aug_xml = NULL; + char *name = NULL; + struct netcf_if *result = NULL; +- int r; +- struct augeas *aug = get_augeas(ncf); +- +- ERR_BAIL(ncf); + + ncf_xml = parse_xml(ncf, xml_str); + ERR_BAIL(ncf); +@@ -1036,12 +1032,8 @@ struct netcf_if *drv_define(struct netcf *ncf, const char *xml_str) { + bond_setup(ncf, name, true); + ERR_BAIL(ncf); + +- r = aug_save(aug); +- if (r < 0 && NCF_DEBUG(ncf)) { +- fprintf(stderr, "Errors from aug_save:\n"); +- aug_print(aug, stderr, "/augeas//error"); +- } +- ERR_THROW(r < 0, ncf, EOTHER, "aug_save failed"); ++ aug_save_assert(ncf); ++ ERR_BAIL(ncf); + + result = make_netcf_if(ncf, name); + ERR_BAIL(ncf); +@@ -1056,12 +1048,7 @@ struct netcf_if *drv_define(struct netcf *ncf, const char *xml_str) { + } + + int drv_undefine(struct netcf_if *nif) { +- struct augeas *aug = NULL; + struct netcf *ncf = nif->ncf; +- int r; +- +- aug = get_augeas(ncf); +- ERR_BAIL(ncf); + + bond_setup(ncf, nif->name, false); + ERR_BAIL(ncf); +@@ -1069,8 +1056,8 @@ int drv_undefine(struct netcf_if *nif) { + rm_interface(ncf, nif->name); + ERR_BAIL(ncf); + +- r = aug_save(aug); +- ERR_COND_BAIL(r < 0, ncf, EOTHER); ++ aug_save_assert(ncf); ++ ERR_BAIL(ncf); + + return 0; + error: +diff --git a/src/dutil_linux.c b/src/dutil_linux.c +index d2bbef4..71160ee 100644 +--- a/src/dutil_linux.c ++++ b/src/dutil_linux.c +@@ -215,6 +215,47 @@ struct augeas *get_augeas(struct netcf *ncf) { + return NULL; + } + ++int aug_save_assert(struct netcf *ncf) ++{ ++ int r = -1; ++ const char *err, *errmsg, *path = "unknown"; ++ struct augeas *aug = get_augeas(ncf); ++ ++ ERR_BAIL(ncf); ++ ++ r = aug_save(aug); ++ if (r >= 0) ++ goto done; ++ ++ if (NCF_DEBUG(ncf)) { ++ fprintf(stderr, "Errors from aug_save:\n"); ++ aug_print(aug, stderr, "/augeas//error"); ++ } ++ ++ if (aug_get(aug, "/augeas//error", &err) == 1) { ++ if (aug_get(aug, "/augeas//error/../path", &path) == 1) { ++ /* strip /files prefix */ ++ if (path != NULL && *path != '\0') ++ path = strchrnul(path + 1, '/'); ++ } ++ if (aug_get(aug, "/augeas//error/message", &errmsg) == 1) { ++ report_error(ncf, NETCF_EOTHER, "aug_save failed on %s: %s (%s)", ++ path, err, errmsg); ++ } else { ++ report_error(ncf, NETCF_EOTHER, "aug_save failed on %s: %s", ++ path, err); ++ } ++ } else if (aug_match(aug, "/augeas//error", NULL) > 1) { ++ report_error(ncf, NETCF_EOTHER, "aug_save failed: multiple failures"); ++ } else { ++ report_error(ncf, NETCF_EOTHER, "aug_save failed: unknown failure"); ++ } ++ ++ error: ++ done: ++ return r; ++} ++ + ATTRIBUTE_FORMAT(printf, 4, 5) + int defnode(struct netcf *ncf, const char *name, const char *value, + const char *format, ...) { +diff --git a/src/dutil_linux.h b/src/dutil_linux.h +index 64fe64f..f63cc5a 100644 +--- a/src/dutil_linux.h ++++ b/src/dutil_linux.h +@@ -69,6 +69,9 @@ int remove_augeas_xfm_table(struct netcf *ncf, + /* Get or create the augeas instance from NCF */ + struct augeas *get_augeas(struct netcf *ncf); + ++/* Save changes in augeas and raise error with message on failure */ ++int aug_save_assert(struct netcf *ncf); ++ + /* Define a node inside the augeas tree */ + ATTRIBUTE_FORMAT(printf, 4, 5) + int defnode(struct netcf *ncf, const char *name, const char *value, +-- +1.8.3.1 + diff --git a/SOURCES/netcf-Require-bridge-utils-for-netcf-libs-in-the-specfile.patch b/SOURCES/netcf-Require-bridge-utils-for-netcf-libs-in-the-specfile.patch deleted file mode 100644 index f3ed352..0000000 --- a/SOURCES/netcf-Require-bridge-utils-for-netcf-libs-in-the-specfile.patch +++ /dev/null @@ -1,46 +0,0 @@ -From 097cfe01588570f924050bc3d1423a0266cd1ca4 Mon Sep 17 00:00:00 2001 -From: Laine Stump -Date: Fri, 7 Feb 2014 16:17:24 +0200 -Subject: [PATCH] Require bridge-utils for netcf-libs in the specfile - -This resolves: - - https://bugzilla.redhat.com/show_bug.cgi?id=1060317 (RHEL7) - https://bugzilla.redhat.com/show_bug.cgi?id=911403 (Fedora 20) - -netcf itself doesn't use anything in bridge-utils, but it called -/sbin/ifup, which *can* run brctl (which is part of bridge-utils). -Technically, initscripts should require brutils (since /sbin/ifup is a -part of initscripts), but we all know that's not going to -happen. Instead we can just make netcf require bridge-utils. It's not -a very large package, so it's unlikely we'll get any complaints about -bloat. - -(NB: in the past, libvirt had a Requires: bridge-utils, so this didn't -used to be a problem. libvirt removed this Requires: in v0.9.8, when -it switched from execing brctl to directly calling ioctls to create -and manage bridge devices.) - -(cherry picked from commit 5bb22ec48096338a6651590299740f9e42367bb9) ---- - netcf.spec.in | 4 ++++ - 1 file changed, 4 insertions(+) - -diff --git a/netcf.spec.in b/netcf.spec.in -index 6ab3ee5..7862e74 100644 ---- a/netcf.spec.in -+++ b/netcf.spec.in -@@ -66,6 +66,10 @@ developing applications that use %{name}. - Summary: Libraries for %{name} - Group: System Environment/Libraries - -+# bridge-utils is needed because /sbin/ifup calls brctl -+# if you create a bridge device -+Requires: bridge-utils -+ - %description libs - The libraries for %{name}. - --- -1.8.3.1 - diff --git a/SOURCES/netcf-eliminate-use-of-uninitialized-data-when-getting-mac.patch b/SOURCES/netcf-eliminate-use-of-uninitialized-data-when-getting-mac.patch deleted file mode 100644 index 48e2192..0000000 --- a/SOURCES/netcf-eliminate-use-of-uninitialized-data-when-getting-mac.patch +++ /dev/null @@ -1,112 +0,0 @@ -From 423f9e7d93c4971a5a02b2ea5dc352f4bf2dfd9f Mon Sep 17 00:00:00 2001 -From: Laine Stump -Date: Tue, 7 Jan 2014 20:12:06 +0200 -Subject: [PATCH] eliminate use of uninitialized data when getting mac address - -https://bugzilla.redhat.com/show_bug.cgi?id=1046594 - -If the call to get_augeas() at the top of aug_get_mac() failed, we -would goto error and FREE(path), which would not have been -initialized. And if by some magic of fate we happened to get past -that, we would return garbage for the return code, since r was also -not initialized. This patch initializes both path and r to fix the -crash documented in Bug 1046594. - -Although it doesn't directly impact the referenced bug, a quick audit -of other functions in the same file showed that defnode() had the same -problem with uninitialized "r". Beyond that, I also defensively -initialized the pointer to mac address to NULL both in aug_get_mac() -as well as two of its callers, to make future audits of the code -easier, and to shut up both valgrind and whatever static analyzers -might be run on the code. - -(cherry picked from commit 8ed36d22fbc792474ca9c3b06c8a326b1fb5af08) ---- - src/drv_redhat.c | 4 ++-- - src/drv_suse.c | 4 ++-- - src/dutil_linux.c | 9 +++++---- - 3 files changed, 9 insertions(+), 8 deletions(-) - -diff --git a/src/drv_redhat.c b/src/drv_redhat.c -index b5b8694..e9d25cb 100644 ---- a/src/drv_redhat.c -+++ b/src/drv_redhat.c -@@ -1,7 +1,7 @@ - /* - * drv_redhat.c: the Red Hat distro family backend for netcf - * -- * Copyright (C) 2009-2013 Red Hat Inc. -+ * Copyright (C) 2009-2014 Red Hat Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public -@@ -989,7 +989,7 @@ int drv_lookup_by_mac_string(struct netcf *ncf, const char *mac, - - const char *drv_mac_string(struct netcf_if *nif) { - struct netcf *ncf = nif->ncf; -- const char *mac; -+ const char *mac = NULL; - char *path = NULL; - int r; - -diff --git a/src/drv_suse.c b/src/drv_suse.c -index e59d7d3..e346c27 100644 ---- a/src/drv_suse.c -+++ b/src/drv_suse.c -@@ -2,7 +2,7 @@ - * drv_suse.c: the suse backend for netcf - * - * Copyright (C) 2010 Novell Inc. -- * Copyright (C) 2009-2013 Red Hat Inc. -+ * Copyright (C) 2009-2014 Red Hat Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public -@@ -1132,7 +1132,7 @@ int drv_lookup_by_mac_string(struct netcf *ncf, const char *mac, - - const char *drv_mac_string(struct netcf_if *nif) { - struct netcf *ncf = nif->ncf; -- const char *mac; -+ const char *mac = NULL; - char *path = NULL; - int r; - -diff --git a/src/dutil_linux.c b/src/dutil_linux.c -index 271c515..7af741e 100644 ---- a/src/dutil_linux.c -+++ b/src/dutil_linux.c -@@ -1,7 +1,7 @@ - /* - * dutil_linux.c: Linux utility functions for driver backends. - * -- * Copyright (C) 2009-2012 Red Hat Inc. -+ * Copyright (C) 2009-2012, 2014 Red Hat Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public -@@ -221,7 +221,7 @@ int defnode(struct netcf *ncf, const char *name, const char *value, - struct augeas *aug = get_augeas(ncf); - va_list ap; - char *expr = NULL; -- int r, created; -+ int r = -1, created; - - ERR_BAIL(ncf); - -@@ -370,10 +370,11 @@ int aug_match_mac(struct netcf *ncf, const char *mac, char ***matches) { - - /* Get the MAC address of the interface INTF */ - int aug_get_mac(struct netcf *ncf, const char *intf, const char **mac) { -- int r; -- char *path; -+ int r = -1; -+ char *path = NULL; - struct augeas *aug = get_augeas(ncf); - -+ *mac = NULL; - ERR_BAIL(ncf); - - r = xasprintf(&path, "/files/sys/class/net/%s/address/content", intf); --- -1.8.3.1 - diff --git a/SOURCES/netcf-fix-autogen-build-error.patch b/SOURCES/netcf-fix-autogen-build-error.patch deleted file mode 100644 index b64cfd8..0000000 --- a/SOURCES/netcf-fix-autogen-build-error.patch +++ /dev/null @@ -1,36 +0,0 @@ -From 576e913f6fbce1a3428ad16af2c3e94544b862e7 Mon Sep 17 00:00:00 2001 -From: Laine Stump -Date: Wed, 22 Jan 2014 15:27:43 +0200 -Subject: [PATCH] fix autogen build error - -This is also required for the fix for: - - https://bugzilla.redhat.com/show_bug.cgi?id=1044681 - -A last minute change to the previous patch addressing a review comment -managed to break an autogen, but I didn't notice because the error -scrolled off the screen: - -checking for system init flavor... ./configure: line 32046: systemd: command not found - -(cherry picked from commit 9dabd473ce54a5264ae92a78d5e4019b864f6997) ---- - configure.ac | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/configure.ac b/configure.ac -index 4dc415f..c9e0ad2 100644 ---- a/configure.ac -+++ b/configure.ac -@@ -139,7 +139,7 @@ fi - - AM_CONDITIONAL([NETCF_USE_INITSCRIPTS], test "$with_sysinit" = "initscripts") - AM_CONDITIONAL([NETCF_USE_SYSTEMD], test "$with_sysinit" = "systemd") --AM_CONDITIONAL([NETCF_TRANSACTION_SUPPORT], "$with_sysinit" != "none") -+AM_CONDITIONAL([NETCF_TRANSACTION_SUPPORT], test "$with_sysinit" != "none") - AC_MSG_RESULT($with_sysinit) - if test "$with_sysinit" != "none" && test "$with_driver" != "redhat"; then - AC_MSG_ERROR([netcf does not have support for $with_sysinit combined with the $with_driver driver]) --- -1.8.3.1 - diff --git a/SOURCES/netcf-remove-extraneous-quotes-from-BONDING_OPTS.patch b/SOURCES/netcf-remove-extraneous-quotes-from-BONDING_OPTS.patch deleted file mode 100644 index ac4cb25..0000000 --- a/SOURCES/netcf-remove-extraneous-quotes-from-BONDING_OPTS.patch +++ /dev/null @@ -1,127 +0,0 @@ -From d25230cb26cdd6603d2758bdb2d3c56925d8219e Mon Sep 17 00:00:00 2001 -From: Satoru SATOH -Date: Wed, 3 Jul 2013 13:17:27 -0400 -Subject: [PATCH] remove extraneous quotes from BONDING_OPTS - -This fixes: https://bugzilla.redhat.com/show_bug.cgi?id=798851 - -For some unknown reason, the BONDING_OPTS setting in ifcfg files was -being set with an extra set of single quotes. So, for example, instead of: - - BONDING_OPTS="mode=active-backup primary=eth1 miimon=100 updelay=10 use_carrier=0" - -we would get (e.g.): - - BONDING_OPTS="'mode=active-backup primary=eth1 miimon=100 updelay=10 use_carrier=0'" - -Even when there weren't any BONDING_OPTS to set, the ifcfg file would -still get: - - BONDING_OPTS="''" - -Since the extra quotes are added in all cases, and are never needed, -this patch just unconditionally removes them. - -(cherry picked from commit 581ff3f252552cf5edc8e47c4a72667a39e133ba) - -Conflicts: - - AUTHORS - one additional name upstream for debian-specific patch not - yet in RHEL. - - tests/suse/schema/*.xml - the upstream patch modified some files that - weren't yet being shipped in the tarball as of netcf-0.2.3; they are - unused in RHEL anyway. ---- - AUTHORS | 1 + - data/xml/util-get.xsl | 2 -- - tests/redhat/schema/bond-arp.xml | 2 +- - tests/redhat/schema/bond-defaults.xml | 2 +- - tests/redhat/schema/bond.xml | 2 +- - tests/redhat/schema/bridge-bond.xml | 2 +- - 6 files changed, 5 insertions(+), 6 deletions(-) - -diff --git a/AUTHORS b/AUTHORS -index b41f26e..2512ac8 100644 ---- a/AUTHORS -+++ b/AUTHORS -@@ -19,3 +19,4 @@ Contributions by: - Guido G�nther - Ed Maste - Hendrik Schwartke -+ Satoru SATOH -diff --git a/data/xml/util-get.xsl b/data/xml/util-get.xsl -index 9edace3..ac0a320 100644 ---- a/data/xml/util-get.xsl -+++ b/data/xml/util-get.xsl -@@ -3,7 +3,6 @@ - version="1.0"> - - -- ' - mode= - primary= - -@@ -21,7 +20,6 @@ - arp_ip_target= - arp_validate= - -- ' - - - -diff --git a/tests/redhat/schema/bond-arp.xml b/tests/redhat/schema/bond-arp.xml -index 6a53d09..884cb84 100644 ---- a/tests/redhat/schema/bond-arp.xml -+++ b/tests/redhat/schema/bond-arp.xml -@@ -7,7 +7,7 @@ - - - -- -+ - - - -diff --git a/tests/redhat/schema/bond-defaults.xml b/tests/redhat/schema/bond-defaults.xml -index 3e92d19..5ee875d 100644 ---- a/tests/redhat/schema/bond-defaults.xml -+++ b/tests/redhat/schema/bond-defaults.xml -@@ -11,7 +11,7 @@ - - - -- -+ - - - -diff --git a/tests/redhat/schema/bond.xml b/tests/redhat/schema/bond.xml -index d97542d..4a7e9bf 100644 ---- a/tests/redhat/schema/bond.xml -+++ b/tests/redhat/schema/bond.xml -@@ -11,7 +11,7 @@ - - - -- -+ - - - -diff --git a/tests/redhat/schema/bridge-bond.xml b/tests/redhat/schema/bridge-bond.xml -index c72f8d3..0b521d4 100644 ---- a/tests/redhat/schema/bridge-bond.xml -+++ b/tests/redhat/schema/bridge-bond.xml -@@ -17,7 +17,7 @@ - - - -- -+ - - - --- -1.8.3.1 - diff --git a/SOURCES/netcf-support-systemd-based-netcf-transaction.patch b/SOURCES/netcf-support-systemd-based-netcf-transaction.patch deleted file mode 100644 index 24de738..0000000 --- a/SOURCES/netcf-support-systemd-based-netcf-transaction.patch +++ /dev/null @@ -1,524 +0,0 @@ -From afcdbdd1923d148f947c53984c42102fd9188207 Mon Sep 17 00:00:00 2001 -From: Laine Stump -Date: Fri, 17 Jan 2014 11:58:46 +0200 -Subject: [PATCH] support systemd-based netcf-transaction - -https://bugzilla.redhat.com/show_bug.cgi?id=1044681 - -The netcf-transaction script is used in two ways: - -1) It is called by libnetcf.so to begin, commit, and manually rollback -a set of network interface config changes. - -2) It is called as part of normal system startup to automatically -rollback any config changes that are part of a netcf transaction that -hasn't yet been committed. (in other words, if you reboot after -calling ncf_change_begin() but before calling ncf_change_commit(), all -the changes you made subsequent to ncf_change_begin() will be erased). - -This functionality is only supported for the "redhat" driver (used by -Fedora, CentOS, and RHEL), and up until now, it was all self-contained -in an initscripts-style shell script installed to -/etc/init.d/netcf-transaction - libnetcf.so would exec this script, -and it was also conveniently placed for initscripts to run it at -startup. - -Some time ago, Fedora started supporting systemd for system -init/daemon management, but is still maintaining legacy support for -initscripts for packages that haven't yet moved over to systemd. RHEL7 -also will support systemd. - -This patch updates netcf to allow building packages either with an -initscripts-style script for /etc/init.d or a systemd-style init file -for /lib/systemd/system. The selection of which to include in the -build can either be made manually at configure-time (using the ---with-sysinit=(initscripts|systemd) option) or, if not explicitly -given on the configure commandline, configure.ac attempts to -automatically determine which style to use based on the existence of -the directory "/etc/systemd". Additionally, netcf.spec decides which -type of sysinit to build for based on the Fedora/RHEL version, so that -anyone building a netcf rpm on Fedora < 20 will continue to get -initscripts files rather than switching midstream to systemd. - -The core functionality that was previously in -/etc/init.d/netcf-transaction has been moved to the file -/usr/libexec/netcf-transaction.sh, which is referenced both by the -initscripts init file (/etc/init.d/netcf-transaction) and by the -systemd service file (/lib/systemd/system/netcf-transaction.service): - - src/netcf-transaction.init.in (new initscripts file) - src/netcf-transaction.service.in (systemd service file) - src/netcf-transaction.sh.in (this was previously the initscripts file) - -netcf.spec.in: - * add check to decide systemd vs. initscripts based on - RHEL/Fedora version and set configure commandline accordingly; - - * update %post and %postun to do the right thing for systems, and add - a new %preun section for the same reason. Unlike libvirt, we know - that any version of netcf chosen to use systemd by this specfile - will already have the systemd rpm macros available, so we don't - need the extra check for that which is present in the libvirt - specfile. (this patch was written by heavily referencing the - libvirt bits responsible for setting up the "libvirt-guests" - service in libvirt). - -src/Makefile.am: - * generate the three new files when appropriate - * change install-data-local and uninstall-local targets as appropriate - for systemd vs initscripts vs none. - -configure.ac: - - * support new --with-sysinit arg to manually specify - systemd/initscripts/none. - - * autodetect which to use based on setting of $with_driver and - presence of /etd/systemd directory. - -NB: the location of the netcf-transaction script, which src/drv_*.c -find via the NETCF_TRANSACTION #define is currently hardcoded to look -in /usr/libexec. Ideally, this should use $libexecdir, but that -resolves to "${exec_prefix}/libexec" at configure time. To get the -desired results, we need to update gnulib and use gnulib's configmake -package, this way we'll end up with a NETCF_TRANSACTION that will be -set at the time make is run rather than configure. This is left as a -separate patch though, so that the initial support for systemd can be -backported to older releases of netcf (a gnulib update shouldn't be -backported to the maintenance branch of an already-cut release). - -(cherry picked from commit 2ca7857cc5ececf12288f4bcda586befdb16378c) - -Conflicts: had to remove changes to .gitignore, since it isn't present - in the release tarball. ---- - configure.ac | 57 ++++++++++++-- - netcf.spec.in | 60 ++++++++++++++- - src/Makefile.am | 86 ++++++++++++++++------ - src/netcf-transaction.init.in | 31 ++++++++ - src/netcf-transaction.service.in | 15 ++++ - ...transaction.init.sh => netcf-transaction.sh.in} | 34 +++++---- - 6 files changed, 236 insertions(+), 47 deletions(-) - create mode 100644 src/netcf-transaction.init.in - create mode 100644 src/netcf-transaction.service.in - rename src/{netcf-transaction.init.sh => netcf-transaction.sh.in} (88%) - mode change 100755 => 100644 - -diff --git a/configure.ac b/configure.ac -index 3f30865..4dc415f 100644 ---- a/configure.ac -+++ b/configure.ac -@@ -50,14 +50,14 @@ if test "$prefix" = "/usr" && test "$sysconfdir" = '${prefix}/etc' ; then - fi - - dnl --dnl init script flavor -+dnl network driver flavor - dnl - AC_ARG_WITH([driver], - [AS_HELP_STRING([--with-driver], -- [Network driver name])], -+ [network driver name])], - [],[with_driver=check]) - --AC_MSG_CHECKING([Network driver name]) -+AC_MSG_CHECKING([network driver name]) - if test "x$with_driver" = "xcheck" ; then - case "$host" in - *-*-mingw*) -@@ -93,12 +93,57 @@ AM_CONDITIONAL([NETCF_DRIVER_SUSE], test "x$with_driver" = "xsuse") - AM_CONDITIONAL([NETCF_DRIVER_MSWINDOWS], test "x$with_driver" = "xmswindows") - - if test "x$with_driver" = "xredhat"; then -+ # FIXME: This should be defined relative to $libexecdir, -+ # but that requires gnulib configmake to do correctly. - AC_DEFINE_UNQUOTED([NETCF_TRANSACTION], -- ["$sysconfdir/rc.d/init.d/netcf-transaction"], -+ ["/usr/libexec/netcf-transaction.sh"], - [Location of the netcf-transaction shell script]) - fi --AM_CONDITIONAL([NETCF_INIT_SCRIPT_RED_HAT], -- [test x$with_driver = xredhat]) -+ -+dnl -+dnl system init flavor -+dnl -+AC_MSG_CHECKING([for system init flavor]) -+AC_ARG_WITH([sysinit], -+ [AS_HELP_STRING([--with-sysinit@<:@=STYLE@:>@], -+ [Style of init script to install: initscripts, systemd, -+ check, none @<:@default=check@:>@])], -+ [],[with_sysinit=check]) -+ -+case "$with_sysinit" in -+ systemd) -+ ;; -+ initscripts) -+ ;; -+ none) -+ ;; -+ check) -+ if test "$cross_compiling" != "yes" && \ -+ test "$with_driver" = "redhat"; then -+ if test -d /etc/systemd; then -+ with_sysinit=systemd -+ else -+ with_sysinit=initscripts -+ fi -+ else -+ with_sysinit=none -+ fi -+ ;; -+ *) -+ AC_MSG_ERROR([Unknown system initscript flavor $with_sysinit]) -+ ;; -+esac -+if test "x$with_sysinit" = "xcheck" ; then -+ with_sysinit=none -+fi -+ -+AM_CONDITIONAL([NETCF_USE_INITSCRIPTS], test "$with_sysinit" = "initscripts") -+AM_CONDITIONAL([NETCF_USE_SYSTEMD], test "$with_sysinit" = "systemd") -+AM_CONDITIONAL([NETCF_TRANSACTION_SUPPORT], "$with_sysinit" != "none") -+AC_MSG_RESULT($with_sysinit) -+if test "$with_sysinit" != "none" && test "$with_driver" != "redhat"; then -+ AC_MSG_ERROR([netcf does not have support for $with_sysinit combined with the $with_driver driver]) -+fi - - AC_ARG_WITH([libnl1], - AS_HELP_STRING([--with-libnl1], [Force usage of libnl1 @<:@default=no@:>@]), -diff --git a/netcf.spec.in b/netcf.spec.in -index d243f1c..6ab3ee5 100644 ---- a/netcf.spec.in -+++ b/netcf.spec.in -@@ -9,6 +9,22 @@ URL: https://fedorahosted.org/netcf/ - Source0: https://fedorahosted.org/released/%{name}/%{name}-%{version}.tar.gz - BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) - -+# Fedora 20 / RHEL-7 are where netcf first uses systemd. Although earlier -+# Fedora has systemd, netcf still used sysvinit there. -+%if 0%{?fedora} >= 20 || 0%{?rhel} >= 7 -+ %define with_systemd 1 -+%else -+ %define with_systemd 0 -+%endif -+ -+%if %{with_systemd} -+BuildRequires: systemd-units -+Requires(post): systemd-units -+Requires(post): systemd-sysv -+Requires(preun): systemd-units -+Requires(postun): systemd-units -+%endif -+ - BuildRequires: readline-devel augeas-devel >= 0.5.2 - BuildRequires: libxml2-devel libxslt-devel - -@@ -60,22 +76,53 @@ The libraries for %{name}. - %if %{with_libnl1} - %define _with_libnl1 --with-libnl1 - %endif -+%if %{with_systemd} -+ %define sysinit --with-sysinit=systemd -+%else -+ %define sysinit --with-sysinit=initscripts -+%endif -+ - - %configure --disable-static \ -- %{?_with_libnl1} -+ %{?_with_libnl1} \ -+ %{sysinit} - make %{?_smp_mflags} - - %install - rm -rf $RPM_BUILD_ROOT --make install DESTDIR=$RPM_BUILD_ROOT INSTALL="%{__install} -p" -+make install DESTDIR=$RPM_BUILD_ROOT SYSTEMD_UNIT_DIR=%{_unitdir} \ -+ INSTALL="%{__install} -p" - find $RPM_BUILD_ROOT -name '*.la' -exec rm -f {} ';' - - %clean - rm -rf $RPM_BUILD_ROOT - --%post libs -p /sbin/ldconfig -+%preun libs - --%postun libs -p /sbin/ldconfig -+%if %{with_systemd} -+ %systemd_preun netcf-transaction.service -+%else -+if [ $1 = 0 ]; then -+ /sbin/chkconfig --del netcf-transaction -+fi -+%endif -+ -+%post libs -+ -+/sbin/ldconfig -+%if %{with_systemd} -+ %systemd_post netcf-transaction.service -+ /bin/systemctl --no-reload enable netcf-transaction.service >/dev/null 2>&1 || : -+%else -+/sbin/chkconfig --add netcf-transaction -+%endif -+ -+%postun libs -+ -+/sbin/ldconfig -+%if %{with_systemd} -+ %systemd_postun netcf-transaction.service -+%endif - - %files - %defattr(-,root,root,-) -@@ -86,7 +133,12 @@ rm -rf $RPM_BUILD_ROOT - %defattr(-,root,root,-) - %{_datadir}/netcf - %{_libdir}/*.so.* -+%if %{with_systemd} -+%{_unitdir}/netcf-transaction.service -+%else - %{_sysconfdir}/rc.d/init.d/netcf-transaction -+%endif -+%attr(0755, root, root) %{_libexecdir}/netcf-transaction.sh - %doc AUTHORS COPYING NEWS - - %files devel -diff --git a/src/Makefile.am b/src/Makefile.am -index 9963402..2f76614 100644 ---- a/src/Makefile.am -+++ b/src/Makefile.am -@@ -16,7 +16,9 @@ include_HEADERS = netcf.h - lib_LTLIBRARIES = libnetcf.la - - bin_PROGRAMS = ncftool -- -+if NETCF_TRANSACTION_SUPPORT -+libexec_SCRIPTS = netcf-transaction.sh -+endif - if ! NETCF_DRIVER_MSWINDOWS - noinst_PROGRAMS = ncftransform - endif -@@ -31,7 +33,6 @@ DRIVER_SOURCES_SUSE = drv_suse.c - - EXTRA_DIST = netcf_public.syms \ - netcf_private.syms \ -- netcf-transaction.init.sh \ - $(DRIVER_SOURCES_COMMON) \ - $(DRIVER_SOURCES_POSIX) \ - $(DRIVER_SOURCES_LINUX) \ -@@ -112,35 +113,78 @@ internal.h: datadir.h - datadir.h: $(top_builddir)/config.status - echo '#define NETCF_DATADIR "$(datadir)"' > datadir.h - --install-data-local: install-init -+EXTRA_DIST += netcf-transaction.sh.in \ -+ netcf-transaction.init.in \ -+ netcf-transaction.service.in -+ -+if NETCF_DRIVER_REDHAT -+ -+install-data-local: install-sysinit -+ -+uninstall-local: uninstall-sysinit -+ -+# This is for the shell script that handles network config change -+# transactions. It is used by both the initscripts and systemd -+# flavors, as well as by libnetcf.so itself -+netcf-transaction.sh: netcf-transaction.sh.in $(top_builddir)/config.status -+ $(AM_V_GEN)sed \ -+ -e 's![@]localstatedir[@]!$(localstatedir)!g' \ -+ -e 's![@]sysconfdir[@]!$(sysconfdir)!g' \ -+ < $< > $@-t && \ -+ chmod a+x $@-t && \ -+ mv $@-t $@ - --uninstall-local: uninstall-init -+BUILT_SOURCES += netcf-transaction.sh - --if NETCF_INIT_SCRIPT_RED_HAT --# This is for the initscript that handles network config change --# transactions. --install-init: netcf-transaction.init -- mkdir -p $(DESTDIR)$(sysconfdir)/rc.d/init.d -+if NETCF_USE_INITSCRIPTS -+install-sysinit: netcf-transaction.init -+ $(MKDIR_P) $(DESTDIR)$(sysconfdir)/rc.d/init.d - $(INSTALL_SCRIPT) netcf-transaction.init \ - $(DESTDIR)$(sysconfdir)/rc.d/init.d/netcf-transaction - --uninstall-init: -+uninstall-sysinit: - rm -f $(DESTDIR)$(sysconfdir)/rc.d/init.d/netcf-transaction \ - $(DESTDIR)$(sysconfdir)/sysconfig/netcf-transaction - -+netcf-transaction.init: netcf-transaction.init.in \ -+ $(top_builddir)/config.status -+ $(AM_V_GEN)sed \ -+ -e 's![@]localstatedir[@]!$(localstatedir)!g' \ -+ -e 's|[@]libexecdir[@]|$(libexecdir)|g' \ -+ < $< > $@-t && \ -+ chmod a+x $@-t && \ -+ mv $@-t $@ -+ - BUILT_SOURCES += netcf-transaction.init - --netcf-transaction.init: netcf-transaction.init.sh $(top_builddir)/config.status -- $(AM_V_GEN)sed \ -- -e 's!\@localstatedir\@!$(localstatedir)!g' \ -- -e 's!\@sysconfdir\@!$(sysconfdir)!g' \ -- < $< > $@-t && \ -- chmod a+x $@-t && \ -+else ! NETCF_USE_INITSCRIPTS -+ -+if NETCF_USE_SYSTEMD -+SYSTEMD_UNIT_DIR = $(prefix)/lib/systemd/system -+ -+install-sysinit: netcf-transaction.service -+ $(MKDIR_P) $(DESTDIR)$(SYSTEMD_UNIT_DIR) -+ $(INSTALL_DATA) netcf-transaction.service \ -+ $(DESTDIR)$(SYSTEMD_UNIT_DIR)/netcf-transaction.service -+ -+uninstall-sysinit: -+ rm -f $(DESTDIR)$(SYSTEMD_UNIT_DIR)/netcf-transaction.service -+ rmdir $(DESTDIR)$(SYSTEMD_UNIT_DIR) ||: -+ -+netcf-transaction.service: netcf-transaction.service.in \ -+ $(top_builddir)/config.status -+ $(AM_V_GEN)sed \ -+ -e 's|[@]libexecdir[@]|$(libexecdir)|g' \ -+ < $< > $@-t && \ - mv $@-t $@ --else --install-init: --uninstall-init: --netcf-transaction.init: --endif # NETCF_INIT_SCRIPT_RED_HAT -+ -+BUILT_SOURCES += netcf-transaction.service -+ -+else ! NETCF_USE_SYSTEMD -+install-sysinit: -+uninstall-sysinit: -+endif ! NETCF_USE_SYSTEMD -+endif ! NETCF_USE_INITSCRIPTS -+endif NETCF_DRIVER_REDHAT - - DISTCLEANFILES += $(BUILT_SOURCES) -diff --git a/src/netcf-transaction.init.in b/src/netcf-transaction.init.in -new file mode 100644 -index 0000000..36beb53 ---- /dev/null -+++ b/src/netcf-transaction.init.in -@@ -0,0 +1,31 @@ -+#!/bin/sh -+ -+# the following is the LSB init header -+# -+### BEGIN INIT INFO -+# Provides: netcf-transaction -+# Required-Start: $local_fs -+# Default-Start: 2 3 4 5 -+# Short-Description: save/restore network configuration files -+# Description: This script can save the current state of network config, -+# and later revert to that config, or commit the new config -+# (by deleting the snapshot). At boot time, if there are -+# uncommitted changes to the network config, they are -+# reverted (and the discarded changes are archived in -+# @localstatedir@/lib/netcf/network-rollback-*). -+# -+### END INIT INFO -+ -+# the following is chkconfig init header -+# -+# netcf-transaction: save/restore current network interface configuration -+# -+# chkconfig: - 09 91 -+# description: This script can save the current state of network config, \ -+# and later revert to that config, or commit the new config \ -+# (by deleting the snapshot). At boot time, if there are \ -+# uncommitted changes to the network config, they are \ -+# reverted (and the discarded changes are archived in \ -+# @localstatedir@/lib/netcf/network-rollback-*). -+ -+exec @libexecdir@/netcf-transaction.sh "$@" -diff --git a/src/netcf-transaction.service.in b/src/netcf-transaction.service.in -new file mode 100644 -index 0000000..6e17627 ---- /dev/null -+++ b/src/netcf-transaction.service.in -@@ -0,0 +1,15 @@ -+[Unit] -+Description=Rollback uncommitted netcf network config change transactions -+Before=network.target -+Before=NetworkManager.service -+ -+[Service] -+# call common script that is also used by initscript-based service -+# and libnetcf.so -+ExecStart=@libexecdir@/netcf-transaction.sh start -+Type=oneshot -+RemainAfterExit=yes -+StandardOutput=journal+console -+ -+[Install] -+WantedBy=multi-user.target -diff --git a/src/netcf-transaction.init.sh b/src/netcf-transaction.sh.in -old mode 100755 -new mode 100644 -similarity index 88% -rename from src/netcf-transaction.init.sh -rename to src/netcf-transaction.sh.in -index 1465b8a..c9aafdf ---- a/src/netcf-transaction.init.sh -+++ b/src/netcf-transaction.sh.in -@@ -1,27 +1,29 @@ - #!/bin/sh - # --# netcf-transaction: save/restore current network interface configuration -+# netcf-transaction.sh: save/restore current network interface configuration -+# -+# Copyright (C) 2011, 2014 Red Hat, Inc. -+# -+# This library is free software; you can redistribute it and/or -+# modify it under the terms of the GNU Lesser General Public -+# License as published by the Free Software Foundation; either -+# version 2.1 of the License, or (at your option) any later version. -+# -+# This library is distributed in the hope that it will be useful, -+# but WITHOUT ANY WARRANTY; without even the implied warranty of -+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -+# Lesser General Public License for more details. -+# -+# You should have received a copy of the GNU Lesser General Public -+# License along with this library. If not, see -+# . - # --# chkconfig: - 09 91 --# description: This script can save the current state of network config, \ --# and later revert to that config, or commit the new config \ --# (by deleting the snapshot). At boot time, if there are \ --# uncommitted changes to the network config, they are \ --# reverted (and the discarded changes are archived in \ --# /var/lib/netcf/network-rollback-*). -- --### BEGIN INIT INFO --# Provides: netcf-transaction --# Required-Start: $local_fs --# Short-Description: save/restore network configuration files - # Description: This script can save the current state of network config, - # and later revert to that config, or commit the new config - # (by deleting the snapshot). At boot time, if there are - # uncommitted changes to the network config, they are - # reverted (and the discarded changes are archived in --# /var/lib/netcf/network-rollback-*). --# --### END INIT INFO -+# @localstatedir@/lib/netcf/network-rollback-*). - - # special exit code that means a command was issued that is invalid for the - # current state (e.g. change-begin when there is already an open transaction) --- -1.8.3.1 - diff --git a/SOURCES/netcf-transform-STP-value-from-yes-no-to-on-off-in-redhat-.patch b/SOURCES/netcf-transform-STP-value-from-yes-no-to-on-off-in-redhat-.patch deleted file mode 100644 index f03cbc1..0000000 --- a/SOURCES/netcf-transform-STP-value-from-yes-no-to-on-off-in-redhat-.patch +++ /dev/null @@ -1,54 +0,0 @@ -From c0f9207b474ffa4c68151f6351434da51c49cb84 Mon Sep 17 00:00:00 2001 -From: Martin Wilck -Date: Mon, 18 Nov 2013 12:35:15 +0100 -Subject: [PATCH] transform STP value from "yes/no" to "on/off" in - redhat-put.xsl - -https://bugzilla.redhat.com/show_bug.cgi?id=1060076 -https://bugzilla.redhat.com/show_bug.cgi?id=1031053 - -Some tools (e.g. NetworkManager) use "yes"/"no" in config files -rather than "on/off". netcf needs to transform this in order to conform -with the schema. - -(cherry picked from commit 048d13afcc91f4a16a80012aa34b9a024d95368e) ---- - AUTHORS | 1 + - data/xml/redhat-put.xsl | 12 +++++++++++- - 2 files changed, 12 insertions(+), 1 deletion(-) - -diff --git a/AUTHORS b/AUTHORS -index 2512ac8..f38e939 100644 ---- a/AUTHORS -+++ b/AUTHORS -@@ -20,3 +20,4 @@ Contributions by: - Ed Maste - Hendrik Schwartke - Satoru SATOH -+ Martin Wilck -diff --git a/data/xml/redhat-put.xsl b/data/xml/redhat-put.xsl -index 267d9cd..88e6d73 100644 ---- a/data/xml/redhat-put.xsl -+++ b/data/xml/redhat-put.xsl -@@ -77,7 +77,17 @@ - - - -- -+ -+ -+ on -+ -+ -+ off -+ -+ -+ -+ -+ - - - --- -1.8.3.1 - diff --git a/SOURCES/netcf-wait-for-IFF_UP-and-IFF_RUNNING-after-calling-ifup.patch b/SOURCES/netcf-wait-for-IFF_UP-and-IFF_RUNNING-after-calling-ifup.patch deleted file mode 100644 index 980ca0c..0000000 --- a/SOURCES/netcf-wait-for-IFF_UP-and-IFF_RUNNING-after-calling-ifup.patch +++ /dev/null @@ -1,152 +0,0 @@ -From 04df67ae69d98b0f77f94bf5f7c1514907dd003a Mon Sep 17 00:00:00 2001 -From: Laine Stump -Date: Wed, 15 May 2013 14:13:09 -0400 -Subject: [PATCH] wait for IFF_UP and IFF_RUNNING after calling ifup - -This fixes https://bugzilla.redhat.com/show_bug.cgi?id=961184 - -Apparently one or the other of IFF_UP and IFF_RUNNING are not always -set by the time /sbin/ifup returns control to netcf, so the subsequent -check to verify that the interface is up may fail. This patch adds a -loop to re-check the status of the interface every 250msec for up to -2.5 seconds (or until both flags are set). If timeout is reached, it -still fails the operation. - -(cherry picked from commit 14af66fa2b119f47a23c9a4043ae8fe2441379fc) ---- - bootstrap.conf | 3 ++- - src/drv_debian.c | 13 ++++++++++--- - src/drv_redhat.c | 11 +++++++++-- - src/drv_suse.c | 13 ++++++++++--- - 4 files changed, 31 insertions(+), 9 deletions(-) - -diff --git a/bootstrap.conf b/bootstrap.conf -index fd1c8f7..4736009 100644 ---- a/bootstrap.conf -+++ b/bootstrap.conf -@@ -1,6 +1,6 @@ - # Bootstrap configuration. - --# Copyright (C) 2010-2012 Red Hat, Inc. -+# Copyright (C) 2010-2013 Red Hat, Inc. - - # This library is free software; you can redistribute it and/or - # modify it under the terms of the GNU Lesser General Public -@@ -43,6 +43,7 @@ sys_ioctl - sys_socket - sys_wait - unistd -+usleep - vasprintf - waitpid - warnings -diff --git a/src/drv_debian.c b/src/drv_debian.c -index ceeed94..d762a5d 100644 ---- a/src/drv_debian.c -+++ b/src/drv_debian.c -@@ -1,7 +1,7 @@ - /* -- * drv_initscripts.c: the initscripts backend for netcf -+ * drv_debian.c: the debian backend for netcf - * -- * Copyright (C) 2009-2012 Red Hat Inc. -+ * Copyright (C) 2009-2013 Red Hat Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public -@@ -1056,10 +1056,17 @@ int drv_if_up(struct netcf_if *nif) { - static const char *const ifup = IFUP; - struct netcf *ncf = nif->ncf; - int result = -1; -+ int is_active, retries; - - run1(ncf, ifup, nif->name); - ERR_BAIL(ncf); -- ERR_THROW(!if_is_active(ncf, nif->name), ncf, EOTHER, -+ -+ for (retries = 0; retries < 10; retries++) { -+ if ((is_active = if_is_active(ncf, nif->name))) -+ break; -+ usleep(250000); -+ } -+ ERR_THROW(!is_active, ncf, EOTHER, - "interface %s failed to become active - " - "possible disconnected cable.", nif->name); - result = 0; -diff --git a/src/drv_redhat.c b/src/drv_redhat.c -index 4040f5e..b5b8694 100644 ---- a/src/drv_redhat.c -+++ b/src/drv_redhat.c -@@ -1,7 +1,7 @@ - /* - * drv_redhat.c: the Red Hat distro family backend for netcf - * -- * Copyright (C) 2009-2012 Red Hat Inc. -+ * Copyright (C) 2009-2013 Red Hat Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public -@@ -1021,6 +1021,7 @@ int drv_if_up(struct netcf_if *nif) { - char **slaves = NULL; - int nslaves = 0; - int result = -1; -+ int is_active, retries; - - if (is_bridge(ncf, nif->name)) { - /* Bring up bridge slaves before the bridge */ -@@ -1034,7 +1035,13 @@ int drv_if_up(struct netcf_if *nif) { - } - run1(ncf, ifup, nif->name); - ERR_BAIL(ncf); -- ERR_THROW(!if_is_active(ncf, nif->name), ncf, EOTHER, -+ -+ for (retries = 0; retries < 10; retries++) { -+ if ((is_active = if_is_active(ncf, nif->name))) -+ break; -+ usleep(250000); -+ } -+ ERR_THROW(!is_active, ncf, EOTHER, - "interface %s failed to become active - " - "possible disconnected cable.", nif->name); - result = 0; -diff --git a/src/drv_suse.c b/src/drv_suse.c -index 0d4a0af..e59d7d3 100644 ---- a/src/drv_suse.c -+++ b/src/drv_suse.c -@@ -1,8 +1,8 @@ - /* -- * drv_suse.c: the suse backend for suse -+ * drv_suse.c: the suse backend for netcf - * - * Copyright (C) 2010 Novell Inc. -- * Copyright (C) 2009-2012 Red Hat Inc. -+ * Copyright (C) 2009-2013 Red Hat Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public -@@ -1164,6 +1164,7 @@ int drv_if_up(struct netcf_if *nif) { - char **slaves = NULL; - int nslaves = 0; - int result = -1; -+ int is_active, retries; - - if (is_bridge(ncf, nif->name)) { - /* Bring up bridge slaves before the bridge */ -@@ -1177,7 +1178,13 @@ int drv_if_up(struct netcf_if *nif) { - } - run1(ncf, ifup, nif->name); - ERR_BAIL(ncf); -- ERR_THROW(!if_is_active(ncf, nif->name), ncf, EOTHER, -+ -+ for (retries = 0; retries < 10; retries++) { -+ if ((is_active = if_is_active(ncf, nif->name))) -+ break; -+ usleep(250000); -+ } -+ ERR_THROW(!is_active, ncf, EOTHER, - "interface %s failed to become active - " - "possible disconnected cable.", nif->name); - result = 0; --- -1.8.3.1 - diff --git a/SPECS/netcf.spec b/SPECS/netcf.spec index 83835f9..52a728d 100644 --- a/SPECS/netcf.spec +++ b/SPECS/netcf.spec @@ -1,6 +1,6 @@ Name: netcf -Version: 0.2.3 -Release: 8%{?dist}%{?extra_release} +Version: 0.2.6 +Release: 3%{?dist}%{?extra_release} Summary: Cross-platform network configuration library Group: System Environment/Libraries @@ -10,20 +10,20 @@ Source0: https://fedorahosted.org/released/%{name}/%{name}-%{version}.tar BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) # Patches -Patch1: netcf-wait-for-IFF_UP-and-IFF_RUNNING-after-calling-ifup.patch -Patch2: netcf-remove-extraneous-quotes-from-BONDING_OPTS.patch -Patch3: netcf-eliminate-use-of-uninitialized-data-when-getting-mac.patch -Patch4: netcf-support-systemd-based-netcf-transaction.patch -Patch5: netcf-fix-autogen-build-error.patch -Patch6: netcf-transform-STP-value-from-yes-no-to-on-off-in-redhat-.patch -Patch7: netcf-Require-bridge-utils-for-netcf-libs-in-the-specfile.patch +Patch1: netcf-Report-file-path-and-reason-when-aug_save-fails.patch +Patch2: netcf-Recognize-IPADDR0-PREFIX0-NETMASK0-GATEWAY0-in-redha.patch +Patch3: netcf-Better-messages-on-failure-reading-sys-class-net-dev.patch +Patch4: netcf-Don-t-return-error-if-sys-class-net-dev-operstate-is.patch + # Default to skipping autoreconf. Distros can change just this one # line (or provide a command-line override) if they backport any # patches that touch configure.ac or Makefile.am. -# THIS HAS BEEN ENABLED FOR RHEL7.0 because Patch4 modifies configure.ac -# and src/Makefile.am. -%{!?enable_autotools:%define enable_autotools 1} +%{!?enable_autotools:%define enable_autotools 0} + +# git is used to build a source tree with patches applied (see the +# %prep section) +BuildRequires: git # Fedora 20 / RHEL-7 are where netcf first uses systemd. Although earlier # Fedora has systemd, netcf still used sysvinit there. @@ -99,13 +99,41 @@ The libraries for %{name}. %prep %setup -q -%patch1 -p1 -%patch2 -p1 -%patch3 -p1 -%patch4 -p1 -%patch5 -p1 -%patch6 -p1 -%patch7 -p1 +# Patches have to be stored in a temporary file because RPM has +# a limit on the length of the result of any macro expansion; +# if the string is longer, it's silently cropped +%{lua: + tmp = os.tmpname(); + f = io.open(tmp, "w+"); + count = 0; + for i, p in ipairs(patches) do + f:write(p.."\n"); + count = count + 1; + end; + f:close(); + print("PATCHCOUNT="..count.."\n") + print("PATCHLIST="..tmp.."\n") +} + +git init -q +git config user.name rpm-build +git config user.email rpm-build +git config gc.auto 0 +git add . +git commit -q -a --author 'rpm-build ' \ + -m '%{name}-%{version} base' + +COUNT=$(grep '\.patch$' $PATCHLIST | wc -l) +if [ $COUNT -ne $PATCHCOUNT ]; then + echo "Found $COUNT patches in $PATCHLIST, expected $PATCHCOUNT" + exit 1 +fi +if [ $COUNT -gt 0 ]; then + xargs git am <$PATCHLIST || exit 1 +fi +echo "Applied $COUNT patches" +rm -f $PATCHLIST + %build %if %{with_libnl1} @@ -117,6 +145,7 @@ The libraries for %{name}. %define sysinit --with-sysinit=initscripts %endif + %if 0%{?enable_autotools} autoreconf -if %endif @@ -187,6 +216,26 @@ fi %{_libdir}/pkgconfig/netcf.pc %changelog +* Tue Jan 27 2015 - Laine Stump 0.2.6-3 + - resolves rhbz#1185850 + - don't treat failure to read /sys/class/net/$def/operstate as an error + +* Thu Nov 13 2014 - Laine Stump 0.2.6-2 + - resolves rhbz#1138196 + - report file path and reason when aug_save fails + - resolves rhbz#1147650 + - recognize IPADDR0/PREFIX0/NETMASK0/GATEWAY0 + - use git to apply patches to source tree + +* Fri Aug 22 2014 Laine Stump - 0.2.6-1 + - resolves rhbz#1115176 + - rebase to upstream 0.2.6 + - allow interleaved elements in interface XML schema + - allow element in vlan and bond interfaces + - report link state/speed in interface status + - change DHCPv6 to DHCPV6C in ifcfg files + - max vlan id is 4095, not 4096 + * Tue Feb 11 2014 Laine Stump - 0.2.3-8 - resolves rhbz 1060076 - Transform STP value from yes/no to on/off