summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris PeBenito <pebenito@gentoo.org>2009-08-24 18:36:16 +0000
committerChris PeBenito <pebenito@gentoo.org>2009-08-24 18:36:16 +0000
commit4ee1e0d0ced405ef4c8e109d00a629d4fe082dfc (patch)
tree724854cad184622bef7ec1a77d59a2f217f917bf /sys-libs/libsemanage
parentAdd ChangeLog entries (diff)
downloadgentoo-2-4ee1e0d0ced405ef4c8e109d00a629d4fe082dfc.tar.gz
gentoo-2-4ee1e0d0ced405ef4c8e109d00a629d4fe082dfc.tar.bz2
gentoo-2-4ee1e0d0ced405ef4c8e109d00a629d4fe082dfc.zip
sys-libs/libsemanage: Add patch to make bzip2 compression configurable.
(Portage version: 2.2_rc38/cvs/Linux x86_64)
Diffstat (limited to 'sys-libs/libsemanage')
-rw-r--r--sys-libs/libsemanage/ChangeLog8
-rw-r--r--sys-libs/libsemanage/files/libsemanage-2.0.33-bzip.diff245
-rw-r--r--sys-libs/libsemanage/libsemanage-2.0.33-r1.ebuild81
3 files changed, 333 insertions, 1 deletions
diff --git a/sys-libs/libsemanage/ChangeLog b/sys-libs/libsemanage/ChangeLog
index a1400d855918..384550e5f6c6 100644
--- a/sys-libs/libsemanage/ChangeLog
+++ b/sys-libs/libsemanage/ChangeLog
@@ -1,6 +1,12 @@
# ChangeLog for sys-libs/libsemanage
# Copyright 1999-2009 Gentoo Foundation; Distributed under the GPL v2
-# $Header: /var/cvsroot/gentoo-x86/sys-libs/libsemanage/ChangeLog,v 1.27 2009/08/03 13:30:03 pebenito Exp $
+# $Header: /var/cvsroot/gentoo-x86/sys-libs/libsemanage/ChangeLog,v 1.28 2009/08/24 18:36:16 pebenito Exp $
+
+*libsemanage-2.0.33-r1 (24 Aug 2009)
+
+ 24 Aug 2009; Chris PeBenito <pebenito@gentoo.org>
+ +libsemanage-2.0.33-r1.ebuild, +files/libsemanage-2.0.33-bzip.diff:
+ Add patch to make bzip2 compression configurable.
03 Aug 2009; Chris PeBenito <pebenito@gentoo.org>
libsemanage-2.0.33.ebuild:
diff --git a/sys-libs/libsemanage/files/libsemanage-2.0.33-bzip.diff b/sys-libs/libsemanage/files/libsemanage-2.0.33-bzip.diff
new file mode 100644
index 000000000000..17c4ef5fe8ad
--- /dev/null
+++ b/sys-libs/libsemanage/files/libsemanage-2.0.33-bzip.diff
@@ -0,0 +1,245 @@
+diff -purN libsemanage-2.0.33.orig/src/conf-parse.y libsemanage-2.0.33/src/conf-parse.y
+--- libsemanage-2.0.33.orig/src/conf-parse.y 2009-07-30 22:14:16.000000000 -0400
++++ libsemanage-2.0.33/src/conf-parse.y 2009-08-24 14:17:59.255304232 -0400
+@@ -58,6 +58,7 @@ static int parse_errors;
+
+ %token MODULE_STORE VERSION EXPAND_CHECK FILE_MODE SAVE_PREVIOUS SAVE_LINKED
+ %token LOAD_POLICY_START SETFILES_START DISABLE_GENHOMEDIRCON HANDLE_UNKNOWN
++%token BZIP_BLOCKSIZE BZIP_SMALL
+ %token VERIFY_MOD_START VERIFY_LINKED_START VERIFY_KERNEL_START BLOCK_END
+ %token PROG_PATH PROG_ARGS
+ %token <s> ARG
+@@ -82,6 +83,8 @@ single_opt: module_store
+ | save_linked
+ | disable_genhomedircon
+ | handle_unknown
++ | bzip_blocksize
++ | bzip_small
+ ;
+
+ module_store: MODULE_STORE '=' ARG {
+@@ -163,6 +166,26 @@ handle_unknown: HANDLE_UNKNOWN '=' ARG {
+ free($3);
+ }
+
++bzip_blocksize: BZIP_BLOCKSIZE '=' ARG {
++ int blocksize = atoi($3);
++ free($3);
++ if (blocksize > 9)
++ yyerror("bzip-blocksize can only be in the range 0-9");
++ else
++ current_conf->bzip_blocksize = blocksize;
++}
++
++bzip_small: BZIP_SMALL '=' ARG {
++ if (strcasecmp($3, "false") == 0) {
++ current_conf->bzip_small = 0;
++ } else if (strcasecmp($3, "true") == 0) {
++ current_conf->bzip_small = 1;
++ } else {
++ yyerror("bzip-small can only be 'true' or 'false'");
++ }
++ free($3);
++}
++
+ command_block:
+ command_start external_opts BLOCK_END {
+ if (new_external->path == NULL) {
+@@ -230,6 +253,8 @@ static int semanage_conf_init(semanage_c
+ conf->expand_check = 1;
+ conf->handle_unknown = -1;
+ conf->file_mode = 0644;
++ conf->bzip_blocksize = 9;
++ conf->bzip_small = 0;
+
+ conf->save_previous = 0;
+ conf->save_linked = 0;
+diff -purN libsemanage-2.0.33.orig/src/conf-scan.l libsemanage-2.0.33/src/conf-scan.l
+--- libsemanage-2.0.33.orig/src/conf-scan.l 2009-07-30 22:14:16.000000000 -0400
++++ libsemanage-2.0.33/src/conf-scan.l 2009-08-24 14:17:59.255304232 -0400
+@@ -47,6 +47,8 @@ save-previous return SAVE_PREVIOUS;
+ save-linked return SAVE_LINKED;
+ disable-genhomedircon return DISABLE_GENHOMEDIRCON;
+ handle-unknown return HANDLE_UNKNOWN;
++bzip-blocksize return BZIP_BLOCKSIZE;
++bzip-small return BZIP_SMALL;
+ "[load_policy]" return LOAD_POLICY_START;
+ "[setfiles]" return SETFILES_START;
+ "[verify module]" return VERIFY_MOD_START;
+diff -purN libsemanage-2.0.33.orig/src/direct_api.c libsemanage-2.0.33/src/direct_api.c
+--- libsemanage-2.0.33.orig/src/direct_api.c 2009-07-30 22:14:16.000000000 -0400
++++ libsemanage-2.0.33/src/direct_api.c 2009-08-24 14:18:16.895213296 -0400
+@@ -401,7 +401,9 @@ static int parse_base_headers(semanage_h
+
+ /* bzip() a data to a file, returning the total number of compressed bytes
+ * in the file. Returns -1 if file could not be compressed. */
+-static ssize_t bzip(const char *filename, char *data, size_t num_bytes) {
++static ssize_t bzip(semanage_handle_t *sh, const char *filename, char *data,
++ size_t num_bytes)
++{
+ BZFILE* b;
+ size_t size = 1<<16;
+ int bzerror;
+@@ -413,7 +415,16 @@ static ssize_t bzip(const char *filename
+ return -1;
+ }
+
+- b = BZ2_bzWriteOpen( &bzerror, f, 9, 0, 0);
++ if (!sh->conf->bzip_blocksize) {
++ if (fwrite(data, 1, num_bytes, f) < num_bytes) {
++ fclose(f);
++ return -1;
++ }
++ fclose(f);
++ return num_bytes;
++ }
++
++ b = BZ2_bzWriteOpen( &bzerror, f, sh->conf->bzip_blocksize, 0, 0);
+ if (bzerror != BZ_OK) {
+ BZ2_bzWriteClose ( &bzerror, b, 1, 0, 0 );
+ return -1;
+@@ -441,17 +452,29 @@ static ssize_t bzip(const char *filename
+ return total;
+ }
+
++#define BZ2_MAGICSTR "BZh"
++#define BZ2_MAGICLEN (sizeof(BZ2_MAGICSTR)-1)
++
+ /* bunzip() a file to '*data', returning the total number of uncompressed bytes
+ * in the file. Returns -1 if file could not be decompressed. */
+-ssize_t bunzip(FILE *f, char **data) {
++ssize_t bunzip(semanage_handle_t *sh, FILE *f, char **data)
++{
+ BZFILE* b;
+ size_t nBuf;
+ char buf[1<<18];
+ size_t size = sizeof(buf);
+ int bzerror;
+ size_t total=0;
++
++ if (!sh->conf->bzip_blocksize) {
++ bzerror = fread(buf, 1, BZ2_MAGICLEN, f);
++ rewind(f);
++ if ((bzerror != BZ2_MAGICLEN) || memcmp(buf, BZ2_MAGICSTR, BZ2_MAGICLEN))
++ return -1;
++ /* fall through */
++ }
+
+- b = BZ2_bzReadOpen ( &bzerror, f, 0, 0, NULL, 0 );
++ b = BZ2_bzReadOpen ( &bzerror, f, 0, sh->conf->bzip_small, NULL, 0 );
+ if ( bzerror != BZ_OK ) {
+ BZ2_bzReadClose ( &bzerror, b );
+ return -1;
+@@ -486,11 +509,12 @@ ssize_t bunzip(FILE *f, char **data) {
+ * the file into '*data'.
+ * Returns the total number of bytes in memory .
+ * Returns -1 if file could not be opened or mapped. */
+-static ssize_t map_file(int fd, char **data, int *compressed)
++static ssize_t map_file(semanage_handle_t *sh, int fd, char **data,
++ int *compressed)
+ {
+ ssize_t size = -1;
+ char *uncompress;
+- if ((size = bunzip(fdopen(fd, "r"), &uncompress)) > 0) {
++ if ((size = bunzip(sh, fdopen(fd, "r"), &uncompress)) > 0) {
+ *data = mmap(0, size, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, 0, 0);
+ if (*data == MAP_FAILED) {
+ free(uncompress);
+@@ -997,7 +1021,7 @@ static int semanage_direct_install(seman
+ &filename)) != 0) {
+ goto cleanup;
+ }
+- if (bzip(filename, data, data_len) <= 0) {
++ if (bzip(sh, filename, data, data_len) <= 0) {
+ ERR(sh, "Error while writing to %s.", filename);
+ retval = -3;
+ goto cleanup;
+@@ -1029,7 +1053,7 @@ static int semanage_direct_install_file(
+ return -1;
+ }
+
+- if ((data_len = map_file(in_fd, &data, &compressed)) <= 0) {
++ if ((data_len = map_file(sh, in_fd, &data, &compressed)) <= 0) {
+ goto cleanup;
+ }
+
+@@ -1127,7 +1151,7 @@ static int semanage_direct_upgrade(seman
+ data, data_len,
+ &filename);
+ if (retval == 0) {
+- if (bzip(filename, data, data_len) <= 0) {
++ if (bzip(sh, filename, data, data_len) <= 0) {
+ ERR(sh, "Error while writing to %s.", filename);
+ retval = -3;
+ }
+@@ -1155,7 +1179,7 @@ static int semanage_direct_upgrade_file(
+ return -1;
+ }
+
+- if ((data_len = map_file(in_fd, &data, &compressed)) <= 0) {
++ if ((data_len = map_file(sh, in_fd, &data, &compressed)) <= 0) {
+ goto cleanup;
+ }
+
+@@ -1197,7 +1221,7 @@ static int semanage_direct_install_base(
+ if ((filename = semanage_path(SEMANAGE_TMP, SEMANAGE_BASE)) == NULL) {
+ goto cleanup;
+ }
+- if (bzip(filename, base_data, data_len) <= 0) {
++ if (bzip(sh, filename, base_data, data_len) <= 0) {
+ ERR(sh, "Error while writing to %s.", filename);
+ retval = -3;
+ goto cleanup;
+@@ -1225,7 +1249,7 @@ static int semanage_direct_install_base_
+ return -1;
+ }
+
+- if ((data_len = map_file(in_fd, &data, &compressed)) <= 0) {
++ if ((data_len = map_file(sh, in_fd, &data, &compressed)) <= 0) {
+ goto cleanup;
+ }
+
+@@ -1347,7 +1371,7 @@ static int semanage_direct_list(semanage
+ ssize_t size;
+ char *data = NULL;
+
+- if ((size = bunzip(fp, &data)) > 0) {
++ if ((size = bunzip(sh, fp, &data)) > 0) {
+ fclose(fp);
+ fp = fmemopen(data, size, "rb");
+ if (!fp) {
+diff -purN libsemanage-2.0.33.orig/src/direct_api.h libsemanage-2.0.33/src/direct_api.h
+--- libsemanage-2.0.33.orig/src/direct_api.h 2009-07-30 22:14:16.000000000 -0400
++++ libsemanage-2.0.33/src/direct_api.h 2009-08-24 14:17:59.271293736 -0400
+@@ -41,6 +41,6 @@ int semanage_direct_mls_enabled(struct s
+
+ #include <stdio.h>
+ #include <unistd.h>
+-ssize_t bunzip(FILE *f, char **data);
++ssize_t bunzip(struct semanage_handle *sh, FILE *f, char **data);
+
+ #endif
+diff -purN libsemanage-2.0.33.orig/src/semanage_conf.h libsemanage-2.0.33/src/semanage_conf.h
+--- libsemanage-2.0.33.orig/src/semanage_conf.h 2009-07-30 22:14:16.000000000 -0400
++++ libsemanage-2.0.33/src/semanage_conf.h 2009-08-24 14:17:59.279293237 -0400
+@@ -40,6 +40,8 @@ typedef struct semanage_conf {
+ int disable_genhomedircon;
+ int handle_unknown;
+ mode_t file_mode;
++ int bzip_blocksize;
++ int bzip_small;
+ struct external_prog *load_policy;
+ struct external_prog *setfiles;
+ struct external_prog *mod_prog, *linked_prog, *kernel_prog;
+diff -purN libsemanage-2.0.33.orig/src/semanage_store.c libsemanage-2.0.33/src/semanage_store.c
+--- libsemanage-2.0.33.orig/src/semanage_store.c 2009-07-30 22:14:16.000000000 -0400
++++ libsemanage-2.0.33/src/semanage_store.c 2009-08-24 14:17:59.283234006 -0400
+@@ -1529,7 +1529,7 @@ static int semanage_load_module(semanage
+ ssize_t size;
+ char *data = NULL;
+
+- if ((size = bunzip(fp, &data)) > 0) {
++ if ((size = bunzip(sh, fp, &data)) > 0) {
+ fclose(fp);
+ fp = fmemopen(data, size, "rb");
+ if (!fp) {
diff --git a/sys-libs/libsemanage/libsemanage-2.0.33-r1.ebuild b/sys-libs/libsemanage/libsemanage-2.0.33-r1.ebuild
new file mode 100644
index 000000000000..7341e7259f5d
--- /dev/null
+++ b/sys-libs/libsemanage/libsemanage-2.0.33-r1.ebuild
@@ -0,0 +1,81 @@
+# Copyright 1999-2009 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Header: /var/cvsroot/gentoo-x86/sys-libs/libsemanage/libsemanage-2.0.33-r1.ebuild,v 1.1 2009/08/24 18:36:16 pebenito Exp $
+
+IUSE=""
+
+inherit eutils multilib python
+
+BUGFIX_PATCH="${FILESDIR}/libsemanage-2.0.33-bzip.diff"
+
+SEPOL_VER="2.0.37"
+SELNX_VER="2.0"
+
+DESCRIPTION="SELinux kernel and policy management library"
+HOMEPAGE="http://userspace.selinuxproject.org"
+SRC_URI="http://userspace.selinuxproject.org/releases/current/devel/${P}.tar.gz"
+LICENSE="GPL-2"
+SLOT="0"
+KEYWORDS="~amd64 ~x86"
+DEPEND=">=sys-libs/libsepol-${SEPOL_VER}
+ >=sys-libs/libselinux-${SELNX_VER}
+ dev-libs/ustr"
+RDEPEND="${DEPEND}"
+
+# tests are not meant to be run outside of the
+# full SELinux userland repo
+RESTRICT="test"
+
+src_unpack() {
+ unpack ${A}
+ cd "${S}"
+
+ [ ! -z "${BUGFIX_PATCH}" ] && epatch "${BUGFIX_PATCH}"
+
+ echo "# Set this to true to save the linked policy." >> "${S}/src/semanage.conf"
+ echo "# This is normally only useful for analysis" >> "${S}/src/semanage.conf"
+ echo "# or debugging of policy." >> "${S}/src/semanage.conf"
+ echo "save-linked=false" >> "${S}/src/semanage.conf"
+ echo >> "${S}/src/semanage.conf"
+ echo "# Set this to 0 to disable assertion checking." >> "${S}/src/semanage.conf"
+ echo "# This should speed up building the kernel policy" >> "${S}/src/semanage.conf"
+ echo "# from policy modules, but may leave you open to" >> "${S}/src/semanage.conf"
+ echo "# dangerous rules which assertion checking" >> "${S}/src/semanage.conf"
+ echo "# would catch." >> "${S}/src/semanage.conf"
+ echo "expand-check=1" >> "${S}/src/semanage.conf"
+ echo >> "${S}/src/semanage.conf"
+ echo "# Modules in the module store can be compressed" >> "${S}/src/semanage.conf"
+ echo "# with bzip2. Set this to the bzip2 blocksize" >> "${S}/src/semanage.conf"
+ echo "# 1-9 when compressing. The higher the number," >> "${S}/src/semanage.conf"
+ echo "# the more memory is traded off for disk space." >> "${S}/src/semanage.conf"
+ echo "# Set to 0 to disable bzip2 compression." >> "${S}/src/semanage.conf"
+ echo "bzip-blocksize=0" >> "${S}/src/semanage.conf"
+ echo >> "${S}/src/semanage.conf"
+ echo "# Reduce memory usage for bzip2 compression and" >> "${S}/src/semanage.conf"
+ echo "# decompression of modules in the module store." >> "${S}/src/semanage.conf"
+ echo "bzip-small=true" >> "${S}/src/semanage.conf"
+}
+
+src_compile() {
+ python_version
+ emake PYLIBVER="python${PYVER}" all || die
+ emake PYLIBVER="python${PYVER}" pywrap || die
+}
+
+src_install() {
+ python_version
+ python_need_rebuild
+ make DESTDIR="${D}" PYLIBVER="python${PYVER}" \
+ LIBDIR="${D}/usr/$(get_libdir)/" \
+ SHLIBDIR="${D}/$(get_libdir)/" install install-pywrap
+}
+
+pkg_postinst() {
+ python_version
+ python_mod_optimize /usr/$(get_libdir)/python${PYVER}/site-packages
+}
+
+pkg_postrm() {
+ python_version
+ python_mod_cleanup /usr/$(get_libdir)/python${PYVER}/site-packages
+}