Commit c77e1301 authored by Gene Z. Ragan's avatar Gene Z. Ragan Committed by Gene Ragan

Fixed bug 1474, special handling for running as root

2000-07-27  Gene Z. Ragan  <gzr@eazel.com>

	Fixed bug 1474, special handling for running as root

	* src/nautilus-application.c:
	(check_for_and_run_as_super_user):
	New function to determine if app is being run if root. If so,
	warn the user and allow them to cancel execution of
	the app.  Return users decision.

	(nautilus_application_startup):
	Call check_for_and_run_as_super_user. If the user is root
	and decides to quit, end program execution.
parent eb1052e1
2000-07-27 Gene Z. Ragan <gzr@eazel.com>
Fixed bug 1474, special handling for running as root
* src/nautilus-application.c:
(check_for_and_run_as_super_user):
New function to determine if app is being run if root. If so,
warn the user and allow them to cancel execution of
the app. Return users decision.
(nautilus_application_startup):
Call check_for_and_run_as_super_user. If the user is root
and decides to quit, end program execution.
2000-07-27 Ramiro Estrugo <ramiro@eazel.com>
* librsvg/Makefile.am:
......
......@@ -67,6 +67,7 @@ static void nautilus_application_initialize (NautilusApplic
static void nautilus_application_initialize_class (NautilusApplicationClass *klass);
static void nautilus_application_destroy (GtkObject *object);
static void nautilus_application_check_user_directories (NautilusApplication *application);
static gboolean check_for_and_run_as_super_user (void);
NAUTILUS_DEFINE_CLASS_BOILERPLATE (NautilusApplication, nautilus_application, BONOBO_OBJECT_TYPE)
......@@ -294,6 +295,11 @@ nautilus_application_startup (NautilusApplication *application,
Nautilus_URIList *url_list;
gboolean need_main_loop;
/* Perform check for nautilus being run as super user */
if (!check_for_and_run_as_super_user ()) {
return FALSE;
}
/* Check if this is the first time running the program by seeing
* if the user_main_directory exists; if not, run the first time druid
* instead of launching the application
......@@ -502,3 +508,34 @@ nautilus_application_create_window (NautilusApplication *application)
return window;
}
/*
* check_for_super_user:
*
* Puts out a warning if the user is running nautilus as root.
*/
static gboolean
check_for_and_run_as_super_user (void)
{
GtkWidget *warning_dlg;
gint result;
if (geteuid () != 0) {
return TRUE;
}
warning_dlg = gnome_message_box_new (
_("You are running Nautilus as root.\n\n"
"As root, you can damage your system if you are not careful, and\n"
"Nautilus will not stop you from doing it."),
GNOME_MESSAGE_BOX_WARNING,
GNOME_STOCK_BUTTON_OK, GNOME_STOCK_BUTTON_CANCEL, NULL);
result = gnome_dialog_run_and_close (GNOME_DIALOG (warning_dlg));
/* If they pressed cancel, quit the application */
if (result == 1) {
return FALSE;
}
return TRUE;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment