mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 13:37:45 +00:00
PartitionEditor: Abort and show a dialog if not running as root
This commit is contained in:
parent
7a8953a833
commit
fb4221ad52
1 changed files with 6 additions and 1 deletions
|
@ -14,6 +14,7 @@
|
||||||
#include <LibGUI/Menu.h>
|
#include <LibGUI/Menu.h>
|
||||||
#include <LibGUI/MessageBox.h>
|
#include <LibGUI/MessageBox.h>
|
||||||
#include <LibGUI/TableView.h>
|
#include <LibGUI/TableView.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
static Vector<String> get_device_paths()
|
static Vector<String> get_device_paths()
|
||||||
{
|
{
|
||||||
|
@ -46,7 +47,11 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
||||||
window->resize(640, 400);
|
window->resize(640, 400);
|
||||||
window->set_icon(app_icon.bitmap_for_size(16));
|
window->set_icon(app_icon.bitmap_for_size(16));
|
||||||
|
|
||||||
// FIXME: Abort and show a dialog if not running as root.
|
if (getuid() != 0) {
|
||||||
|
auto error_message = "PartitionEditor must be run as root in order to open raw block devices and read partition tables."sv;
|
||||||
|
GUI::MessageBox::show_error(window, error_message);
|
||||||
|
return Error::from_string_view(error_message);
|
||||||
|
}
|
||||||
|
|
||||||
auto widget = TRY(window->try_set_main_widget<GUI::Widget>());
|
auto widget = TRY(window->try_set_main_widget<GUI::Widget>());
|
||||||
widget->load_from_gml(partition_editor_window_gml);
|
widget->load_from_gml(partition_editor_window_gml);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue