mirror of
https://github.com/troglobit/finit.git
synced 2026-11-13 17:00:16 +00:00
Check return value from rename(), fall back to truncate() on error
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This commit is contained in:
1 parent
a84bb9042f
commit
658fb9b037
1 file changed
+4
-2
+4
-2
@@ -86,8 +86,10 @@ static int logrotate(char *file, int num, off_t sz)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
rename(file, nfile);
|
if (rename(file, nfile))
|
||||||
create(file, st.st_mode, st.st_uid, st.st_gid);
|
(void)truncate(file, 0);
|
||||||
|
else
|
||||||
|
create(file, st.st_mode, st.st_uid, st.st_gid);
|
||||||
} else {
|
} else {
|
||||||
if (truncate(file, 0))
|
if (truncate(file, 0))
|
||||||
syslog(LOG_ERR | LOG_PERROR, "Failed truncating %s during logrotate: %s", file, strerror(errno));
|
syslog(LOG_ERR | LOG_PERROR, "Failed truncating %s during logrotate: %s", file, strerror(errno));
|
||||||
|
|||||||
Reference in new issue
Block a user