Skip to content

Commit

Permalink
Add possibility to export authpro/2fas using the cli
Browse files Browse the repository at this point in the history
  • Loading branch information
paolostivanin committed Mar 8, 2024
1 parent f12b962 commit 36625da
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
26 changes: 26 additions & 0 deletions src/cli/exec-action.c
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,32 @@ gboolean exec_action (CmdlineOpts *cmdline_opts,
gcry_free (export_pwd);
exported = TRUE;
}
if (g_ascii_strcasecmp (cmdline_opts->export_type, "twofas_plain") == 0 || g_ascii_strcasecmp (cmdline_opts->export_type, "twofas_encrypted") == 0) {
if (g_ascii_strcasecmp (cmdline_opts->export_type, "twofas_encrypted") == 0) {
export_pwd = get_pwd (_("Type the export encryption password: "));
if (export_pwd == NULL) {
free_dbdata (db_data);
return FALSE;
}
}
exported_file_path = g_build_filename (export_directory, export_pwd != NULL ? "twofas_encrypted_v4.2fas" : "twofas_plain_v4.2fas", NULL);
ret_msg = export_twofas (exported_file_path, export_pwd, db_data->json_data);
gcry_free (export_pwd);
exported = TRUE;
}
if (g_ascii_strcasecmp (cmdline_opts->export_type, "authpro_plain") == 0 || g_ascii_strcasecmp (cmdline_opts->export_type, "authpro_encrypted") == 0) {
if (g_ascii_strcasecmp (cmdline_opts->export_type, "authpro_encrypted") == 0) {
export_pwd = get_pwd (_("Type the export encryption password: "));
if (export_pwd == NULL) {
free_dbdata (db_data);
return FALSE;
}
}
exported_file_path = g_build_filename (export_directory, export_pwd != NULL ? "authpro_encrypted.bin" : "authpro_plain.json", NULL);
ret_msg = export_authpro (exported_file_path, export_pwd, db_data->json_data);
gcry_free (export_pwd);
exported = TRUE;
}
if (ret_msg != NULL) {
g_printerr (_("An error occurred while exporting the data: %s\n"), ret_msg);
g_free (ret_msg);
Expand Down
2 changes: 1 addition & 1 deletion src/cli/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ main (gint argc,
{ "show-next", 'n', G_OPTION_FLAG_NONE, G_OPTION_ARG_NONE, NULL, "Show also next OTP (to be used with --show, optional)", NULL},
{ "list", 'l', G_OPTION_FLAG_NONE, G_OPTION_ARG_NONE, NULL, "List all accounts and issuers for a given database.", NULL },
{ "export", 'e', G_OPTION_FLAG_NONE, G_OPTION_ARG_NONE, NULL, "Export a database.", NULL },
{ "type", 't', G_OPTION_FLAG_NONE, G_OPTION_ARG_STRING, NULL, "The export type for the database. Must be either one of: andotp_plain, andotp_encrypted, freeotpplus, aegis, aegis_encrypted (to be used with --export, mandatory)", NULL },
{ "type", 't', G_OPTION_FLAG_NONE, G_OPTION_ARG_STRING, NULL, "The export type for the database. Must be either one of: andotp_plain, andotp_encrypted, freeotpplus, aegis_plain, aegis_encrypted, twofas_plain, twofas_encrypted, authpro_plain, authpro_encrypted (to be used with --export, mandatory)", NULL },
#ifndef USE_FLATPAK_APP_FOLDER
{ "output-dir", 'o', G_OPTION_FLAG_NONE, G_OPTION_ARG_STRING, NULL, "The output directory (defaults to the user's home. To be used with --export, optional)", NULL },
#endif
Expand Down

0 comments on commit 36625da

Please sign in to comment.