diff options
author | Samuel Bowman <sam@sambowman.tech> | 2022-06-28 00:11:42 -0400 |
---|---|---|
committer | Linus Groh <mail@linusgroh.de> | 2022-07-21 20:13:44 +0100 |
commit | fb4221ad52f9c03edebc96e070ebbde25e8c50fb (patch) | |
tree | b76e3572a5f960942db893bd367420f98a5da5a9 /Userland/Applications | |
parent | 7a8953a833e5243df4809ae8b9bffc3a1bab10e1 (diff) | |
download | serenity-fb4221ad52f9c03edebc96e070ebbde25e8c50fb.zip |
PartitionEditor: Abort and show a dialog if not running as root
Diffstat (limited to 'Userland/Applications')
-rw-r--r-- | Userland/Applications/PartitionEditor/main.cpp | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/Userland/Applications/PartitionEditor/main.cpp b/Userland/Applications/PartitionEditor/main.cpp index c8e53f4a27..dff685ce4d 100644 --- a/Userland/Applications/PartitionEditor/main.cpp +++ b/Userland/Applications/PartitionEditor/main.cpp @@ -14,6 +14,7 @@ #include <LibGUI/Menu.h> #include <LibGUI/MessageBox.h> #include <LibGUI/TableView.h> +#include <unistd.h> static Vector<String> get_device_paths() { @@ -46,7 +47,11 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) window->resize(640, 400); 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>()); widget->load_from_gml(partition_editor_window_gml); |