]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
setpriv: check writing to a file was successful
authorSami Kerola <kerolasa@iki.fi>
Sat, 13 Apr 2013 19:54:39 +0000 (20:54 +0100)
committerKarel Zak <kzak@redhat.com>
Fri, 26 Apr 2013 11:26:06 +0000 (13:26 +0200)
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
sys-utils/setpriv.c

index 743fd92183dd4a8467317c605ad464de952e4899..ab3180ac5bd46a1bfba1285df40cbd3a064a28de 100644 (file)
@@ -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);
 }