setpriv: check writing to a file was successful

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
This commit is contained in:
Sami Kerola 2013-04-13 20:54:39 +01:00 committed by Karel Zak
parent 1d3762ee53
commit f99b58b384
1 changed files with 3 additions and 2 deletions

View 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);
}