[gparted] Also write "Root privileges are required ..." message to stderr (!34)
- From: Curtis Gedak <gedakc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gparted] Also write "Root privileges are required ..." message to stderr (!34)
- Date: Wed, 3 Apr 2019 22:17:51 +0000 (UTC)
commit 56596d680a12d953497382882b6ca5889e6575a1
Author: Mike Fleetwood <mike fleetwood googlemail com>
Date: Sun Mar 31 18:49:05 2019 +0100
Also write "Root privileges are required ..." message to stderr (!34)
To further help in diagnosing root authorisation issues by reporting the
error message to the terminal too. Also set a failure exit status when
terminating with this error.
Example:
$ ./gpartedbin
GParted 0.33.0-git
configuration --enable-online-resize
libparted 3.2
Root privileges are required for running GParted
$ echo $?
1
Closes !34 - Display more version and configuration information
src/main.cc | 15 +++++++--------
1 file changed, 7 insertions(+), 8 deletions(-)
---
diff --git a/src/main.cc b/src/main.cc
index 91478db5..22ee9079 100644
--- a/src/main.cc
+++ b/src/main.cc
@@ -21,6 +21,7 @@
#include <gtkmm/messagedialog.h>
#include <gtkmm/main.h>
#include <iostream>
+#include <stdlib.h>
int main( int argc, char *argv[] )
@@ -43,15 +44,15 @@ int main( int argc, char *argv[] )
//check UID
if ( getuid() != 0 )
{
- Gtk::MessageDialog dialog( _("Root privileges are required for running GParted"),
- false,
- Gtk::MESSAGE_ERROR,
- Gtk::BUTTONS_OK ) ;
+ const Glib::ustring error_msg(_("Root privileges are required for running GParted"));
+ std::cerr << error_msg << std::endl;
+
+ Gtk::MessageDialog dialog(error_msg, false, Gtk::MESSAGE_ERROR, Gtk::BUTTONS_OK);
dialog .set_secondary_text(
_("Since GParted is a powerful tool capable of destroying partition tables
and vast amounts of data, only root may run it.") ) ;
dialog .run() ;
- exit( 0 ) ;
+ exit(EXIT_FAILURE);
}
//deal with arguments..
@@ -60,7 +61,5 @@ int main( int argc, char *argv[] )
GParted::Win_GParted win_gparted( user_devices ) ;
Gtk::Main::run( win_gparted ) ;
- return 0 ;
+ return EXIT_SUCCESS;
}
-
-
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]