All of lore.kernel.org
 help / color / mirror / Atom feed
From: Alan Jenkins <alan.christopher.jenkins@gmail.com>
To: selinux@tycho.nsa.gov
Cc: Alan Jenkins <alan.christopher.jenkins@gmail.com>
Subject: [PATCH 1/3] policycoreutils/setfiles: stdout messages don't need program prefix
Date: Sun, 26 Mar 2017 17:22:43 +0100	[thread overview]
Message-ID: <20170326162245.21135-1-alan.christopher.jenkins@gmail.com> (raw)

I suggested that if you run a command for its informational output (by
passing  `-v`), you don't expect it to be prefixed with the program name.
Prefixing is used for error messages, so you can tell where your shell
script blew up :).  If a script is running a command for its informational
output, it's usually the script's responsibility to make sure it's in
context, e.g. providing headers if there are multiple sections of output.

Removing the program name from setfiles/restorecon output is particularly
useful because it generates very long lines.  But also, it actually helps
highlight where there are error messages - the prefix will make them
stand out visually.

Signed-off-by: Alan Jenkins <alan.christopher.jenkins@gmail.com>
---
 policycoreutils/setfiles/setfiles.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/policycoreutils/setfiles/setfiles.c b/policycoreutils/setfiles/setfiles.c
index 6f69c90..83e0b2a 100644
--- a/policycoreutils/setfiles/setfiles.c
+++ b/policycoreutils/setfiles/setfiles.c
@@ -142,9 +142,15 @@ static int __attribute__ ((format(printf, 2, 3)))
 log_callback(int type, const char *fmt, ...)
 {
 	int rc;
-	FILE *out = (type == SELINUX_INFO) ? stdout : stderr;
+	FILE *out;
 	va_list ap;
-	fprintf(out, "%s: ", r_opts.progname);
+
+	if (type == SELINUX_INFO) {
+		out = stdout;
+	} else {
+		out = stderr;
+		fprintf(out, "%s: ", r_opts.progname);
+	}
 	va_start(ap, fmt);
 	rc = vfprintf(out, fmt, ap);
 	va_end(ap);
-- 
2.9.3

             reply	other threads:[~2017-03-26 16:23 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-26 16:22 Alan Jenkins [this message]
2017-03-26 16:22 ` [PATCH 2/3] policycoreutils/setfiles: don't scramble stdout and stderr together Alan Jenkins
2017-03-26 16:22 ` [PATCH 3/3] policycoreutils: fixfiles: remove useless use of cat Alan Jenkins
2017-03-28 19:56 ` [PATCH 1/3] policycoreutils/setfiles: stdout messages don't need program prefix James Carter

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=20170326162245.21135-1-alan.christopher.jenkins@gmail.com \
    --to=alan.christopher.jenkins@gmail.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.