[Open-scap] [PATCH] RHEL Patch - Function calls from newer libnl versions addressed

Francisco Slavin fslavin at tresys.com
Fri Mar 26 18:26:18 UTC 2010


This patch allows OpenSCAP to build in RHEL as of current trunk.
The line referencing config directory m4 was removed from configure.ac because it does not get handled cleanly in RHEL.  With Fedora's shiny new library versions, that m4 directory gets created automatically; RHEL barfs.  I am sure there is a more polished solution for this, but removing the line works.

The rhel5 specific .c and .h files allow for conslidation of RHEL-related patch data; all affected .c files then simply need a conditional include of "common/rhel5.h".  The updates to the probe source files system_info.c, interface.c, and rpminfo.c reflect this implementation.

Calls to a function nl_addr_iszero() from a newer libnl version caused issues in RHEL.  This function and the structure it references were simply ripped from the newer libnl source code and added in to the rhel5 specific code (with citation).  They are conditionally included where needed.

The rhel specific source and header file are handled in the appropriate Makefile.am so they are accessable when called during build time.  They are appropriately not pushed into the publicly installed headers.

Signed-off-by: Francisco Slavin <fslavin at tresys.com>

---
 configure.ac                              |    1 -
 src/OVAL/probes/independent/system_info.c |    2 +-
 src/OVAL/probes/unix/interface.c          |    2 +-
 src/OVAL/probes/unix/linux/rpminfo.c      |    3 +-
 src/common/Makefile.am                    |    4 +-
 src/common/rhel5.c                        |   39 +++++++++++++++++++++++++
 src/common/rhel5.h                        |   45 +++++++++++++++++++++++++++++
 7 files changed, 89 insertions(+), 7 deletions(-)
 create mode 100644 src/common/rhel5.c
 create mode 100644 src/common/rhel5.h

diff --git a/configure.ac b/configure.ac
index bd0f67b..79f5421 100644
--- a/configure.ac
+++ b/configure.ac
@@ -4,7 +4,6 @@ AC_PREREQ(2.59)
 AC_INIT([openscap], [0.5.8], [open-scap-list at redhat.com])
 AC_CONFIG_HEADERS([config.h])
 AC_CONFIG_AUX_DIR([config])
-AC_CONFIG_MACRO_DIR([m4])
 
 AM_INIT_AUTOMAKE([foreign])
 
diff --git a/src/OVAL/probes/independent/system_info.c b/src/OVAL/probes/independent/system_info.c
index 4582617..535c845 100644
--- a/src/OVAL/probes/independent/system_info.c
+++ b/src/OVAL/probes/independent/system_info.c
@@ -62,7 +62,7 @@
 
 /* Use netlink libnl 1.0 API */
 #ifdef HAVE_LIBNL10
-#define nl_cache_free nl_cache_destroy_and_free
+#include "common/rhel5.h"
 #endif
 
 struct nl_cache *link_cache;
diff --git a/src/OVAL/probes/unix/interface.c b/src/OVAL/probes/unix/interface.c
index 7c48439..1d66932 100644
--- a/src/OVAL/probes/unix/interface.c
+++ b/src/OVAL/probes/unix/interface.c
@@ -48,7 +48,7 @@
 #  include <netlink/route/addr.h>
 
 #  ifdef HAVE_LIBNL10
-#    define nl_cache_free nl_cache_destroy_and_free
+#  include "common/rhel5.h"
 #  endif
 
 struct cbstate_s {
diff --git a/src/OVAL/probes/unix/linux/rpminfo.c b/src/OVAL/probes/unix/linux/rpminfo.c
index 2d7434a..51fb11b 100644
--- a/src/OVAL/probes/unix/linux/rpminfo.c
+++ b/src/OVAL/probes/unix/linux/rpminfo.c
@@ -57,8 +57,7 @@
 #include <config.h>
 
 #ifdef HAVE_LIBRPM44
-#include <rpm/header.h>
-#define headerFormat(_h, _fmt, _emsg) headerSprintf((_h),(_fmt),0,0,(_emsg))
+#include "common/rhel5.h"
 #endif
 
 #ifndef _A
diff --git a/src/common/Makefile.am b/src/common/Makefile.am
index f2e2c9b..7b1cb3b 100644
--- a/src/common/Makefile.am
+++ b/src/common/Makefile.am
@@ -1,8 +1,8 @@
 noinst_LTLIBRARIES = liboscapcommon.la
 
-liboscapcommon_la_SOURCES = oscap.c alloc.c text.c \
+liboscapcommon_la_SOURCES = oscap.c alloc.c text.c rhel5.c \
 			    util.h util.c list.h list.c bfind.c bfind.h elements.h elements.c debug.c \
-			    error.c _error.h assume.h text_priv.h
+			    error.c _error.h assume.h text_priv.h rhel5.h
 
 liboscapcommon_la_CPPFLAGS  = @libxml_cflags@ -I$(srcdir)/public
 liboscapcommon_la_LIBADD = @libxml_libs@ $(pthread_ldflags)
diff --git a/src/common/rhel5.c b/src/common/rhel5.c
new file mode 100644
index 0000000..8493eaa
--- /dev/null
+++ b/src/common/rhel5.c
@@ -0,0 +1,39 @@
+/*  Author: Francisco Slavin <fslavin at tresys.com>
+ *
+ *  Copyright (C) 2009-2010 Tresys Technology, LLC
+ *
+ *  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, write to the Free Software
+ *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+/* The follwing code includes functions that let OpenSCAP build on RHEL */
+
+#include "rhel5.h"
+
+/* The following is ripped from newer libnl source code */
+/**
+ * Returns true if the address consists of all zeros
+ * @arg addr            Address to look at.
+ */
+int nl_addr_iszero(struct nl_addr *addr)
+{
+        int i;
+
+        for (i = 0; i < addr->a_len; i++)
+                if (addr->a_addr[i])
+                        return 0;
+
+        return 1;
+}
+
diff --git a/src/common/rhel5.h b/src/common/rhel5.h
new file mode 100644
index 0000000..68edd23
--- /dev/null
+++ b/src/common/rhel5.h
@@ -0,0 +1,45 @@
+/*  Author: Francisco Slavin <fslavin at tresys.com>
+ *          Spencer Shimko   <sshimko at tresys.com>
+ *
+ *  Copyright (C) 2009-2010 Tresys Technology, LLC
+ *
+ *  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, write to the Free Software
+ *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+#ifndef OSCAP_RHEL_H_
+#define OSCAP_RHEL_H_
+
+#include <rpm/header.h>
+#define headerFormat(_h, _fmt, _emsg) headerSprintf((_h),(_fmt),0,0,(_emsg))
+#define nl_cache_free nl_cache_destroy_and_free
+
+/* The follwing is ripped from newer libnl source code. */
+struct nl_addr
+{
+        int                     a_family;
+        unsigned int            a_maxsize;
+        unsigned int            a_len;
+        int                     a_prefixlen;
+        int                     a_refcnt;
+        char                    a_addr[0];
+};
+
+/**
+ * Returns true if the address consists of all zeros
+ * @arg addr            Address to look at.
+ */
+int nl_addr_iszero(struct nl_addr *addr);
+
+#endif /* OSCAP_RHEL_H_ */
-- 
1.5.5.6




More information about the Open-scap-list mailing list