Browse Source

Keeping a backup of previous ring file is now an option

master
Edouard Tisserant 7 years ago
parent
commit
ec72218253
1 changed files with 8 additions and 1 deletions
  1. +8
    -1
      dist/src/lib/netpgp.c

+ 8
- 1
dist/src/lib/netpgp.c View File

@ -1182,7 +1182,9 @@ netpgp_save_ring(netpgp_t *netpgp,
return 0;
}
/* ensure temporary file isn't already existing */
unlink(swpfile);
if ((fd = pgp_setup_file_write(&output, swpfile, 0)) < 0) {
(void) fprintf(io->errs,
"netpgp_save_%s : can't setup write for %s\n", name, swpfile);
@ -1209,7 +1211,12 @@ netpgp_save_ring(netpgp_t *netpgp,
return 0;
}
rename(ringfile, backup);
/* save ring if "backup rings" variable is set */
if (netpgp_getvar(netpgp, "backup rings") != NULL) {
rename(ringfile, backup);
}
/* replace ring file with swap file */
rename(swpfile, ringfile);
return 1;


Loading…
Cancel
Save