Skip to contentSkip to conversation

package/eudev: add libselinux dependency

PATCH New Romain Naour 2 participants 6 messages Jul 30, 2015 – Jul 31, 2015

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/2 package/eudev: add libselinux dependency

Cc Clayton Shotwell <[email protected]>

---
v2: Don't disable selinux support for musl toolchains (Thomas)

---
 package/eudev/eudev.mk | 7 +++++++
 1 file changed, 7 insertions(+)
package/eudev/eudev.mk +7 -0
index 87bce3e..f587acd 100644
@@ -44,6 +44,13 @@ else
 EUDEV_CONF_OPTS += --disable-gudev
 endif
 
+ifeq ($(BR2_PACKAGE_LIBSELINUX),y)
+EUDEV_CONF_OPTS += --enable-selinux
+EUDEV_DEPENDENCIES += libselinux
+else
+EUDEV_CONF_OPTS += --disable-selinux
+endif
+
 define EUDEV_INSTALL_INIT_SYSV
 	$(INSTALL) -m 0755 package/eudev/S10udev $(TARGET_DIR)/etc/init.d/S10udev
 endef
Signature · 1 line
2.4.3
#1 lore raw

PATCH v2 2/2 package/eudev: fix build with musl + libselinux

Add a patch to disable mallinfo statistics with musl toolchains which doesn't have struct mallinfo.

Fixes:
selinux-util.c: In function ?mac_selinux_init?:
selinux-util.c:70:25: error: storage size of ?before_mallinfo? isn?t known

         struct mallinfo before_mallinfo, after_mallinfo;

Add a second patch for strndupa() which is a GNU extension.

Fixes:
./.libs/libudev-core.a(selinux-util.o): In function `mac_selinux_bind':
selinux-util.c:(.text+0xd94): undefined reference to `strndupa'
collect2: error: ld returned 1 exit status

Cc Clayton Shotwell <[email protected]>

---
v2: new patch

---
 .../eudev/0002-build-sys-check-for-mallinfo.patch  | 85 ++++++++++++++++++++++
 .../eudev/0003-build-sys-check-for-strndupa.patch  | 69 ++++++++++++++++++
 package/eudev/eudev.mk                             |  5 ++
 3 files changed, 159 insertions(+)
 create mode 100644 package/eudev/0002-build-sys-check-for-mallinfo.patch
 create mode 100644 package/eudev/0003-build-sys-check-for-strndupa.patch
package/eudev/0002-build-sys-check-for-mallinfo.patch new file +85 -0
new file mode 100644
index 0000000..5189a06
@@ -0,0 +1,85 @@
+From a1e904cbad7e52d4eb079e7dff37d5affe67895b Mon Sep 17 00:00:00 2001
+From: Romain Naour <[email protected]>
+Date: Thu, 30 Jul 2015 16:55:45 +0200
+Subject: [PATCH] build-sys: check for mallinfo
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+mallinfo is not specified by POSIX or the C standards, therefore
+it's not available for all libc libraries (musl).
+
+Add the ability to disable mallinfo statistics.
+
+Fixes:
+selinux-util.c: In function ?mac_selinux_init?:
+selinux-util.c:70:25: error: storage size of ?before_mallinfo? isn?t known
+         struct mallinfo before_mallinfo, after_mallinfo;
+
+Signed-off-by: Romain Naour <[email protected]>
+---
+ configure.ac              | 3 +++
+ src/shared/selinux-util.c | 8 ++++++++
+ 2 files changed, 11 insertions(+)
+
+diff --git a/configure.ac b/configure.ac
+index ec23ab5..4889b91 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -226,6 +226,9 @@ else
+ fi
+ AC_SUBST(sushell)
+ 
++# selinux-util.c use struct mallinfo which is not available for all C libraries (musl).
++AC_CHECK_FUNCS([mallinfo])
++
+ # ------------------------------------------------------------------------------
+ 
+ AC_CHECK_DECL([unshare],
+diff --git a/src/shared/selinux-util.c b/src/shared/selinux-util.c
+index 756215e..c811235 100644
+--- a/src/shared/selinux-util.c
++++ b/src/shared/selinux-util.c
+@@ -66,8 +66,10 @@ int mac_selinux_init(const char *prefix) {
+         int r = 0;
+ 
+ #ifdef HAVE_SELINUX
++#ifdef HAVE_MALLINFO
+         usec_t before_timestamp, after_timestamp;
+         struct mallinfo before_mallinfo, after_mallinfo;
++#endif
+ 
+         if (!mac_selinux_use())
+                 return 0;
+@@ -75,8 +77,10 @@ int mac_selinux_init(const char *prefix) {
+         if (label_hnd)
+                 return 0;
+ 
++#ifdef HAVE_MALLINFO
+         before_mallinfo = mallinfo();
+         before_timestamp = now(CLOCK_MONOTONIC);
++#endif
+ 
+         if (prefix) {
+                 struct selinux_opt options[] = {
+@@ -91,6 +95,7 @@ int mac_selinux_init(const char *prefix) {
+                 log_enforcing("Failed to initialize SELinux context: %m");
+                 r = security_getenforce() == 1 ? -errno : 0;
+         } else  {
++#ifdef HAVE_MALLINFO
+                 char timespan[FORMAT_TIMESPAN_MAX];
+                 int l;
+ 
+@@ -102,6 +107,9 @@ int mac_selinux_init(const char *prefix) {
+                 log_debug("Successfully loaded SELinux database in %s, size on heap is %iK.",
+                           format_timespan(timespan, sizeof(timespan), after_timestamp - before_timestamp, 0),
+                           (l+1023)/1024);
++#else
++                log_debug("Successfully loaded SELinux database");
++#endif
+         }
+ #endif
+ 
+-- 
+2.4.3
+
package/eudev/0003-build-sys-check-for-strndupa.patch new file +69 -0

69 lines not on this page · raw message

package/eudev/eudev.mk +5 -0
index f587acd..b916acd 100644
@@ -11,6 +11,11 @@ EUDEV_LICENSE = GPLv2+ (programs), LGPLv2.1+ (libraries)
 EUDEV_LICENSE_FILES = COPYING
 EUDEV_INSTALL_STAGING = YES
 
+# configure.ac is patched by:
+# 0002-build-sys-check-for-mallinfo.patch
+# 0003-build-sys-check-for-strndupa.patch
+EUDEV_AUTORECONF = YES
+
 # mq_getattr is in librt
 EUDEV_CONF_ENV += LIBS=-lrt
 
Signature · 1 line
2.4.3
#2 lore raw

PATCH v2 2/2 package/eudev: fix build with musl + libselinux

Dear Romain Naour,

Quoted 3 lines · Romain Naour

+ #ifdef HAVE_SELINUX
++#ifdef HAVE_MALLINFO
+ usec_t before_timestamp, after_timestamp;

Why do you enclose the timestamp stuff inside HAVE_MALLINFO ? It is unrelated.

package/eudev/0002-build-sys-check-for-mallinfo.patch line 60

Quoted 12 lines
package/eudev/0002-build-sys-check-for-mallinfo.patch new file +12 -0
+         struct mallinfo before_mallinfo, after_mallinfo;
++#endif
+ 
+         if (!mac_selinux_use())
+                 return 0;
+@@ -75,8 +77,10 @@ int mac_selinux_init(const char *prefix) {
+         if (label_hnd)
+                 return 0;
+ 
++#ifdef HAVE_MALLINFO
+         before_mallinfo = mallinfo();
+         before_timestamp = now(CLOCK_MONOTONIC);

Ditto.

Quoted 8 lines

++#endif
+

package/eudev/0002-build-sys-check-for-mallinfo.patch new file +6 -0
+         if (prefix) {
+                 struct selinux_opt options[] = {
+@@ -91,6 +95,7 @@ int mac_selinux_init(const char *prefix) {
+                 log_enforcing("Failed to initialize SELinux context: %m");
+                 r = security_getenforce() == 1 ? -errno : 0;
+         } else  {

package/eudev/0002-build-sys-check-for-mallinfo.patch line 78

Quoted 10 lines
package/eudev/0002-build-sys-check-for-mallinfo.patch new file +10 -0
++#ifdef HAVE_MALLINFO
+                 char timespan[FORMAT_TIMESPAN_MAX];
+                 int l;
+ 
+@@ -102,6 +107,9 @@ int mac_selinux_init(const char *prefix) {
+                 log_debug("Successfully loaded SELinux database in %s, size on heap is %iK.",
+                           format_timespan(timespan, sizeof(timespan), after_timestamp - before_timestamp, 0),
+                           (l+1023)/1024);
++#else
++                log_debug("Successfully loaded SELinux database");

Ditto.

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
#3 lore raw

PATCH v2 2/2 package/eudev: fix build with musl + libselinux

Hi Thomas,

Le 30/07/2015 22:59, Thomas Petazzoni a ?crit :

Quoted 10 lines

Dear Romain Naour,

Quoted 3 lines · Romain Naour

+ #ifdef HAVE_SELINUX
++#ifdef HAVE_MALLINFO
+ usec_t before_timestamp, after_timestamp;

Why do you enclose the timestamp stuff inside HAVE_MALLINFO ? It is unrelated.

That's because I enclosed the "else" content containing the full log_debug() inside HAVE_MALLINFO...

Ok, I'll resend this one.

Best regards,
Romain

Quoted 39 lines

package/eudev/0002-build-sys-check-for-mallinfo.patch line 60

Quoted 13 lines
package/eudev/0002-build-sys-check-for-mallinfo.patch new file +12 -0
+         struct mallinfo before_mallinfo, after_mallinfo;
++#endif
+ 
+         if (!mac_selinux_use())
+                 return 0;
+@@ -75,8 +77,10 @@ int mac_selinux_init(const char *prefix) {
+         if (label_hnd)
+                 return 0;
+ 
++#ifdef HAVE_MALLINFO
+         before_mallinfo = mallinfo();
+         before_timestamp = now(CLOCK_MONOTONIC);

Ditto.

Quoted 8 lines

++#endif
+

package/eudev/0002-build-sys-check-for-mallinfo.patch new file +6 -0
+         if (prefix) {
+                 struct selinux_opt options[] = {
+@@ -91,6 +95,7 @@ int mac_selinux_init(const char *prefix) {
+                 log_enforcing("Failed to initialize SELinux context: %m");
+                 r = security_getenforce() == 1 ? -errno : 0;
+         } else  {

package/eudev/0002-build-sys-check-for-mallinfo.patch line 78

Quoted 10 lines
package/eudev/0002-build-sys-check-for-mallinfo.patch new file +10 -0
++#ifdef HAVE_MALLINFO
+                 char timespan[FORMAT_TIMESPAN_MAX];
+                 int l;
+ 
+@@ -102,6 +107,9 @@ int mac_selinux_init(const char *prefix) {
+                 log_debug("Successfully loaded SELinux database in %s, size on heap is %iK.",
+                           format_timespan(timespan, sizeof(timespan), after_timestamp - before_timestamp, 0),
+                           (l+1023)/1024);
++#else
++                log_debug("Successfully loaded SELinux database");

Ditto.

Thomas

#4 lore raw

PATCH v2 2/2 package/eudev: fix build with musl + libselinux

Dear Romain Naour,

Quoted 2 lines · Romain Naour

That's because I enclosed the "else" content containing the full log_debug() inside HAVE_MALLINFO...

Yes, but that's what I'm criticizing :-)

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
#5 lore raw

PATCH v2 1/2 package/eudev: add libselinux dependency

In reply to Romain Naour

Dear Romain Naour,

Quoted 7 lines · Romain Naour
Cc Clayton Shotwell <[email protected]>

---
v2: Don't disable selinux support for musl toolchains (Thomas)

---
 package/eudev/eudev.mk | 7 +++++++
 1 file changed, 7 insertions(+)

Applied, thanks.

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com