Really patch out libgnomesu

This commit is contained in:
Matthias Clasen 2005-02-02 20:08:54 +00:00
parent 7210f972c1
commit 1c86b90b08
2 changed files with 140 additions and 126 deletions

View File

@ -1,13 +1,142 @@
--- gnome-system-monitor-2.9.90/src/util.c.libgnomesu 2005-02-02 14:33:26.000000000 -0500
+++ gnome-system-monitor-2.9.90/src/util.c 2005-02-02 14:41:25.000000000 -0500
@@ -1,10 +1,292 @@
--- gnome-system-monitor-2.9.90/configure.in.libgnomesu 2005-01-24 09:06:57.000000000 -0500
+++ gnome-system-monitor-2.9.90/configure.in 2005-02-02 15:03:45.000000000 -0500
@@ -19,9 +19,8 @@
LIBGTOP_REQUIRED=2.9.5
GTK_REQUIRED=2.5.0
GNOME_VFS_REQUIRED=2.6.0
-LIBGNOMESU_REQUIRED=0.9.3
-PKG_CHECK_MODULES(PROCMAN, libgnome-2.0 >= $LIBGNOME_REQUIRED libgnomeui-2.0 >= $LIBGNOMEUI_REQUIRED gconf-2.0 >= $GCONF_REQUIRED libgtop-2.0 >= $LIBGTOP_REQUIRED libwnck-1.0 >= $LIBWNCK_REQUIRED gtk+-2.0 >= $GTK_REQUIRED gnome-vfs-2.0 >= $GNOME_VFS_REQUIRED libgnomesu-1.0 >= $LIBGNOMESU_REQUIRED)
+PKG_CHECK_MODULES(PROCMAN, libgnome-2.0 >= $LIBGNOME_REQUIRED libgnomeui-2.0 >= $LIBGNOMEUI_REQUIRED gconf-2.0 >= $GCONF_REQUIRED libgtop-2.0 >= $LIBGTOP_REQUIRED libwnck-1.0 >= $LIBWNCK_REQUIRED gtk+-2.0 >= $GTK_REQUIRED gnome-vfs-2.0 >= $GNOME_VFS_REQUIRED)
AC_ARG_ENABLE(more-warnings,
--- gnome-system-monitor-2.9.90/src/procdialogs.c.libgnomesu 2005-01-13 19:05:00.000000000 -0500
+++ gnome-system-monitor-2.9.90/src/procdialogs.c 2005-02-02 15:03:45.000000000 -0500
@@ -23,7 +23,6 @@
#include <signal.h>
#include <string.h>
-#include <libgnomesu/libgnomesu.h>
#include "procdialogs.h"
#include "favorites.h"
#include "proctable.h"
@@ -815,13 +814,101 @@
void procdialog_create_root_password_dialog (gint type, ProcData *procdata, gint pid,
gint extra_value, gchar *text)
{
+ GtkWidget *dialog;
+ GtkWidget *error_dialog;
+ GtkWidget *main_vbox;
+ GtkWidget *hbox;
+ GtkWidget *entry;
+ GtkWidget *label;
+ gchar *title = NULL, *button_label;
gchar *command;
+ gchar *password, *blank;
+ gint retval;
+
+ if (type == 0) {
+ if (extra_value == SIGKILL) {
+ title = g_strdup (_("Kill Process"));
+ button_label = g_strdup (_("_Kill Process"));
+ }
+ else {
+ title = g_strdup (_("End Process"));
+ button_label = g_strdup (_("_End Process"));
+ }
+ }
+ else {
+ title = g_strdup (_("Change Priority"));
+ button_label = g_strdup (_("Change _Priority"));
+ }
+
+ dialog = gtk_dialog_new_with_buttons (title, NULL, GTK_DIALOG_DESTROY_WITH_PARENT,
+ GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
+ button_label, 100,
+ NULL);
+
+ main_vbox = GTK_DIALOG (dialog)->vbox;
+
+ label = gtk_label_new (_(text));
+ gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
+ gtk_misc_set_padding (GTK_MISC (label), GNOME_PAD, 2 * GNOME_PAD);
+ gtk_box_pack_start (GTK_BOX (main_vbox), label, FALSE, FALSE, 0);
+
+ hbox = gtk_hbox_new (FALSE, 0);
+ gtk_container_set_border_width (GTK_CONTAINER (hbox), GNOME_PAD_SMALL);
+ gtk_box_pack_start (GTK_BOX (main_vbox), hbox, FALSE, FALSE, 0);
+
+ label = gtk_label_new (_("Root Password :"));
+ gtk_misc_set_padding (GTK_MISC (label), GNOME_PAD_SMALL, 0);
+ gtk_box_pack_start (GTK_BOX (hbox), label, TRUE, FALSE, 0);
+
+ entry = gtk_entry_new ();
+ gtk_entry_set_visibility (GTK_ENTRY (entry), FALSE);
+ gtk_box_pack_start (GTK_BOX (hbox), entry, TRUE, FALSE, 0);
+ g_signal_connect (G_OBJECT (entry), "activate",
+ G_CALLBACK (entry_activate_cb), dialog);
+
+ gtk_widget_show_all (main_vbox);
+
+ gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_CANCEL);
+ gtk_widget_grab_focus (entry);
+
+ g_free (title);
+ g_free (button_label);
+
+ retval = gtk_dialog_run (GTK_DIALOG (dialog));
+ gtk_widget_hide (dialog);
+
+ if (retval == 100) {
+ password = gtk_editable_get_chars (GTK_EDITABLE (entry), 0, -1);
+
+ if (!password)
+ password = "";
+ blank = g_strdup (password);
+ if (strlen (blank))
+ memset (blank, ' ', strlen (blank));
+
+ gtk_entry_set_text (GTK_ENTRY (entry), blank);
+ gtk_entry_set_text (GTK_ENTRY (entry), "");
+ g_free (blank);
+
+ if (type == 0)
+ command = g_strdup_printf ("kill -s %d %d", extra_value, pid);
+ else
+ command = g_strdup_printf ("renice %d %d", extra_value, pid);
+
+ if (su_run_with_password (command, password) == -1) {
+ error_dialog = gtk_message_dialog_new (NULL,
+ GTK_DIALOG_DESTROY_WITH_PARENT,
+ GTK_MESSAGE_ERROR,
+ GTK_BUTTONS_OK,
+ "%s",
+ _("Wrong Password."));
+ gtk_dialog_run (GTK_DIALOG (error_dialog));
+ gtk_widget_destroy (error_dialog);
+ }
+ g_free (command);
+
+ }
+ gtk_widget_destroy (dialog);
- if (type == 0)
- command = g_strdup_printf ("kill -s %d %d", extra_value, pid);
- else
- command = g_strdup_printf ("renice %d %d", extra_value, pid);
- gnomesu_exec (command);
- g_free (command);
}
--- gnome-system-monitor-2.9.90/src/util.c.libgnomesu 2005-01-08 17:43:35.000000000 -0500
+++ gnome-system-monitor-2.9.90/src/util.c 2005-02-02 15:08:57.000000000 -0500
@@ -1,10 +1,294 @@
-#include "util.h"
+#define _GNU_SOURCE
#include <config.h>
-#include <gnome.h>
-#include <stddef.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
@ -36,6 +165,9 @@
+
+#include "util.h"
+
#include <gnome.h>
-#include <stddef.h>
+/* ABORT() kills GTK if we're not root, else it just exits.
+ */
+#define ABORT(root) \
@ -291,131 +423,13 @@
+{
+ return exec_su (exec_path, "root", password);
+}
+
+#if 1
void _procman_array_gettext_init(const char * strings[], size_t n)
{
size_t i;
@@ -15,3 +297,4 @@
@@ -15,3 +299,4 @@
strings[i] = _(strings[i]);
}
}
+#endif
--- gnome-system-monitor-2.9.90/src/procdialogs.c.libgnomesu 2005-02-02 14:33:45.000000000 -0500
+++ gnome-system-monitor-2.9.90/src/procdialogs.c 2005-02-02 14:39:21.000000000 -0500
@@ -23,7 +23,6 @@
#include <signal.h>
#include <string.h>
-#include <libgnomesu/libgnomesu.h>
#include "procdialogs.h"
#include "favorites.h"
#include "proctable.h"
@@ -815,13 +814,101 @@
void procdialog_create_root_password_dialog (gint type, ProcData *procdata, gint pid,
gint extra_value, gchar *text)
{
+ GtkWidget *dialog;
+ GtkWidget *error_dialog;
+ GtkWidget *main_vbox;
+ GtkWidget *hbox;
+ GtkWidget *entry;
+ GtkWidget *label;
+ gchar *title = NULL, *button_label;
gchar *command;
+ gchar *password, *blank;
+ gint retval;
+
+ if (type == 0) {
+ if (extra_value == SIGKILL) {
+ title = g_strdup (_("Kill Process"));
+ button_label = g_strdup (_("_Kill Process"));
+ }
+ else {
+ title = g_strdup (_("End Process"));
+ button_label = g_strdup (_("_End Process"));
+ }
+ }
+ else {
+ title = g_strdup (_("Change Priority"));
+ button_label = g_strdup (_("Change _Priority"));
+ }
+
+ dialog = gtk_dialog_new_with_buttons (title, NULL, GTK_DIALOG_DESTROY_WITH_PARENT,
+ GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
+ button_label, 100,
+ NULL);
+
+ main_vbox = GTK_DIALOG (dialog)->vbox;
+
+ label = gtk_label_new (_(text));
+ gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
+ gtk_misc_set_padding (GTK_MISC (label), GNOME_PAD, 2 * GNOME_PAD);
+ gtk_box_pack_start (GTK_BOX (main_vbox), label, FALSE, FALSE, 0);
+
+ hbox = gtk_hbox_new (FALSE, 0);
+ gtk_container_set_border_width (GTK_CONTAINER (hbox), GNOME_PAD_SMALL);
+ gtk_box_pack_start (GTK_BOX (main_vbox), hbox, FALSE, FALSE, 0);
+
+ label = gtk_label_new (_("Root Password :"));
+ gtk_misc_set_padding (GTK_MISC (label), GNOME_PAD_SMALL, 0);
+ gtk_box_pack_start (GTK_BOX (hbox), label, TRUE, FALSE, 0);
+
+ entry = gtk_entry_new ();
+ gtk_entry_set_visibility (GTK_ENTRY (entry), FALSE);
+ gtk_box_pack_start (GTK_BOX (hbox), entry, TRUE, FALSE, 0);
+ g_signal_connect (G_OBJECT (entry), "activate",
+ G_CALLBACK (entry_activate_cb), dialog);
+
+ gtk_widget_show_all (main_vbox);
+
+ gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_CANCEL);
+ gtk_widget_grab_focus (entry);
+
+ g_free (title);
+ g_free (button_label);
+
+ retval = gtk_dialog_run (GTK_DIALOG (dialog));
+ gtk_widget_hide (dialog);
+
+ if (retval == 100) {
+ password = gtk_editable_get_chars (GTK_EDITABLE (entry), 0, -1);
+
+ if (!password)
+ password = "";
+ blank = g_strdup (password);
+ if (strlen (blank))
+ memset (blank, ' ', strlen (blank));
+
+ gtk_entry_set_text (GTK_ENTRY (entry), blank);
+ gtk_entry_set_text (GTK_ENTRY (entry), "");
+ g_free (blank);
+
+ if (type == 0)
+ command = g_strdup_printf ("kill -s %d %d", extra_value, pid);
+ else
+ command = g_strdup_printf ("renice %d %d", extra_value, pid);
+
+ if (su_run_with_password (command, password) == -1) {
+ error_dialog = gtk_message_dialog_new (NULL,
+ GTK_DIALOG_DESTROY_WITH_PARENT,
+ GTK_MESSAGE_ERROR,
+ GTK_BUTTONS_OK,
+ "%s",
+ _("Wrong Password."));
+ gtk_dialog_run (GTK_DIALOG (error_dialog));
+ gtk_widget_destroy (error_dialog);
+ }
+ g_free (command);
+
+ }
+ gtk_widget_destroy (dialog);
- if (type == 0)
- command = g_strdup_printf ("kill -s %d %d", extra_value, pid);
- else
- command = g_strdup_printf ("renice %d %d", extra_value, pid);
- gnomesu_exec (command);
- g_free (command);
}

View File

@ -41,6 +41,7 @@ gnome-system-monitor is a simple process and system monitor.
%build
autoconf
%configure
make %{?_smp_mflags}
@ -75,7 +76,6 @@ gconftool-2 --makefile-install-rule %{_sysconfdir}/gconf/schemas/gnome-system-mo
%{_datadir}/applications
%{_datadir}/gnome
%{_datadir}/applications
%{_datadir}/pixmaps
%{_sysconfdir}/gconf/schemas/*
%{_datadir}/omf