[PATCH 11/33] setpriv: check writing to a file was successful

Sami Kerola
2013-04-13T19:55:41Z

sys-utils/setpriv.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/sys-utils/setpriv.c b/sys-utils/setpriv.c
index 7fa5f82..18810c5 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);
}
--
1.8.2.1