aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSaturneric <[email protected]>2023-02-11 12:08:24 +0000
committerSaturneric <[email protected]>2023-02-11 12:08:24 +0000
commit1935399c920c354eb195d8e957b88cd801dbb7c2 (patch)
tree33377398ab2f5c021deb80a2d4bf8f4c1b6853ae
parentfeat: codesign and add entitlements for buddled gnupg binaries (diff)
downloadGpgFrontend-1935399c920c354eb195d8e957b88cd801dbb7c2.tar.gz
GpgFrontend-1935399c920c354eb195d8e957b88cd801dbb7c2.zip
feat: show checksums of all gnupg components
-rw-r--r--src/core/GpgContext.cpp68
-rw-r--r--src/core/GpgContext.h7
-rw-r--r--src/core/GpgInfo.h18
-rw-r--r--src/ui/dialog/help/AboutDialog.cpp2
-rw-r--r--src/ui/dialog/help/GnupgTab.cpp19
5 files changed, 88 insertions, 26 deletions
diff --git a/src/core/GpgContext.cpp b/src/core/GpgContext.cpp
index 1b2669b8..de6ea33c 100644
--- a/src/core/GpgContext.cpp
+++ b/src/core/GpgContext.cpp
@@ -339,9 +339,14 @@ const GpgInfo &GpgContext::GetInfo(bool refresh) {
auto &components_info = info_.ComponentsInfo;
components_info["gpgme"] = {"GPG Made Easy", info_.GpgMEVersion,
- _("Embedded In")};
- components_info["gpgconf"] = {"GPG Configure", "/",
- info_.GpgConfPath};
+ _("Embedded In"), "/"};
+
+ auto gpgconf_binary_checksum =
+ check_binary_chacksum(info_.GpgConfPath);
+ components_info["gpgconf"] = {"GPG Configure", "/", info_.GpgConfPath,
+ gpgconf_binary_checksum.has_value()
+ ? gpgconf_binary_checksum.value()
+ : "/"};
std::vector<std::string> line_split_list;
boost::split(line_split_list, p_out, boost::is_any_of("\n"));
@@ -349,19 +354,39 @@ const GpgInfo &GpgContext::GetInfo(bool refresh) {
for (const auto &line : line_split_list) {
std::vector<std::string> info_split_list;
boost::split(info_split_list, line, boost::is_any_of(":"));
- SPDLOG_INFO("gpgconf info line: {} info size: {}", line,
- info_split_list.size());
if (info_split_list.size() != 3) continue;
auto component_name = info_split_list[0];
+ auto component_desc = info_split_list[1];
+ auto component_path = info_split_list[2];
+ auto binary_checksum = check_binary_chacksum(component_path);
+
+ SPDLOG_DEBUG(
+ "gnupg component name: {} desc: {} checksum: {} path: {} ",
+ component_name, component_desc,
+ binary_checksum.has_value() ? binary_checksum.value() : "/",
+ component_path);
+
+ std::string version = "/";
+
if (component_name == "gpg") {
- components_info[component_name] = {
- info_split_list[1], info_.GnupgVersion, info_split_list[2]};
- } else {
- components_info[component_name] = {info_split_list[1], "/",
- info_split_list[2]};
+ version = info_.GnupgVersion;
+ }
+ if (component_name == "gpg-agent") {
+ info_.GpgAgentPath = info_split_list[2];
+ }
+ if (component_name == "dirmngr") {
+ info_.DirmngrPath = info_split_list[2];
+ }
+ if (component_name == "keyboxd") {
+ info_.KeyboxdPath = info_split_list[2];
}
+
+ // add component info to list
+ components_info[component_name] = {
+ component_desc, version, component_path,
+ binary_checksum.has_value() ? binary_checksum.value() : "/"};
}
});
@@ -393,6 +418,11 @@ const GpgInfo &GpgContext::GetInfo(bool refresh) {
if (info_split_list.size() != 2) continue;
+ // record gnupg home path
+ if (info_split_list[0] == "homedir") {
+ info_.GnuPGHomePath = info_split_list[1];
+ }
+
auto configuration_name = info_split_list[0];
configurations_info[configuration_name] = {info_split_list[1]};
}
@@ -492,6 +522,24 @@ const GpgInfo &GpgContext::GetInfo(bool refresh) {
return info_;
}
+std::optional<std::string> GpgContext::check_binary_chacksum(
+ std::filesystem::path path) {
+ QFile f(QString::fromStdString(path.u8string()));
+ if (!f.open(QFile::ReadOnly)) return {};
+
+ // read all data from file
+ auto buffer = f.readAll();
+ f.close();
+
+ auto hash_md5 = QCryptographicHash(QCryptographicHash::Md5);
+ // md5
+ hash_md5.addData(buffer);
+ auto md5 = hash_md5.result().toHex().toStdString();
+ SPDLOG_DEBUG("md5 {}", md5);
+
+ return md5.substr(0, 6);
+}
+
void GpgContext::_ctx_ref_deleter::operator()(gpgme_ctx_t _ctx) {
if (_ctx != nullptr) gpgme_release(_ctx);
}
diff --git a/src/core/GpgContext.h b/src/core/GpgContext.h
index b25fcf15..79d76fe2 100644
--- a/src/core/GpgContext.h
+++ b/src/core/GpgContext.h
@@ -29,6 +29,7 @@
#ifndef __SGPGMEPP_CONTEXT_H__
#define __SGPGMEPP_CONTEXT_H__
+#include <optional>
#include <string>
#include "GpgConstants.h"
@@ -124,6 +125,12 @@ class GPGFRONTEND_CORE_EXPORT GpgContext
std::string need_user_input_passphrase();
/**
+ * @brief Construct a new std::check component existence object
+ *
+ */
+ std::optional<std::string> check_binary_chacksum(std::filesystem::path);
+
+ /**
* @brief
*
*/
diff --git a/src/core/GpgInfo.h b/src/core/GpgInfo.h
index 53c5c3f5..115b7911 100644
--- a/src/core/GpgInfo.h
+++ b/src/core/GpgInfo.h
@@ -38,13 +38,17 @@ namespace GpgFrontend {
*/
class GpgInfo {
public:
- std::string AppPath; ///< executable binary path of gnupg
- std::string DatabasePath; ///<
- std::string GnupgVersion; ///<
- std::string GpgConfPath; ///<
- std::string AssuanPath; ///<
- std::string CMSPath; ///<
- std::string GpgMEVersion; ///<
+ std::string AppPath; ///< executable binary path of gnupg
+ std::string DatabasePath; ///<
+ std::string GnupgVersion; ///<
+ std::string GpgConfPath; ///<
+ std::string AssuanPath; ///<
+ std::string CMSPath; ///<
+ std::string GpgAgentPath; ///<
+ std::string DirmngrPath; ///<
+ std::string KeyboxdPath; ///<
+ std::string GpgMEVersion; ///<
+ std::string GnuPGHomePath; ///<
std::map<std::string, std::vector<std::string>> ComponentsInfo; ///<
std::map<std::string, std::vector<std::string>> ConfigurationsInfo; ///<
diff --git a/src/ui/dialog/help/AboutDialog.cpp b/src/ui/dialog/help/AboutDialog.cpp
index 3fc09ff1..2b5ef099 100644
--- a/src/ui/dialog/help/AboutDialog.cpp
+++ b/src/ui/dialog/help/AboutDialog.cpp
@@ -66,7 +66,7 @@ AboutDialog::AboutDialog(int defaultIndex, QWidget* parent)
mainLayout->addWidget(buttonBox);
setLayout(mainLayout);
- this->resize(450, 580);
+ this->resize(550, 650);
this->setMinimumWidth(450);
this->show();
}
diff --git a/src/ui/dialog/help/GnupgTab.cpp b/src/ui/dialog/help/GnupgTab.cpp
index 92e2786d..92c3fd55 100644
--- a/src/ui/dialog/help/GnupgTab.cpp
+++ b/src/ui/dialog/help/GnupgTab.cpp
@@ -43,7 +43,7 @@ GpgFrontend::UI::GnupgTab::GnupgTab(QWidget* parent)
QStringList components_column_titles;
components_column_titles << _("Name") << _("Description") << _("Version")
- << _("Path");
+ << _("Checksum") << _("Path");
ui_->componentDetailsTable->setColumnCount(components_column_titles.length());
ui_->componentDetailsTable->setHorizontalHeaderLabels(
@@ -64,8 +64,6 @@ GpgFrontend::UI::GnupgTab::GnupgTab(QWidget* parent)
ui_->configurationDetailsTable->setSelectionBehavior(
QAbstractItemView::SelectRows);
- ui_->softwareDetailsTableTitle->setText(_("Software Information"));
-
// tableitems not editable
ui_->componentDetailsTable->setEditTriggers(
QAbstractItemView::NoEditTriggers);
@@ -79,15 +77,16 @@ GpgFrontend::UI::GnupgTab::GnupgTab(QWidget* parent)
}
void GpgFrontend::UI::GnupgTab::process_software_info() {
- SPDLOG_INFO("called");
-
auto ctx_info = GpgContext::GetInstance().GetInfo(true);
+ ui_->gnupgVersionLabel->setText(QString::fromStdString(
+ fmt::format("Version: {}", ctx_info.GnupgVersion)));
+
ui_->componentDetailsTable->setRowCount(ctx_info.ComponentsInfo.size());
int row = 0;
for (const auto& info : ctx_info.ComponentsInfo) {
- if (info.second.size() != 3) continue;
+ if (info.second.size() != 4) continue;
auto* tmp0 = new QTableWidgetItem(QString::fromStdString(info.first));
tmp0->setTextAlignment(Qt::AlignCenter);
@@ -101,10 +100,14 @@ void GpgFrontend::UI::GnupgTab::process_software_info() {
tmp2->setTextAlignment(Qt::AlignCenter);
ui_->componentDetailsTable->setItem(row, 2, tmp2);
- auto* tmp3 = new QTableWidgetItem(QString::fromStdString(info.second[2]));
- tmp3->setTextAlignment(Qt::AlignLeft);
+ auto* tmp3 = new QTableWidgetItem(QString::fromStdString(info.second[3]));
+ tmp3->setTextAlignment(Qt::AlignCenter);
ui_->componentDetailsTable->setItem(row, 3, tmp3);
+ auto* tmp4 = new QTableWidgetItem(QString::fromStdString(info.second[2]));
+ tmp4->setTextAlignment(Qt::AlignLeft);
+ ui_->componentDetailsTable->setItem(row, 4, tmp4);
+
row++;
}