Skip to contentSkip to conversation

Adding audit message to newrole

PATCH Steve G 2 participants 2 messages Jan 27, 2006 SELinux security module

lore
Share & tools
lore

Steve G

author
#0 lore raw

Hi,

I am attaching a patch that lets newrole send messages to the audit system. This patch needs review as it changes newrole to be setuid root. The patch drops capabilities immediately after startup.

To enable the patch, you would change the make commands to the following:

make LOG_AUDIT_PRIV="y"
make LOG_AUDIT_PRIV="y" install

You will need recent audit package in order to compile newrole since it uses the USER_ROLE_CHANGE message type. It is available in version 1.1.2 and later. There is also a dependency on a kernel patch that is not upstream yet that can be found here:

https://www.redhat.com/archives/linux-audit/2005-October/msg00059.html

This patch is in the lspp test kernels.

Thanks,
-Steve

__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com

newrole/Makefile +12 -1
diff -ur policycoreutils-1.29.11.orig/newrole/Makefile policycoreutils-1.29.11/newrole/Makefile
@@ -6,6 +6,10 @@
 LOCALEDIR = /usr/share/locale
 PAMH = $(shell ls /usr/include/security/pam_appl.h 2>/dev/null)
 AUDITH = $(shell ls /usr/include/libaudit.h 2>/dev/null)
+# If LOG_AUDIT_PRIV is y, then newrole will be made into setuid root program.
+# This is so that we have the CAP_AUDIT_WRITE capability. newrole will
+# shed all privileges and change to the user's uid.
+LOG_AUDIT_PRIV ?= n
 
 CFLAGS ?= -Werror -Wall -W
 override CFLAGS += $(LDFLAGS) -I$(PREFIX)/include -DUSE_NLS -DLOCALEDIR="\"$(LOCALEDIR)\"" -DPACKAGE="\"policycoreutils\""
@@ -21,6 +25,13 @@
 	override CFLAGS += -DUSE_AUDIT
 	LDLIBS += -laudit
 endif
+ifeq (${LOG_AUDIT_PRIV},y)
+	override CFLAGS += -DLOG_AUDIT_PRIV -D_GNU_SOURCE
+	LDLIBS += -lcap
+	MODE := 4555
+else
+	MODE := 555
+endif
 
 TARGETS=$(patsubst %.c,%,$(wildcard *.c))
 
@@ -30,7 +41,7 @@
 	test -d $(BINDIR)      || install -m 755 -d $(BINDIR)
 	test -d $(ETCDIR)/pam.d || install -m 755 -d $(ETCDIR)/pam.d
 	test -d $(MANDIR)/man1 || install -m 755 -d $(MANDIR)/man1
-	install -m 555 newrole $(BINDIR)
+	install -m $(MODE) newrole $(BINDIR)
 	install -m 644 newrole.1 $(MANDIR)/man1/
 ifeq (${PAMH}, /usr/include/security/pam_appl.h)
 	test -d $(ETCDIR)/pam.d || install -m 755 -d $(ETCDIR)/pam.d
newrole/newrole.c +96 -2

128 lines not on this page · raw message

#1 lore raw
Quoted 11 lines · Steve G

Hi,

I am attaching a patch that lets newrole send messages to the audit system. This patch needs review as it changes newrole to be setuid root. The patch drops capabilities immediately after startup.

To enable the patch, you would change the make commands to the following:

make LOG_AUDIT_PRIV="y"
make LOG_AUDIT_PRIV="y" install

Quoted 8 lines

You will need recent audit package in order to compile newrole since it uses the USER_ROLE_CHANGE message type. It is available in version 1.1.2 and later. There is also a dependency on a kernel patch that is not upstream yet that can be found here:

https://www.redhat.com/archives/linux-audit/2005-October/msg00059.html

This patch is in the lspp test kernels.

Thanks, merged as of policycoreutils 1.29.15.
Note: Do not build with LOG_AUDIT_PRIV=y unless the kernel includes the necessary patch (which is not in the Fedora kernel yet, only in the LSPP kernel). This is disabled by default (LOG_AUDIT_PRIV=n).

Signature · 8 lines
Stephen Smalley
National Security Agency


--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to [email protected] with
the words "unsubscribe selinux" without quotes as the message.