Skip to contentSkip to conversation

Update for libselinux embedded build support

PATCH In review Yuichi Nakamura 2 participants 3 messages Jul 25, 2007 – Jul 30, 2007

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Update for libselinux embedded build support

Hi.

Recently, some userspace AVC features are merged to libselinux. I found make EMBEDDED=y fails due to that.
So I've updated "make EMBEDDED=y" support for libselinux.

src/Makefile +1 -1
Index: libselinux/src/Makefile
===================================================================
@@ -20,7 +20,7 @@
 LIBSO=$(TARGET).$(LIBVERSION)
 
 ifeq ($(DISABLE_AVC),y)
-	UNUSED_SRCS+=avc.c avc_internal.c avc_sidtab.c 
+	UNUSED_SRCS+=avc.c avc_internal.c avc_sidtab.c mapping.c stringrep.c checkAccess.c
 endif
 ifeq ($(DISABLE_BOOL),y)
 	UNUSED_SRCS+=booleans.c
src/compute_create.c +5 -0
Index: libselinux/src/compute_create.c
===================================================================
@@ -36,7 +36,12 @@
 		ret = -1;
 		goto out;
 	}
+
+#ifdef DISABLE_AVC
+	snprintf(buf, size, "%s %s %hu", scon, tcon, tclass);
+#else
 	snprintf(buf, size, "%s %s %hu", scon, tcon, unmap_class(tclass));
+#endif
 
 	ret = write(fd, buf, strlen(buf));
 	if (ret < 0)
src/compute_member.c +5 -0
Index: libselinux/src/compute_member.c
===================================================================
@@ -36,7 +36,12 @@
 		ret = -1;
 		goto out;
 	}
+
+#ifdef DISABLE_AVC
+	snprintf(buf, size, "%s %s %hu", scon, tcon, tclass);
+#else
 	snprintf(buf, size, "%s %s %hu", scon, tcon, unmap_class(tclass));
+#endif
 
 	ret = write(fd, buf, strlen(buf));
 	if (ret < 0)
src/compute_relabel.c +5 -0
Index: libselinux/src/compute_relabel.c
===================================================================
@@ -36,7 +36,12 @@
 		ret = -1;
 		goto out;
 	}
+
+#ifdef DISABLE_AVC
+	snprintf(buf, size, "%s %s %hu", scon, tcon, tclass);
+#else
 	snprintf(buf, size, "%s %s %hu", scon, tcon, unmap_class(tclass));
+#endif
 
 	ret = write(fd, buf, strlen(buf));
 	if (ret < 0)
src/compute_av.c +7 -0
Index: libselinux/src/compute_av.c
===================================================================
@@ -37,8 +37,13 @@
 		goto out;
 	}
 
+#ifdef DISABLE_AVC
 	snprintf(buf, len, "%s %s %hu %x", scon, tcon,
+		 tclass, requested);
+#else
+	snprintf(buf, len, "%s %s %hu %x", scon, tcon,
 		 unmap_class(tclass), unmap_perm(tclass, requested));
+#endif
 
 	ret = write(fd, buf, strlen(buf));
 	if (ret < 0)
@@ -56,7 +61,9 @@
 		goto out2;
 	}
 
+#ifndef DISABLE_AVC
 	map_decision(tclass, avd);
+#endif
 
 	ret = 0;
       out2:
Makefile +3 -0
Index: libselinux/Makefile
===================================================================
@@ -8,6 +8,9 @@
 	override DISABLE_RPM=y
 	override DISABLE_BOOL=y
 endif
+ifeq ($(DISABLE_AVC),y)
+	EMFLAGS+= -DDISABLE_AVC
+endif
 ifeq ($(DISABLE_BOOL),y)
 	EMFLAGS+= -DDISABLE_BOOL
 endif

Regards,

Signature · 10 lines
Yuichi Nakamura
Hitachi Software Engineering Co., Ltd.
Japan SELinux Users Group(JSELUG): http://www.selinux.gr.jp/
SELinux Policy Editor: http://seedit.sourceforge.net/


--
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.
#1 lore raw
Quoted 24 lines · Yuichi Nakamura

Hi.

Recently, some userspace AVC features are merged to libselinux. I found make EMBEDDED=y fails due to that.
So I've updated "make EMBEDDED=y" support for libselinux.

Index: libselinux/src/Makefile
===================================================================

src/Makefile +1 -1
@@ -20,7 +20,7 @@
 LIBSO=$(TARGET).$(LIBVERSION)
 
 ifeq ($(DISABLE_AVC),y)
-	UNUSED_SRCS+=avc.c avc_internal.c avc_sidtab.c 
+	UNUSED_SRCS+=avc.c avc_internal.c avc_sidtab.c mapping.c stringrep.c checkAccess.c
 endif
 ifeq ($(DISABLE_BOOL),y)
 	UNUSED_SRCS+=booleans.c

Index: libselinux/src/compute_create.c
===================================================================

src/compute_create.c line 44

Quoted 9 lines
src/compute_create.c +5 -0
@@ -36,7 +36,12 @@
 		ret = -1;
 		goto out;
 	}
+
+#ifdef DISABLE_AVC
+	snprintf(buf, size, "%s %s %hu", scon, tcon, tclass);
+#else
 	snprintf(buf, size, "%s %s %hu", scon, tcon, unmap_class(tclass));
+#endif

As with the kernel, we don't want #ifdef's sprinkled through the code. Instead, just #define unmap_class(x) x and #define unmap_perm(x,y) y in mapping.h #ifdef DISABLE_AVC.

Quoted 84 lines
src/compute_create.c +0 -0
 	ret = write(fd, buf, strlen(buf));
 	if (ret < 0)

Index: libselinux/src/compute_member.c
===================================================================

src/compute_member.c +5 -0
@@ -36,7 +36,12 @@
 		ret = -1;
 		goto out;
 	}
+
+#ifdef DISABLE_AVC
+	snprintf(buf, size, "%s %s %hu", scon, tcon, tclass);
+#else
 	snprintf(buf, size, "%s %s %hu", scon, tcon, unmap_class(tclass));
+#endif
 
 	ret = write(fd, buf, strlen(buf));
 	if (ret < 0)

Index: libselinux/src/compute_relabel.c
===================================================================

src/compute_relabel.c +5 -0
@@ -36,7 +36,12 @@
 		ret = -1;
 		goto out;
 	}
+
+#ifdef DISABLE_AVC
+	snprintf(buf, size, "%s %s %hu", scon, tcon, tclass);
+#else
 	snprintf(buf, size, "%s %s %hu", scon, tcon, unmap_class(tclass));
+#endif
 
 	ret = write(fd, buf, strlen(buf));
 	if (ret < 0)

Index: libselinux/src/compute_av.c
===================================================================

src/compute_av.c +7 -0
@@ -37,8 +37,13 @@
 		goto out;
 	}
 
+#ifdef DISABLE_AVC
 	snprintf(buf, len, "%s %s %hu %x", scon, tcon,
+		 tclass, requested);
+#else
+	snprintf(buf, len, "%s %s %hu %x", scon, tcon,
 		 unmap_class(tclass), unmap_perm(tclass, requested));
+#endif
 
 	ret = write(fd, buf, strlen(buf));
 	if (ret < 0)
@@ -56,7 +61,9 @@
 		goto out2;
 	}
 
+#ifndef DISABLE_AVC
 	map_decision(tclass, avd);
+#endif
 
 	ret = 0;
       out2:

Index: libselinux/Makefile
===================================================================

Makefile +3 -0
@@ -8,6 +8,9 @@
 	override DISABLE_RPM=y
 	override DISABLE_BOOL=y
 endif
+ifeq ($(DISABLE_AVC),y)
+	EMFLAGS+= -DDISABLE_AVC
+endif
 ifeq ($(DISABLE_BOOL),y)
 	EMFLAGS+= -DDISABLE_BOOL
 endif

Regards,

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.
#2 lore raw
Quoted 1 line · On Wed, 25 Jul 2007 08:47:40 -0400 Stephen Smalley wrote:

On Wed, 2007-07-25 at 12:10 +0900, Yuichi Nakamura wrote:

...

Quoted 10 lines
Quoted 10 lines

Index: libselinux/src/compute_create.c
===================================================================

src/compute_create.c +2 -0
@@ -36,7 +36,12 @@
 		ret = -1;
 		goto out;
 	}
+
+#ifdef DISABLE_AVC
Quoted 8 lines

src/compute_create.c line 44

Quoted 4 lines
src/compute_create.c +3 -0
+	snprintf(buf, size, "%s %s %hu", scon, tcon, tclass);
+#else
 	snprintf(buf, size, "%s %s %hu", scon, tcon, unmap_class(tclass));
+#endif

As with the kernel, we don't want #ifdef's sprinkled through the code. Instead, just #define unmap_class(x) x and #define unmap_perm(x,y) y in mapping.h #ifdef DISABLE_AVC.

Fixed, below is updated patch.

src/Makefile +1 -1
Index: libselinux/src/Makefile
===================================================================
@@ -20,7 +20,7 @@
 LIBSO=$(TARGET).$(LIBVERSION)
 
 ifeq ($(DISABLE_AVC),y)
-	UNUSED_SRCS+=avc.c avc_internal.c avc_sidtab.c 
+	UNUSED_SRCS+=avc.c avc_internal.c avc_sidtab.c mapping.c stringrep.c checkAccess.c
 endif
 ifeq ($(DISABLE_BOOL),y)
 	UNUSED_SRCS+=booleans.c
src/mapping.h +7 -0
Index: libselinux/src/mapping.h
===================================================================
@@ -31,4 +31,11 @@
 extern void
 map_decision(security_class_t tclass, struct av_decision *avd);
 
+/*mapping is not used for embedded build*/
+#ifdef DISABLE_AVC 
+#define unmap_perm(x,y) y
+#define unmap_class(x) x
+#define map_decision(x,y) 
+#endif
+
 #endif				/* _SELINUX_MAPPING_H_ */
Makefile +3 -0
Index: libselinux/Makefile
===================================================================
@@ -8,6 +8,9 @@
 	override DISABLE_RPM=y
 	override DISABLE_BOOL=y
 endif
+ifeq ($(DISABLE_AVC),y)
+	EMFLAGS+= -DDISABLE_AVC
+endif
 ifeq ($(DISABLE_BOOL),y)
 	EMFLAGS+= -DDISABLE_BOOL
 endif

Regards,

Signature · 11 lines
Yuichi Nakamura
Hitachi Software Engineering Co., Ltd.
Japan SELinux Users Group(JSELUG): http://www.selinux.gr.jp/
SELinux Policy Editor: http://seedit.sourceforge.net/



--
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.