plugins/chanbackup: Define FILENAME globally (Good Manners)

This commit is contained in:
adi2011
2023-02-02 20:31:25 +10:30
committed by Alex Myers
parent 2b1867aca3
commit ff777e3238

View File

@@ -21,6 +21,8 @@
#define HEADER_LEN crypto_secretstream_xchacha20poly1305_HEADERBYTES
#define ABYTES crypto_secretstream_xchacha20poly1305_ABYTES
#define FILENAME "emergency.recover"
/* VERSION is the current version of the data encrypted in the file */
#define VERSION ((u64)1)
@@ -111,7 +113,7 @@ static void maybe_create_new_scb(struct plugin *p,
/* Note that this is opened for write-only, even though the permissions
* are set to read-only. That's perfectly valid! */
int fd = open("emergency.recover", O_CREAT|O_EXCL|O_WRONLY, 0400);
int fd = open(FILENAME, O_CREAT|O_EXCL|O_WRONLY, 0400);
if (fd < 0) {
/* Don't do anything if the file already exists. */
if (errno == EEXIST)
@@ -120,7 +122,7 @@ static void maybe_create_new_scb(struct plugin *p,
}
/* Comes here only if the file haven't existed before */
unlink_noerr("emergency.recover");
unlink_noerr(FILENAME);
/* This couldn't give EEXIST because we call unlink_noerr("scb.tmp")
* in INIT */
@@ -161,7 +163,7 @@ static void maybe_create_new_scb(struct plugin *p,
close(fd);
/* This will update the scb file */
rename("scb.tmp", "emergency.recover");
rename("scb.tmp", FILENAME);
}
@@ -169,9 +171,9 @@ static void maybe_create_new_scb(struct plugin *p,
static u8 *decrypt_scb(struct plugin *p)
{
struct stat st;
int fd = open("emergency.recover", O_RDONLY);
int fd = open(FILENAME, O_RDONLY);
if (stat("emergency.recover", &st) != 0)
if (stat(FILENAME, &st) != 0)
plugin_err(p, "SCB file is corrupted!: %s",
strerror(errno));
@@ -315,7 +317,7 @@ static void update_scb(struct plugin *p, struct scb_chan **channels)
close(fd);
/* This will atomically replace the main file */
rename("scb.tmp", "emergency.recover");
rename("scb.tmp", FILENAME);
}
static struct command_result *after_staticbackup(struct command *cmd,