All of lore.kernel.org
 help / color / mirror / Atom feed
From: Daniel J Walsh <dwalsh@redhat.com>
To: SE Linux <selinux@tycho.nsa.gov>
Subject: semodule patch to use new semanage interfaces
Date: Fri, 07 Nov 2008 09:41:24 -0500	[thread overview]
Message-ID: <49145394.3050806@redhat.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 372 bytes --]

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Allows semodule to read bzip compressed policy packages directly.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org

iEYEARECAAYFAkkUU5QACgkQrlYvE4MpobMHGQCdGwEl3h1ZwV92u1mfgrr3z7XT
NGYAoIwz76N7QFdEr8I0t3ncGhbo6heq
=raBi
-----END PGP SIGNATURE-----

[-- Attachment #2: semodule.patch --]
[-- Type: text/plain, Size: 2164 bytes --]

--- nsapolicycoreutils/semodule/semodule.c	2008-08-28 09:34:24.000000000 -0400
+++ policycoreutils-2.0.57/semodule/semodule.c	2008-10-10 16:04:46.000000000 -0400
@@ -60,24 +60,6 @@
 	free(commands);
 }
 
-/* mmap() a file to '*data', returning the total number of bytes in
- * the file.  Returns 0 if file could not be opened or mapped. */
-static size_t map_file(char *filename, char **data)
-{
-	int fd;
-	struct stat sb;
-	if ((fd = open(filename, O_RDONLY)) == -1) {
-		return 0;
-	}
-	if (fstat(fd, &sb) == -1 ||
-	    (*data = mmap(NULL, sb.st_size, PROT_READ, MAP_PRIVATE, fd, 0)) ==
-	    MAP_FAILED) {
-		sb.st_size = 0;
-	}
-	close(fd);
-	return sb.st_size;
-}
-
 /* Signal handlers. */
 static void handle_signal(int sig_num)
 {
@@ -339,16 +321,6 @@
 	for (i = 0; i < num_commands; i++) {
 		enum client_modes mode = commands[i].mode;
 		char *mode_arg = commands[i].arg;
-		char *data = NULL;
-		size_t data_len = 0;
-		if (mode == INSTALL_M || mode == UPGRADE_M || mode == BASE_M) {
-			if ((data_len = map_file(mode_arg, &data)) == 0) {
-				fprintf(stderr,
-					"%s:  Could not read file '%s': %s\n",
-					argv[0], mode_arg, errno ? strerror(errno) : "");
-				goto cleanup;
-			}
-		}
 		switch (mode) {
 		case INSTALL_M:{
 				if (verbose) {
@@ -357,7 +329,7 @@
 					     mode_arg);
 				}
 				result =
-				    semanage_module_install(sh, data, data_len);
+				    semanage_module_install_file(sh, mode_arg);
 				break;
 			}
 		case UPGRADE_M:{
@@ -367,7 +339,7 @@
 					     mode_arg);
 				}
 				result =
-				    semanage_module_upgrade(sh, data, data_len);
+				    semanage_module_upgrade_file(sh, mode_arg);
 				break;
 			}
 		case BASE_M:{
@@ -377,8 +349,7 @@
 					     mode_arg);
 				}
 				result =
-				    semanage_module_install_base(sh, data,
-								 data_len);
+				    semanage_module_install_base_file(sh, mode_arg);
 				break;
 			}
 		case REMOVE_M:{
@@ -429,9 +400,6 @@
 			}
 		}
 		commit += do_commit[mode];
-		if (mode == INSTALL_M || mode == UPGRADE_M || mode == BASE_M) {
-			munmap(data, data_len);
-		}
 		if (result < 0) {
 			fprintf(stderr, "%s:  Failed on %s!\n", argv[0],
 				mode_arg ? : "list");

[-- Attachment #3: semodule.patch.sig --]
[-- Type: application/octet-stream, Size: 72 bytes --]

             reply	other threads:[~2008-11-07 14:41 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-11-07 14:41 Daniel J Walsh [this message]
2009-01-05 19:52 ` semodule patch to use new semanage interfaces Joshua Brindle
2009-01-05 19:58   ` Daniel J Walsh
2009-01-05 20:07     ` Joshua Brindle
     [not found]       ` <49626F43.9000702@redhat.com>
2009-01-05 20:42         ` Joshua Brindle
2009-01-12 20:58 ` Joshua Brindle

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=49145394.3050806@redhat.com \
    --to=dwalsh@redhat.com \
    --cc=selinux@tycho.nsa.gov \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.