@@ -34,6 +34,12 @@ PCRE_CFLAGS += $(shell $(PKG_CONFIG) --cflags $(PCRE_MODULE))
PCRE_LDLIBS := $(shell $(PKG_CONFIG) --libs $(PCRE_MODULE))
export PCRE_MODULE PCRE_CFLAGS PCRE_LDLIBS
+USE_LFS ?= y
+ifeq ($(USE_LFS),y)
+ LFS_CFLAGS := -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64
+endif
+export LFS_CFLAGS
+
OS := $(shell uname)
export OS
@@ -1,8 +1,10 @@
#ifndef _SELINUX_H_
#define _SELINUX_H_
+#include <stdint.h>
#include <sys/types.h>
#include <stdarg.h>
+#include <asm/bitsperlong.h>
#ifdef __cplusplus
extern "C" {
@@ -535,6 +537,9 @@ extern int matchpathcon_index(const char *path,
with the same inode (e.g. due to multiple hard links). If so, then
use the latter of the two specifications based on their order in the
file contexts configuration. Return the used specification index. */
+#if defined(_FILE_OFFSET_BITS) && _FILE_OFFSET_BITS == 64 && __BITS_PER_LONG < 64
+#define matchpathcon_filespec_add matchpathcon_filespec_add64
+#endif
extern int matchpathcon_filespec_add(ino_t ino, int specind, const char *file);
/* Destroy any inode associations that have been added, e.g. to restart
@@ -89,6 +89,8 @@ CFLAGS ?= -O -Wall -W -Wundef -Wformat-y2k -Wformat-security -Winit-self -Wmissi
-Werror -Wno-aggregate-return \
$(EXTRA_CFLAGS)
+override CFLAGS += $(LFS_CFLAGS)
+
LD_SONAME_FLAGS=-soname,$(LIBSO),--version-script=libselinux.map,-z,defs,-z,relro
ifeq ($(OS), Darwin)
@@ -252,3 +252,8 @@ LIBSELINUX_3.5 {
getpidprevcon;
getpidprevcon_raw;
} LIBSELINUX_3.4;
+
+LIBSELINUX_3.8 {
+ global:
+ matchpathcon_filespec_add64;
+} LIBSELINUX_3.5;
@@ -1,3 +1,4 @@
+#include <assert.h>
#include <sys/stat.h>
#include <string.h>
#include <errno.h>
@@ -261,6 +262,31 @@ int matchpathcon_filespec_add(ino_t ino, int specind, const char *file)
return -1;
}
+#if defined(_FILE_OFFSET_BITS) && _FILE_OFFSET_BITS == 64 && __BITS_PER_LONG < 64
+/* alias defined in the public header but we undefine it here */
+#undef matchpathcon_filespec_add
+
+/* ABI backwards-compatible shim for non-LFS 32-bit systems */
+
+static_assert(sizeof(unsigned long) == sizeof(__ino_t), "inode size mismatch");
+static_assert(sizeof(unsigned long) == sizeof(uint32_t), "inode size mismatch");
+static_assert(sizeof(ino_t) == sizeof(ino64_t), "inode size mismatch");
+static_assert(sizeof(ino64_t) == sizeof(uint64_t), "inode size mismatch");
+
+extern int matchpathcon_filespec_add(unsigned long ino, int specind,
+ const char *file);
+
+int matchpathcon_filespec_add(unsigned long ino, int specind,
+ const char *file)
+{
+ return matchpathcon_filespec_add64(ino, specind, file);
+}
+#else
+
+static_assert(sizeof(unsigned long) == sizeof(ino_t), "inode size mismatch");
+
+#endif
+
/*
* Evaluate the association hash table distribution.
*/
@@ -36,6 +36,8 @@ CFLAGS ?= -O -Wall -W -Wundef -Wformat-y2k -Wformat-security -Winit-self -Wmissi
-Werror -Wno-aggregate-return -Wno-redundant-decls -Wstrict-overflow=5 \
$(EXTRA_CFLAGS)
+override CFLAGS += $(LFS_CFLAGS)
+
ifeq ($(OS), Darwin)
override CFLAGS += -I/opt/local/include -I../../libsepol/include
override LDFLAGS += -L../../libsepol/src -undefined dynamic_lookup