From: Sami Kerola Date: Sat, 13 Apr 2013 19:54:39 +0000 (+0100) Subject: setpriv: check writing to a file was successful X-Git-Tag: v2.24-rc1~600 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f99b58b3841888703ef41802256b913abd4e3e89;p=thirdparty%2Futil-linux.git setpriv: check writing to a file was successful Signed-off-by: Sami Kerola --- diff --git a/sys-utils/setpriv.c b/sys-utils/setpriv.c index 743fd92183..ab3180ac5b 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); }