New libsemanage space saving patch.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
This patch compresses all pp files with bzip
Adds three new interfaces.
+int semanage_module_install_file(semanage_handle_t *,
+ const char *module_name);
+int semanage_module_upgrade_file(semanage_handle_t *,
+ const char *module_name);
+int semanage_module_install_base_file(semanage_handle_t *,
+ const char *module_name);
These interfaces will read either compressed or uncompressed files and store them as compressed files in /etc/selinux/POLICY/targeted/modules/avtive/modules
New functions
bzip and bunzip, self explanatory.
map_file which will take either a compresses or uncompressed file and return the uncompressed data as a memory mapped file.
dupfile, which takes an open file descriptor and a filename and duplicates the open filedescriptor to the name. (Used for copying compressed files to the store.)
Contains previous patch to setup sandbox as links rather then copies.
Some stats:
system-config-selinux currently needs over 100 megabytes of disk space to install policy packages, with these fixes we only
Fedora 9
# du -m -s /etc/selinux/targeted /usr/share/selinux/targeted/ 40 /etc/selinux/targeted 48 /usr/share/selinux/targeted/
Fedora 10 With this patch
# du -m -s /etc/selinux/targeted /usr/share/selinux/targeted/ 10 /etc/selinux/targeted 3 /usr/share/selinux/targeted/
This does not include the space savings in/usr/share/selinux/targeted/modules/tmp
Which needs another 40Mb of disk.
It does slow down the semodule command slightly, running semodule on all compressed policy packages in Fedora Targeted policy.
# time semodule -b base.pp.bz2 -i ../*bz2
real 0m14.774s
user 0m13.528s
sys 0m0.883s
Previous commands without patches
# time semodule -b base.pp -i ../*.pp
real 0m13.063s
user 0m11.742s
sys 0m1.179s
Max Heap size, as reported by valgrind -tool=massif
valgrind --tool=massif --massif-out-file=/tmp/old/massif-b /usr/sbin/semodule -b /usr/share/selinux/targeted/tmp/base.pp -i /usr/share/selinux/targeted/*.pp
Without Compression
117970697
With Compression
118459897
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org
iEYEARECAAYFAkjzvf0ACgkQrlYvE4MpobNp+QCdHl510g4d/5a72tkzKFh+mKx8 MRcAn0l5cAWfyPw147H6nuEHY2aRf0Re
=6I0F
-----END PGP SIGNATURE-----
include/semanage/modules.h +6 -0
@@ -30,10 +30,16 @@int semanage_module_install (semanage_handle_t *,char *module_data,size_t data_len); +int semanage_module_install_file (semanage_handle_t *, +const char *module_name);int semanage_module_upgrade (semanage_handle_t *,char *module_data,size_t data_len); +int semanage_module_upgrade_file (semanage_handle_t *, +const char *module_name);int semanage_module_install_base (semanage_handle_t *,char *module_data,size_t data_len); +int semanage_module_install_base_file (semanage_handle_t *, +const char *module_name);int semanage_module_remove (semanage_handle_t *,char *module_name);/* semanage_module_info is for getting information on installed
src/Makefile +1 -1
@@ -54,7 +54,7 @@ ranlib $@ $(LIBSO): $(LOBJS) - $(CC) $(CFLAGS) $(LDFLAGS) -shared -o $@ $^ -lsepol -lselinux -lustr -L$(LIBDIR) -Wl,-soname,$(LIBSO),--version-script=libsemanage.map,-z,defs + $(CC) $(CFLAGS) $(LDFLAGS) -shared -o $@ $^ -lsepol -lselinux -lbz2 -lustr -L$(LIBDIR) -Wl,-soname,$(LIBSO),--version-script=libsemanage.map,-z,defs ln -sf $@ $(TARGET) conf-scan.c: conf-scan.l conf-parse.h
src/direct_api.c +339 -19
456 lines not on this page · raw message
src/direct_api.h +3 -0
@@ -37,4 +37,7 @@int semanage_direct_access_check (struct semanage_handle *sh); +#include <stdio.h> +size_t bunzip (FILE *f,char **data); +#endif
src/libsemanage.map +4 -2
@@ -3,8 +3,10 @@ semanage_is_managed; semanage_connect; semanage_disconnect; semanage_msg_*; semanage_begin_transaction; semanage_commit; - semanage_module_install; semanage_module_upgrade; - semanage_module_install_base; semanage_module_remove; + semanage_module_install; semanage_module_install_file; + semanage_module_upgrade; semanage_module_upgrade_file; + semanage_module_install_base; semanage_module_install_base_file; + semanage_module_remove; semanage_module_list; semanage_module_info_datum_destroy; semanage_module_list_nth; semanage_module_get_name; semanage_module_get_version; semanage_select_store;
src/modules.c +57 -0
75 lines not on this page · raw message
src/policy.h +9 -0
@@ -49,8 +49,14 @@/* Install a policy module */ int (*install) (struct semanage_handle *,char *,size_t ); +/* Install a policy module */ +int (*install_file) (struct semanage_handle *,const char *); +/* Upgrade a policy module */ int (*upgrade) (struct semanage_handle *,char *,size_t ); + +/* Upgrade a policy module */ +int (*upgrade_file) (struct semanage_handle *,const char *);/* Remove a policy module */ int (*remove) (struct semanage_handle *,char *);
@@ -61,6 +67,9 @@/* Install base policy */ int (*install_base) (struct semanage_handle *,char *,size_t ); + +/* Install a base module */ +int (*install_base_file) (struct semanage_handle *,const char *); };/* Should be backend independent */
src/semanage_store.c +12 -0
@@ -440,6 +440,8 @@char tmp[PATH_MAX ];char buf[4192 ]; +if (link (src,dst) ==0 )return 0 ; + n =snprintf (tmp,PATH_MAX ,"%s.tmp" , dst);if (n <0 || n >=PATH_MAX )return -1 ;
@@ -1522,16 +1524,26 @@ERR (sh,"Could not open module file %s for reading." , filename); goto cleanup; } +size_t size; +char *data =NULL ; + +if ((size =bunzip (fp, &data)) !=0 ) { +fclose (fp); + fp =fmemopen (data, size,"rb" ); + } +rewind (fp);__fsetlocking (fp,FSETLOCKING_BYCALLER );sepol_policy_file_set_fp (pf, fp);sepol_policy_file_set_handle (pf, sh->sepolh);if (sepol_module_package_read (*package, pf,0 ) ==-1 ) {ERR (sh,"Error while reading from module file %s." , filename);fclose (fp); +free (data); goto cleanup; }sepol_policy_file_free (pf);fclose (fp); +free (data);return retval; cleanup: