Browse Source

Offer to overwrite existing config file.

If the configuration file we were about to write already exists,
ask the user whether we should overwrite it, and proceed or abort
accordingly.
develop
Damien Goutte-Gattat 3 years ago
parent
commit
4009edcf78
  1. 7
      src/gfsec-split.c

7
src/gfsec-split.c

@ -365,8 +365,11 @@ main(int argc, char **argv)
secret_file = argv[optind++];
transform_config_pathname(&config_path, secret_file);
if ( file_exists(config_path) != -1 )
errx(EXIT_FAILURE, _("Configuration file %s already exists"), config_path);
if ( file_exists(config_path) != -1 ) {
warn(_("Configuration file %s already exists"), config_path);
if ( ! ask_confirmation(_("Overwrite (y/N)?")) )
errx(EXIT_FAILURE, _("Split cancelled"));
}
if ( (c = gfsec_secret_set_secret_file(cfg, secret_file, output_file)) != 0 )
errx(EXIT_FAILURE, _("Cannot set secret: %s"), gfsec_error_string(c));

Loading…
Cancel
Save