Skip to content

Commit

Permalink
Display EFI PK certificate information
Browse files Browse the repository at this point in the history
Fix #336
  • Loading branch information
TheTumultuousUnicornOfDarkness committed Oct 5, 2024
1 parent 7d041dc commit a01a17b
Show file tree
Hide file tree
Showing 6 changed files with 76 additions and 5 deletions.
49 changes: 48 additions & 1 deletion data/cpu-x-gtk-3.12.ui
Original file line number Diff line number Diff line change
Expand Up @@ -2237,7 +2237,7 @@
<property name="margin-end">6</property>
<property name="margin-bottom">6</property>
<child>
<!-- n-columns=2 n-rows=4 -->
<!-- n-columns=2 n-rows=5 -->
<object class="GtkGrid" id="bios_grid">
<property name="visible">True</property>
<property name="can-focus">False</property>
Expand Down Expand Up @@ -2430,6 +2430,53 @@
<property name="top-attach">3</property>
</packing>
</child>
<child>
<object class="GtkAspectFrame" id="bios_frampk">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="margin-top">1</property>
<property name="margin-bottom">1</property>
<property name="label-xalign">0</property>
<property name="shadow-type">in</property>
<child>
<object class="GtkLabel" id="bios_valpk">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="hexpand">True</property>
<property name="justify">center</property>
<property name="selectable">True</property>
<property name="ellipsize">end</property>
<property name="width-chars">40</property>
<property name="single-line-mode">True</property>
<property name="max-width-chars">40</property>
<property name="lines">1</property>
</object>
</child>
</object>
<packing>
<property name="left-attach">1</property>
<property name="top-attach">4</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="bios_labpk">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="halign">end</property>
<property name="margin-end">4</property>
<property name="margin-top">1</property>
<property name="margin-bottom">1</property>
<property name="mnemonic-widget">bios_valrom</property>
<property name="ellipsize">end</property>
<property name="single-line-mode">True</property>
<property name="max-width-chars">15</property>
<property name="lines">1</property>
</object>
<packing>
<property name="left-attach">0</property>
<property name="top-attach">4</property>
</packing>
</child>
</object>
</child>
</object>
Expand Down
19 changes: 19 additions & 0 deletions src/core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -745,6 +745,24 @@ static int call_bandwidth([[maybe_unused]] Data &data)
}
#endif /* HAS_BANDWIDTH */

static int efi_readvar(Data &data)
{
int err = 0;
std::string pk_subject, pk_issuer;

if(!command_exists("efi-readvar"))
return 1;

/* Get Platform Key (PK) X509 information */
err += popen_to_str(pk_subject, "efi-readvar -v PK | grep -A1 Subject: | tail -n-1 | cut -d= -f2");
err += popen_to_str(pk_issuer, "efi-readvar -v PK | grep -A1 Issuer: | tail -n-1 | cut -d= -f2");

if(!err)
data.motherboard.bios.efi_pk.value = string_format(_("%s (subject) / %s (issuer)"), pk_subject.c_str(), pk_issuer.c_str());

return err;
}

#if HAS_LIBPCI
/* Check is GPU is enabled */
static bool gpu_is_on([[maybe_unused]] std::string device_path)
Expand Down Expand Up @@ -2501,6 +2519,7 @@ int fill_labels(Data &data)
err += find_devices(data);
#endif

err += efi_readvar (data);
err += system_static (data);
err += fallback_mode_static(data);

Expand Down
1 change: 1 addition & 0 deletions src/data.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -469,6 +469,7 @@ std::ostream& operator<<(std::ostream& os, const Data::Motherboard::Bios& bios)
os << static_cast<const Label&>(bios.version);
os << static_cast<const Label&>(bios.date);
os << static_cast<const Label&>(bios.romsize);
os << static_cast<const Label&>(bios.efi_pk);
os << std::endl;
return os;
}
Expand Down
1 change: 1 addition & 0 deletions src/data.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,7 @@ struct Data
Label version {_("Version")};
Label date {_("Date")};
Label romsize {_("ROM Size")};
Label efi_pk {_("EFI PK")};

Bios();
friend std::ostream& operator<<(std::ostream& os, const Bios& bios);
Expand Down
2 changes: 2 additions & 0 deletions src/gui_gtk.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,7 @@ void GtkData::get_widgets(Glib::RefPtr<Gtk::Builder> builder)
this->data.motherboard.bios.version.extend(new ExtLabel<Gtk::Label>(builder, "bios_vers"));
this->data.motherboard.bios.date. extend(new ExtLabel<Gtk::Label>(builder, "bios_date"));
this->data.motherboard.bios.romsize.extend(new ExtLabel<Gtk::Label>(builder, "bios_rom"));
this->data.motherboard.bios.efi_pk. extend(new ExtLabel<Gtk::Label>(builder, "bios_pk"));
/* Chipset frame */
this->data.motherboard.chipset.extend(new ExtFrame(builder, "chip_lab"));
this->data.motherboard.chipset.vendor.extend(new ExtLabel<Gtk::Label>(builder, "chip_vend"));
Expand Down Expand Up @@ -862,6 +863,7 @@ void GtkData::gtab_motherboard()
set_label_name_and_value(this->data.motherboard.bios.version);
set_label_name_and_value(this->data.motherboard.bios.date);
set_label_name_and_value(this->data.motherboard.bios.romsize);
set_label_name_and_value(this->data.motherboard.bios.efi_pk, _("EFI Platform Key certificate information"));

/* Chipset frame */
set_frame_name(this->data.motherboard.chipset);
Expand Down
9 changes: 5 additions & 4 deletions src/tui_ncurses.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -429,16 +429,17 @@ static void ntab_motherboard(WINDOW *win, Data &data)
mvwprintw2c(win, LINE_3, SizeInfo::tb, "%13s", "%s", data.motherboard.board.revision);

/* BIOS frame */
draw_frame(win, LINE_5, SizeInfo::start , LINE_10, SizeInfo::width - 1, data.motherboard.bios);
draw_frame(win, LINE_5, SizeInfo::start , LINE_11, SizeInfo::width - 1, data.motherboard.bios);
mvwprintw2c(win, LINE_6, SizeInfo::tb, "%13s", "%s", data.motherboard.bios.brand);
mvwprintw2c(win, LINE_7, SizeInfo::tb, "%13s", "%s", data.motherboard.bios.version);
mvwprintw2c(win, LINE_8, SizeInfo::tb, "%13s", "%s", data.motherboard.bios.date);
mvwprintw2c(win, LINE_9, SizeInfo::tb, "%13s", "%s", data.motherboard.bios.romsize);
mvwprintw2c(win, LINE_10, SizeInfo::tb, "%13s", "%s", data.motherboard.bios.efi_pk);

/* Chipset frame */
draw_frame(win, LINE_11, SizeInfo::start , LINE_14, SizeInfo::width - 1, data.motherboard.chipset);
mvwprintw2c(win, LINE_12, SizeInfo::tb, "%13s", "%s", data.motherboard.chipset.vendor);
mvwprintw2c(win, LINE_13, SizeInfo::tb, "%13s", "%s", data.motherboard.chipset.model);
draw_frame(win, LINE_12, SizeInfo::start , LINE_15, SizeInfo::width - 1, data.motherboard.chipset);
mvwprintw2c(win, LINE_13, SizeInfo::tb, "%13s", "%s", data.motherboard.chipset.vendor);
mvwprintw2c(win, LINE_14, SizeInfo::tb, "%13s", "%s", data.motherboard.chipset.model);
}

/* Memory tab */
Expand Down

0 comments on commit a01a17b

Please sign in to comment.