From f99b58b3841888703ef41802256b913abd4e3e89 Mon Sep 17 00:00:00 2001 From: Sami Kerola Date: Sat, 13 Apr 2013 20:54:39 +0100 Subject: setpriv: check writing to a file was successful Signed-off-by: Sami Kerola --- sys-utils/setpriv.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'sys-utils/setpriv.c') diff --git a/sys-utils/setpriv.c b/sys-utils/setpriv.c index 743fd9218..ab3180ac5 100644 --- a/sys-utils/setpriv.c +++ b/sys-utils/setpriv.c @@ -541,8 +541,9 @@ static void do_apparmor_profile(const char *label) err(SETPRIV_EXIT_PRIVERR, _("cannot open %s"), _PATH_PROC_ATTR_EXEC); - if (fprintf(f, "changeprofile %s", label) < 0 || fflush(f) != 0 - || fclose(f) != 0) + fprintf(f, "changeprofile %s", label); + + if (close_stream(f) != 0) err(SETPRIV_EXIT_PRIVERR, _("write failed: %s"), _PATH_PROC_ATTR_EXEC); } -- cgit v1.2.3-55-g7522