[yocto] [meta-selinux][RFC 03/10] e2fsprogs: Add bbappend and apply initial xattr patch.

Philip Tricca flihp at twobit.us
Sat Jun 6 17:37:01 PDT 2015


Signed-off-by: Philip Tricca <flihp at twobit.us>
---
 .../e2fsprogs/misc-xattr-copy-xattrs.patch         | 69 ++++++++++++++++++++++
 .../e2fsprogs/e2fsprogs_1.42.9.bbappend            |  5 ++
 2 files changed, 74 insertions(+)
 create mode 100644 recipes-devtools/e2fsprogs/e2fsprogs/misc-xattr-copy-xattrs.patch
 create mode 100644 recipes-devtools/e2fsprogs/e2fsprogs_1.42.9.bbappend

diff --git a/recipes-devtools/e2fsprogs/e2fsprogs/misc-xattr-copy-xattrs.patch b/recipes-devtools/e2fsprogs/e2fsprogs/misc-xattr-copy-xattrs.patch
new file mode 100644
index 0000000..7423c4e
--- /dev/null
+++ b/recipes-devtools/e2fsprogs/e2fsprogs/misc-xattr-copy-xattrs.patch
@@ -0,0 +1,69 @@
+Copy xattr blocks as part of the '-d' option to mke2fs. Initial implementation
+only supports xattrs with the 'security.' prefix. Copying xattrs is necessary
+to boot SELinux images without setting labels on firstboot.
+
+To build the xattr disk block we process the output from listxattr and
+lgetxattr from the source file system object. It's then associated with the
+inode and written to disk. ext2|3|4 saves space by allowing inodes to share
+identical xattr blocks. We maintain a primitive cache (a linked list) of the
+existing xattr blocks and only create new ones when when we must.
+
+Currently this cache keeps the full xattr block around on the heap so it's
+pretty inefficient. Still, the memory overhead is only on the order of single
+digit megabytes for core-image-selinux.
+
+TODO:
+  - Test additional xattrs with the 'security.' prefix like IMA.
+
+Signed-off-by: Philip Tricca <flihp at twobit.us>
+
+Index: e2fsprogs-1.42.9/misc/xattr.c
+===================================================================
+--- /dev/null
++++ e2fsprogs-1.42.9/misc/xattr.c
+@@ -0,0 +1,34 @@
++#include "xattr.h"
++
++#include <stdio.h>
++
++#ifdef XATTR_DEBUG
++#define XATTR_STDERR(fmt, args...) fprintf (stderr, fmt, ##args)
++#else
++#define XATTR_STDERR(fmt, args...) do {} while (0)
++#endif
++
++
++/* Free remaining resources after all files have been processed. */
++void
++xattr_cleanup ()
++{
++	XATTR_STDERR ("Cleaning up resources from xattrs.\n");
++}
++
++/* This is the entry point to the xattr module. This function copies the xattrs
++ * from the file at 'path' to the file system object at 'ino'.
++ *
++ * Parameters:
++ *   fs:  the file system object for the fs we're operating on
++ *   ino: inode for the object we're labeling
++ *   path: path to the object we're copying xattrs from
++ */
++errcode_t
++set_inode_xattr (ext2_filsys fs, ext2_ino_t ino, const char *path)
++{
++	errcode_t ret = 0;
++
++	XATTR_STDERR ("Copying xattrs from %s to inode 0x%x.\n", path, ino);
++	return ret;
++}
+Index: e2fsprogs-1.42.9/misc/xattr.h
+===================================================================
+--- /dev/null
++++ e2fsprogs-1.42.9/misc/xattr.h
+@@ -0,0 +1,6 @@
++#include "et/com_err.h"
++#include "ext2fs/ext2fs.h"
++
++/* Copy xattrs from source file to destination inode */
++errcode_t set_inode_xattrs(ext2_filsys fs, ext2_ino_t ino, const char *name);
++void xattr_cleanup ();
diff --git a/recipes-devtools/e2fsprogs/e2fsprogs_1.42.9.bbappend b/recipes-devtools/e2fsprogs/e2fsprogs_1.42.9.bbappend
new file mode 100644
index 0000000..7f0198e
--- /dev/null
+++ b/recipes-devtools/e2fsprogs/e2fsprogs_1.42.9.bbappend
@@ -0,0 +1,5 @@
+FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:"
+
+SRC_URI += " \
+    file://misc-xattr-copy-xattrs.patch \
+"
-- 
2.1.4




More information about the yocto mailing list