From 17bdd6de1e384b8455c62f4db9aac35496cf534f Mon Sep 17 00:00:00 2001 From: Bram Matthys Date: Sat, 6 Mar 2021 18:53:02 +0100 Subject: [PATCH] Use different temporary filename. Not really important normally but if running multiple ircds from the same directory you sometimes get weird messages otherwise (not that we really support such a thing but i use it while dev'ing). --- src/modules/channeldb.c | 2 +- src/modules/reputation.c | 2 +- src/modules/tkldb.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/modules/channeldb.c b/src/modules/channeldb.c index 425180bdb..442ce00b4 100644 --- a/src/modules/channeldb.c +++ b/src/modules/channeldb.c @@ -216,7 +216,7 @@ int write_channeldb(void) #endif // Write to a tempfile first, then rename it if everything succeeded - snprintf(tmpfname, sizeof(tmpfname), "%s.tmp", cfg.database); + snprintf(tmpfname, sizeof(tmpfname), "%s.%x.tmp", cfg.database, getrandom32()); fd = fopen(tmpfname, "wb"); if (!fd) { diff --git a/src/modules/reputation.c b/src/modules/reputation.c index 19418a75f..50c238f60 100644 --- a/src/modules/reputation.c +++ b/src/modules/reputation.c @@ -401,7 +401,7 @@ void save_db(void) #endif /* We write to a temporary file. Only to rename it later if everything was ok */ - snprintf(tmpfname, sizeof(tmpfname), "%s.tmp", cfg.database); + snprintf(tmpfname, sizeof(tmpfname), "%s.%x.tmp", cfg.database, getrandom32()); fd = fopen(tmpfname, "w"); if (!fd) diff --git a/src/modules/tkldb.c b/src/modules/tkldb.c index 83a3e48eb..7cfdcd4f4 100644 --- a/src/modules/tkldb.c +++ b/src/modules/tkldb.c @@ -255,7 +255,7 @@ int write_tkldb(void) #endif // Write to a tempfile first, then rename it if everything succeeded - snprintf(tmpfname, sizeof(tmpfname), "%s.tmp", cfg.database); + snprintf(tmpfname, sizeof(tmpfname), "%s.%x.tmp", cfg.database, getrandom32()); fd = fopen(tmpfname, "wb"); if (!fd) {