diff --git a/src/install/dracut-install.c b/src/install/dracut-install.c index 6bf5ce1fd7..d60584c438 100644 --- a/src/install/dracut-install.c +++ b/src/install/dracut-install.c @@ -682,9 +682,11 @@ void mark_hostonly(const char *path) _asprintf(&fulldstpath, "%s/lib/dracut/hostonly-files", destrootdir); - f = fopen(fulldstpath, "a"); + int fd = open(fulldstpath, O_RDONLY | O_APPEND, 0600); + if (fd != -1) + f = fdopen(fd, "a"); - if (f == NULL) { + if (fd == -1 || f == NULL) { log_error("Could not open '%s' for writing.", fulldstpath); return; }