From: Ondrej Mosnacek <omosnace@redhat.com>
To: selinux@vger.kernel.org
Subject: [PATCH userspace v2 4/7] secilc: add flag to enable policy optimization
Date: Tue, 28 May 2019 16:59:09 +0200 [thread overview]
Message-ID: <20190528145912.13827-5-omosnace@redhat.com> (raw)
In-Reply-To: <20190528145912.13827-1-omosnace@redhat.com>
Add a command-line option -O/--optimize to optimize the final policydb
using sepol_policydb_optimize() before writing it out.
Signed-off-by: Ondrej Mosnacek <omosnace@redhat.com>
---
secilc/secilc.c | 16 +++++++++++++++-
1 file changed, 15 insertions(+), 1 deletion(-)
diff --git a/secilc/secilc.c b/secilc/secilc.c
index ad6862ba..26996ef9 100644
--- a/secilc/secilc.c
+++ b/secilc/secilc.c
@@ -68,6 +68,7 @@ static __attribute__((__noreturn__)) void usage(const char *prog)
printf(" -G, --expand-generated Expand and remove auto-generated attributes\n");
printf(" -X, --expand-size <SIZE> Expand type attributes with fewer than <SIZE>\n");
printf(" members.\n");
+ printf(" -n, --no-optimize do not optimize final policy\n");
printf(" -v, --verbose increment verbosity level\n");
printf(" -h, --help display usage information\n");
exit(1);
@@ -97,6 +98,7 @@ int main(int argc, char *argv[])
int policyvers = POLICYDB_VERSION_MAX;
int attrs_expand_generated = 0;
int attrs_expand_size = -1;
+ int optimize_policy = 1;
int opt_char;
int opt_index = 0;
char *fc_buf = NULL;
@@ -117,12 +119,13 @@ int main(int argc, char *argv[])
{"filecontexts", required_argument, 0, 'f'},
{"expand-generated", no_argument, 0, 'G'},
{"expand-size", required_argument, 0, 'X'},
+ {"no-optimize", no_argument, 0, 'n'},
{0, 0, 0, 0}
};
int i;
while (1) {
- opt_char = getopt_long(argc, argv, "o:f:U:hvt:M:PDmNc:GX:", long_opts, &opt_index);
+ opt_char = getopt_long(argc, argv, "o:f:U:hvt:M:PDmNc:GX:n", long_opts, &opt_index);
if (opt_char == -1) {
break;
}
@@ -211,6 +214,9 @@ int main(int argc, char *argv[])
}
break;
}
+ case 'n':
+ optimize_policy = 0;
+ break;
case 'h':
usage(argv[0]);
case '?':
@@ -294,6 +300,14 @@ int main(int argc, char *argv[])
goto exit;
}
+ if (optimize_policy) {
+ rc = sepol_policydb_optimize(pdb);
+ if (rc != SEPOL_OK) {
+ fprintf(stderr, "Failed to optimize policydb\n");
+ goto exit;
+ }
+ }
+
if (output == NULL) {
int size = snprintf(NULL, 0, "policy.%d", policyvers);
output = malloc((size + 1) * sizeof(char));
--
2.20.1
next prev parent reply other threads:[~2019-05-28 14:59 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-05-28 14:59 [PATCH userspace v2 0/7] Remove redundant rules when building policydb Ondrej Mosnacek
2019-05-28 14:59 ` [PATCH userspace v2 1/7] libsepol: add a function to optimize kernel policy Ondrej Mosnacek
2019-05-29 20:32 ` [Non-DoD Source] " jwcart2
2019-05-30 11:46 ` Ondrej Mosnacek
2019-05-30 16:55 ` Stephen Smalley
2019-05-31 7:39 ` Ondrej Mosnacek
2019-05-28 14:59 ` [PATCH userspace v2 2/7] libsemanage: optionally optimize policy on rebuild Ondrej Mosnacek
2019-05-28 14:59 ` [PATCH userspace v2 3/7] semodule: add flag to enable policy optimization Ondrej Mosnacek
2019-05-28 14:59 ` Ondrej Mosnacek [this message]
2019-05-28 16:32 ` [PATCH userspace v2 4/7] secilc: " Dominick Grift
2019-05-28 17:01 ` Ondrej Mosnacek
2019-05-28 14:59 ` [PATCH userspace v2 5/7] checkpolicy: " Ondrej Mosnacek
2019-05-28 14:59 ` [PATCH userspace v2 6/7] [RFC] lisepol: slightly more thorough optimization Ondrej Mosnacek
2019-05-28 14:59 ` [PATCH userspace v2 7/7] [RFC] libsemanage: switch to config file entry Ondrej Mosnacek
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=20190528145912.13827-5-omosnace@redhat.com \
--to=omosnace@redhat.com \
--cc=selinux@vger.kernel.org \
/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.