meta-selinux/recipes-security/selinux/libsemanage/libsemanage-allow-to-disable-audit-support.patch
Yi Zhao 4273eb6d6e selinux: upgrade 3.7 -> 3.8
ChangeLog:
https://github.com/SELinuxProject/selinux/releases/tag/3.8

* libsemanage: Preserve file context and ownership in policy store
* libselinux: deprecate security_disable(3)
* libsepol: Support nlmsg extended permissions
* libsepol: Add policy capability netlink_xperm
* libsemanage: Optionally allow duplicate declarations
* policycoreutils: introduce unsetfiles
* libselinux/utils: introduce selabel_compare
* improved selabel_lookup performance
* libselinux: support parallel usage of selabel_lookup(3)
* libsepol: add support for xperms in conditional policies
* Improved man pages
* Code improvements and bug fixes
* Always build for LFS mode on 32-bit archs.
* libsemanage: Mute error messages from selinux_restorecon introduced in
  3.8-rc1
* Regex spec ordering is restored to pre 3.8-rc1
* Binary fcontext files format changed, files using old format are ignored
* Code improvements and bug fixes

License-Update: White space cleanup for libsemanage/LICENSE

Signed-off-by: Yi Zhao <yi.zhao@windriver.com>
Signed-off-by: Joe MacDonald <joe.macdonald@siemens.com>
2025-03-07 14:34:45 -05:00

127 lines
3.6 KiB
Diff

From 0fddb654b4193e91b8534cbbeaa5fd9b6aa1ead2 Mon Sep 17 00:00:00 2001
From: Wenzong Fan <wenzong.fan@windriver.com>
Date: Mon, 20 Jan 2014 03:53:48 -0500
Subject: [PATCH] libsemanage: allow to disable audit support
Upstream-Status: Inappropriate [embedded specific]
Signed-off-by: Wenzong Fan <wenzong.fan@windriver.com>
---
src/Makefile | 10 +++++++++-
src/seusers_local.c | 13 +++++++++++++
tests/Makefile | 10 +++++++++-
3 files changed, 31 insertions(+), 2 deletions(-)
diff --git a/src/Makefile b/src/Makefile
index 8dfbd76..4012f28 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -27,6 +27,14 @@ ifeq ($(DEBUG),1)
export LDFLAGS ?= -g
endif
+DISABLE_AUDIT ?= n
+ifeq ($(DISABLE_AUDIT),y)
+ LIBAUDIT =
+ CFLAGS += -DDISABLE_AUDIT
+else
+ LIBAUDIT = -laudit
+endif
+
LEX = flex
LFLAGS = -s
YACC = bison
@@ -90,7 +98,7 @@ $(LIBA): $(OBJS)
$(RANLIB) $@
$(LIBSO): $(LOBJS)
- $(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) -shared -o $@ $^ -lsepol -laudit -lselinux -lbz2 -Wl,-soname,$(LIBSO),--version-script=libsemanage.map,-z,defs
+ $(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) -shared -o $@ $^ -lsepol $(LIBAUDIT) -lselinux -lbz2 -Wl,-soname,$(LIBSO),--version-script=libsemanage.map,-z,defs
ln -sf $@ $(TARGET)
$(LIBPC): $(LIBPC).in ../VERSION
diff --git a/src/seusers_local.c b/src/seusers_local.c
index eb3f82b..45da825 100644
--- a/src/seusers_local.c
+++ b/src/seusers_local.c
@@ -8,7 +8,11 @@ typedef struct semanage_seuser record_t;
#include <sepol/policydb.h>
#include <sepol/context.h>
+
+#ifndef DISABLE_AUDIT
#include <libaudit.h>
+#endif
+
#include <errno.h>
#include "user_internal.h"
#include "seuser_internal.h"
@@ -56,6 +60,7 @@ static char *semanage_user_roles(semanage_handle_t * handle, const char *sename)
return roles;
}
+#ifndef DISABLE_AUDIT
static int semanage_seuser_audit(semanage_handle_t * handle,
const semanage_seuser_t * seuser,
const semanage_seuser_t * previous,
@@ -120,6 +125,7 @@ err:
free(proles);
return rc;
}
+#endif
int semanage_seuser_modify_local(semanage_handle_t * handle,
const semanage_seuser_key_t * key,
@@ -165,8 +171,11 @@ int semanage_seuser_modify_local(semanage_handle_t * handle,
(void) semanage_seuser_query(handle, key, &previous);
handle->msg_callback = callback;
rc = dbase_modify(handle, dconfig, key, new);
+
+#ifndef DISABLE_AUDIT
if (semanage_seuser_audit(handle, new, previous, AUDIT_ROLE_ASSIGN, rc == 0) < 0)
rc = -1;
+#endif
err:
if (previous)
semanage_seuser_free(previous);
@@ -182,8 +191,12 @@ int semanage_seuser_del_local(semanage_handle_t * handle,
dbase_config_t *dconfig = semanage_seuser_dbase_local(handle);
rc = dbase_del(handle, dconfig, key);
semanage_seuser_query(handle, key, &seuser);
+
+#ifndef DISABLE_AUDIT
if (semanage_seuser_audit(handle, NULL, seuser, AUDIT_ROLE_REMOVE, rc == 0) < 0)
rc = -1;
+#endif
+
if (seuser)
semanage_seuser_free(seuser);
return rc;
diff --git a/tests/Makefile b/tests/Makefile
index 241ff17..fa03fb6 100644
--- a/tests/Makefile
+++ b/tests/Makefile
@@ -4,10 +4,18 @@ CILS = $(sort $(wildcard *.cil))
###########################################################################
+DISABLE_AUDIT ?= n
+ifeq ($(DISABLE_AUDIT),y)
+ LIBAUDIT =
+ CFLAGS += -DDISABLE_AUDIT
+else
+ LIBAUDIT = -laudit
+endif
+
EXECUTABLE = libsemanage-tests
CFLAGS += -g -O0 -Wall -W -Wundef -Wmissing-noreturn -Wmissing-format-attribute
override CFLAGS += -I../src -I../include
-override LDLIBS += -lcunit -lbz2 -laudit -lselinux -lsepol
+override LDLIBS += -lcunit -lbz2 $(LIBAUDIT) -lselinux -lsepol
OBJECTS = $(SOURCES:.c=.o)
POLICIES = $(CILS:.cil=.policy)
--
2.25.1