mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-19 15:14:23 +01:00
plugins/chanbackup: Define FILENAME globally (Good Manners)
This commit is contained in:
@@ -21,6 +21,8 @@
|
|||||||
#define HEADER_LEN crypto_secretstream_xchacha20poly1305_HEADERBYTES
|
#define HEADER_LEN crypto_secretstream_xchacha20poly1305_HEADERBYTES
|
||||||
#define ABYTES crypto_secretstream_xchacha20poly1305_ABYTES
|
#define ABYTES crypto_secretstream_xchacha20poly1305_ABYTES
|
||||||
|
|
||||||
|
#define FILENAME "emergency.recover"
|
||||||
|
|
||||||
/* VERSION is the current version of the data encrypted in the file */
|
/* VERSION is the current version of the data encrypted in the file */
|
||||||
#define VERSION ((u64)1)
|
#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
|
/* Note that this is opened for write-only, even though the permissions
|
||||||
* are set to read-only. That's perfectly valid! */
|
* 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) {
|
if (fd < 0) {
|
||||||
/* Don't do anything if the file already exists. */
|
/* Don't do anything if the file already exists. */
|
||||||
if (errno == EEXIST)
|
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 */
|
/* 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")
|
/* This couldn't give EEXIST because we call unlink_noerr("scb.tmp")
|
||||||
* in INIT */
|
* in INIT */
|
||||||
@@ -161,7 +163,7 @@ static void maybe_create_new_scb(struct plugin *p,
|
|||||||
close(fd);
|
close(fd);
|
||||||
|
|
||||||
/* This will update the scb file */
|
/* 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)
|
static u8 *decrypt_scb(struct plugin *p)
|
||||||
{
|
{
|
||||||
struct stat st;
|
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",
|
plugin_err(p, "SCB file is corrupted!: %s",
|
||||||
strerror(errno));
|
strerror(errno));
|
||||||
|
|
||||||
@@ -315,7 +317,7 @@ static void update_scb(struct plugin *p, struct scb_chan **channels)
|
|||||||
close(fd);
|
close(fd);
|
||||||
|
|
||||||
/* This will atomically replace the main file */
|
/* 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,
|
static struct command_result *after_staticbackup(struct command *cmd,
|
||||||
|
|||||||
Reference in New Issue
Block a user