Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release 3.4.0 #344

Merged
merged 4 commits into from
Feb 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
cmake_minimum_required(VERSION 3.16)
project(OTPClient VERSION "3.3.0" LANGUAGES "C")
project(OTPClient VERSION "3.4.0" LANGUAGES "C")
include(GNUInstallDirs)

configure_file("src/common/version.h.in" "version.h")
Expand Down Expand Up @@ -88,7 +88,8 @@ set(GUI_HEADER_FILES
src/shortcuts-cb.h
src/webcam-add-cb.h
src/edit-row-cb.h
src/show-qr-cb.h src/dbinfo-cb.h)
src/show-qr-cb.h src/dbinfo-cb.h
src/change-file-cb.h)

set(GUI_SOURCE_FILES
src/common/common.c
Expand Down Expand Up @@ -128,10 +129,10 @@ set(GUI_SOURCE_FILES
src/about_diag_cb.c
src/show-qr-cb.c
src/setup-signals-shortcuts.c
src/change-pwd-cb.c src/dbinfo-cb.c)
src/change-pwd-cb.c
src/dbinfo-cb.c)

set(CLI_HEADER_FILES
src/cli/help.h
src/cli/get-data.h
src/common/common.h
src/db-misc.h
Expand All @@ -141,15 +142,17 @@ set(CLI_HEADER_FILES
src/parse-uri.h
src/common/get-providers-data.h
src/google-migration.pb-c.h
src/secret-schema.h)
src/secret-schema.h
src/cli/main.h
)

set(CLI_SOURCE_FILES
src/cli/main.c
src/cli/help.c
src/cli/get-data.c
src/common/common.c
src/db-misc.c
src/gquarks.c
src/cli/exec-action.c
src/file-size.c
src/parse-uri.c
src/common/andotp.c
Expand Down
14 changes: 14 additions & 0 deletions data/com.github.paolostivanin.OTPClient.appdata.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
<keyword>2fa</keyword>
<keyword>2factor</keyword>
<keyword>2fa-client</keyword>
<keyword>2step</keyword>
<keyword>twostep</keyword>
</keywords>

<description>
Expand Down Expand Up @@ -87,6 +89,18 @@
</content_rating>

<releases>
<release version="3.4.0" date="2024-02-09">
<description>
<p>OTPClient 3.4.0 brings the following changes:</p>
<ul>
<li>NEW: you can now specify a database when calling the CLI (#340)</li>
<li>FIX: handling errors when path and/or password is incorrect (#336)</li>
<li>FIX: prompt for file again, if needed (#335)</li>
<li>FIX: prevent about dialog from hiding</li>
<li>FIX: use system RNG as source of entropy</li>
</ul>
</description>
</release>
<release version="3.3.0" date="2024-01-08">
<description>
<p>OTPClient 3.3.0 brings the following changes:</p>
Expand Down
6 changes: 5 additions & 1 deletion src/app.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include "edit-row-cb.h"
#include "show-qr-cb.h"
#include "dbinfo-cb.h"
#include "change-file-cb.h"

#ifndef USE_FLATPAK_APP_FOLDER
static gchar *get_db_path (AppData *app_data);
Expand Down Expand Up @@ -208,11 +209,14 @@ activate (GtkApplication *app,
retry:
app_data->db_data->key = prompt_for_password (app_data, NULL, NULL, FALSE);
if (app_data->db_data->key == NULL) {
if (change_file (app_data) == FALSE) {
retry_change_file:
if (change_file (app_data) == QUIT_APP) {
g_free (app_data->db_data);
g_free (app_data);
g_application_quit (G_APPLICATION(app));
return;
} else {
goto retry_change_file;
}
}
}
Expand Down
69 changes: 48 additions & 21 deletions src/change-db-cb.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,11 @@
#include "password-cb.h"
#include "db-actions.h"
#include "secret-schema.h"
#include "change-file-cb.h"


void
change_db_cb (GSimpleAction *simple __attribute__((unused)),
GVariant *parameter __attribute__((unused)),
gpointer user_data)
int
change_db (AppData *app_data)
{
AppData *app_data = (AppData *)user_data;

GtkWidget *changedb_diag = GTK_WIDGET(gtk_builder_get_object (app_data->builder, "changedb_diag_id"));
GtkWidget *old_changedb_entry = GTK_WIDGET(gtk_builder_get_object (app_data->builder, "changedb_olddb_entry_id"));
GtkWidget *new_changedb_entry = GTK_WIDGET(gtk_builder_get_object (app_data->builder, "changedb_entry_id"));
Expand All @@ -29,29 +25,60 @@ change_db_cb (GSimpleAction *simple __attribute__((unused)),
gint result = gtk_dialog_run (GTK_DIALOG (changedb_diag));
switch (result) {
case GTK_RESPONSE_OK:
if (gtk_entry_get_text_length (GTK_ENTRY(new_changedb_entry)) == 0) {
show_message_dialog (app_data->main_window, "Input path cannot be empty.", GTK_MESSAGE_ERROR);
gtk_widget_hide (changedb_diag);
return RETRY_CHANGE;
}
new_db_path = gtk_entry_get_text (GTK_ENTRY(new_changedb_entry));
if (!g_file_test (new_db_path, G_FILE_TEST_IS_REGULAR) || g_file_test (new_db_path,G_FILE_TEST_IS_SYMLINK)){
show_message_dialog (app_data->main_window, "Selected file is either a symlink or a non regular file.\nPlease choose another file.", GTK_MESSAGE_ERROR);
} else {
g_free (app_data->db_data->db_path);
app_data->db_data->db_path = g_strdup (new_db_path);
update_cfg_file (app_data);
gcry_free (app_data->db_data->key);
app_data->db_data->key = prompt_for_password (app_data, NULL, NULL, FALSE);
secret_password_store (OTPCLIENT_SCHEMA, SECRET_COLLECTION_DEFAULT, "main_pwd", app_data->db_data->key, NULL, on_password_stored, NULL, "string", "main_pwd", NULL);
GError *err = NULL;
load_new_db (app_data, &err);
if (err != NULL) {
show_message_dialog (app_data->main_window, err->message, GTK_MESSAGE_ERROR);
g_clear_error (&err);
}
gtk_widget_hide (changedb_diag);
return RETRY_CHANGE;
}
gchar *old_db_path = g_strdup (app_data->db_data->db_path);
g_free (app_data->db_data->db_path);
app_data->db_data->db_path = g_strdup (new_db_path);
update_cfg_file (app_data);
gcry_free (app_data->db_data->key);
app_data->db_data->key = prompt_for_password (app_data, NULL, NULL, FALSE);
if (app_data->db_data->key == NULL) {
gtk_widget_hide (changedb_diag);
revert_db_path (app_data, old_db_path);
return RETRY_CHANGE;
}
secret_password_store (OTPCLIENT_SCHEMA, SECRET_COLLECTION_DEFAULT, "main_pwd", app_data->db_data->key, NULL, on_password_stored, NULL, "string", "main_pwd", NULL);
GError *err = NULL;
load_new_db (app_data, &err);
if (err != NULL) {
show_message_dialog (app_data->main_window, err->message, GTK_MESSAGE_ERROR);
g_clear_error (&err);
gtk_widget_hide (changedb_diag);
revert_db_path (app_data, old_db_path);
return RETRY_CHANGE;
}
g_free (old_db_path);
break;
case GTK_RESPONSE_CANCEL:
gtk_widget_destroy (changedb_diag);
return QUIT_APP;
default:
break;
}
gtk_widget_destroy (changedb_diag);

return CHANGE_OK;
}


void
change_db_cb (GSimpleAction *action_name __attribute__((unused)),
GVariant *parameter __attribute__((unused)),
gpointer user_data)
{
AppData *app_data = (AppData *)user_data;

change_db (app_data);
}


Expand All @@ -60,4 +87,4 @@ change_db_cb_shortcut (GtkWidget *w __attribute__((unused)),
gpointer user_data)
{
change_db_cb (NULL, NULL, user_data);
}
}
2 changes: 2 additions & 0 deletions src/change-db-cb.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

G_BEGIN_DECLS

int change_db (AppData *app_data);

void change_db_cb (GSimpleAction *simple,
GVariant *parameter,
gpointer user_data);
Expand Down
14 changes: 7 additions & 7 deletions src/change-file-cb.c
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#include <gtk/gtk.h>
#include "new-db-cb.h"
#include "change-db-cb.h"
#include "db-misc.h"
#include "change-file-cb.h"
#include "message-dialogs.h"

gboolean
int
change_file (AppData *app_data)
{
GtkWidget *label = GTK_WIDGET(gtk_builder_get_object (app_data->builder, "diag_changefile_label_id"));
Expand All @@ -21,18 +21,18 @@ change_file (AppData *app_data)
switch (result) {
case GTK_RESPONSE_ACCEPT:
// select an existing DB.
change_db_cb (NULL, NULL, app_data);
res = TRUE;
res = change_db (app_data);
break;
case GTK_RESPONSE_OK:
// create a new db.
new_db_cb (NULL, NULL, app_data);
res = TRUE;
res = new_db (app_data);
break;
case GTK_RESPONSE_CANCEL:
case GTK_RESPONSE_CLOSE:
res = QUIT_APP;
default:
break;
}

gtk_widget_hide (diag_changefile);

return res;
Expand Down
13 changes: 13 additions & 0 deletions src/change-file-cb.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#pragma once

#include "data.h"

G_BEGIN_DECLS

#define QUIT_APP 50
#define RETRY_CHANGE 51
#define CHANGE_OK 52

int change_file (AppData *app_data);

G_END_DECLS
Loading
Loading