Close file before replacing signed

This commit is contained in:
Evgeniy Taishev 2022-01-17 22:07:13 +03:00 committed by Florian Festi
parent 0edd64ea4a
commit 9b4c50dd67
1 changed files with 4 additions and 0 deletions

View File

@ -695,6 +695,10 @@ static int rpmSign(const char *rpm, int deleting, int flags)
if (copyFile(&fd, rpm, &ofd, trpm) == 0) {
struct stat st;
/* File must be closed before deletion due to different file locking in some file systems*/
if (fd) (void) closeFile(&fd);
if (ofd) (void) closeFile(&ofd);
/* Move final target into place, restore file permissions. */
if (stat(rpm, &st) == 0 && unlink(rpm) == 0 &&
rename(trpm, rpm) == 0 && chmod(rpm, st.st_mode) == 0) {