selinux.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Nick Kralevich <nnk@google.com>
To: selinux@tycho.nsa.gov
Subject: [PATCH] checkpolicy: remove extraneous policy build noise
Date: Wed, 19 Sep 2018 12:08:56 -0700	[thread overview]
Message-ID: <20180919190856.58147-1-nnk@google.com> (raw)

Reduce noise when calling the checkpolicy command line. In Android, this
creates unnecessary build noise which we'd like to avoid.

https://en.wikipedia.org/wiki/Unix_philosophy

  Rule of Silence
  Developers should design programs so that they do not print
  unnecessary output. This rule aims to allow other programs
  and developers to pick out the information they need from a
  program's output without having to parse verbosity.

An alternative approach would be to add a -s (silent) option to these
tools, or to have the Android build system redirect stdout to /dev/null.

Signed-off-by: Nick Kralevich <nnk@google.com>
---
 checkpolicy/checkmodule.c |  8 --------
 checkpolicy/checkpolicy.c | 11 -----------
 2 files changed, 19 deletions(-)

diff --git a/checkpolicy/checkmodule.c b/checkpolicy/checkmodule.c
index 46ce258f..8edc1f8c 100644
--- a/checkpolicy/checkmodule.c
+++ b/checkpolicy/checkmodule.c
@@ -228,7 +228,6 @@ int main(int argc, char **argv)
 		if (optind !=3D argc)
 			usage(argv[0]);
 	}
-	printf("%s:  loading policy configuration from %s\n", argv[0], file);
=20
 	/* Set policydb and sidtab used by libsepol service functions
 	   to my structures, so that I can directly populate and
@@ -302,8 +301,6 @@ int main(int argc, char **argv)
=20
 	sepol_sidtab_destroy(&sidtab);
=20
-	printf("%s:  policy configuration loaded\n", argv[0]);
-
 	if (outfile) {
 		FILE *outfp =3D fopen(outfile, "w");
=20
@@ -313,16 +310,11 @@ int main(int argc, char **argv)
 		}
=20
 		if (!cil) {
-			printf("%s:  writing binary representation (version %d) to %s\n",
-				   argv[0], policyvers, outfile);
-
 			if (write_binary_policy(&modpolicydb, outfp) !=3D 0) {
 				fprintf(stderr, "%s:  error writing %s\n", argv[0], outfile);
 				exit(1);
 			}
 		} else {
-			printf("%s:  writing CIL to %s\n",argv[0], outfile);
-
 			if (sepol_module_policydb_to_cil(outfp, &modpolicydb, 0) !=3D 0) {
 				fprintf(stderr, "%s:  error writing %s\n", argv[0], outfile);
 				exit(1);
diff --git a/checkpolicy/checkpolicy.c b/checkpolicy/checkpolicy.c
index fbda4558..12c4c405 100644
--- a/checkpolicy/checkpolicy.c
+++ b/checkpolicy/checkpolicy.c
@@ -512,8 +512,6 @@ int main(int argc, char **argv)
 		if (optind !=3D argc)
 			usage(argv[0]);
 	}
-	printf("%s:  loading policy configuration from %s\n", argv[0], file);
-
 	/* Set policydb and sidtab used by libsepol service functions
 	   to my structures, so that I can directly populate and
 	   manipulate them. */
@@ -623,8 +621,6 @@ int main(int argc, char **argv)
 	if (policydb_load_isids(&policydb, &sidtab))
 		exit(1);
=20
-	printf("%s:  policy configuration loaded\n", argv[0]);
-
 	if (outfile) {
 		outfp =3D fopen(outfile, "w");
 		if (!outfp) {
@@ -636,8 +632,6 @@ int main(int argc, char **argv)
=20
 		if (!cil) {
 			if (!conf) {
-				printf("%s:  writing binary representation (version %d) to %s\n", ar=
gv[0], policyvers, outfile);
-
 				policydb.policy_type =3D POLICY_KERN;
=20
 				policy_file_init(&pf);
@@ -645,8 +639,6 @@ int main(int argc, char **argv)
 				pf.fp =3D outfp;
 				ret =3D policydb_write(&policydb, &pf);
 			} else {
-				printf("%s:  writing policy.conf to %s\n",
-				       argv[0], outfile);
 				ret =3D sepol_kernel_policydb_to_conf(outfp, policydbp);
 			}
 			if (ret) {
@@ -655,7 +647,6 @@ int main(int argc, char **argv)
 				exit(1);
 			}
 		} else {
-			printf("%s:  writing CIL to %s\n",argv[0], outfile);
 			if (binary) {
 				ret =3D sepol_kernel_policydb_to_cil(outfp, policydbp);
 			} else {
@@ -894,8 +885,6 @@ int main(int argc, char **argv)
 			FGETS(ans, sizeof(ans), stdin);
 			pathlen =3D strlen(ans);
 			ans[pathlen - 1] =3D 0;
-			printf("%s:  loading policy configuration from %s\n",
-			       argv[0], ans);
 			fd =3D open(ans, O_RDONLY);
 			if (fd < 0) {
 				fprintf(stderr, "Can't open '%s':  %s\n",
--=20
2.19.0.397.gdd90340f6a-goog

             reply	other threads:[~2018-09-19 19:12 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-09-19 19:08 Nick Kralevich [this message]
2018-09-19 19:21 ` [PATCH] checkpolicy: remove extraneous policy build noise William Roberts
2018-09-19 19:38   ` Stephen Smalley
2018-09-19 19:41     ` William Roberts
2018-09-19 19:48       ` Stephen Smalley
2018-09-21 19:52 ` William Roberts

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=20180919190856.58147-1-nnk@google.com \
    --to=nnk@google.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).