Keeping a backup of previous ring file is now an option

master
Edouard Tisserant 8 years ago
parent 5ed7a0d585
commit ec72218253

@ -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