summaryrefslogtreecommitdiff
path: root/components
diff options
context:
space:
mode:
authorEskil Heyn Olsen <eskil@eazel.com>2001-03-30 21:01:59 +0000
committerEskil Heyn Olsen <eskil@src.gnome.org>2001-03-30 21:01:59 +0000
commitc857ceecf00cf666bd3d050c72a42ee8f1481f59 (patch)
tree6aa84d982b742525f6f5fb7e32c1c3714783161d /components
parent3f3dd3bf8515a7ac72a9d318363f362a27763555 (diff)
downloadnautilus-c857ceecf00cf666bd3d050c72a42ee8f1481f59.tar.gz
reviewed by: the toad that lives under my table
2001-03-30 Eskil Heyn Olsen <eskil@eazel.com> reviewed by: the toad that lives under my table * components/services/trilobite/Makefile.am: Build utils/ * components/services/trilobite/helper/eazel-helper.c: (main): Added ability to launch a start-medusa script. * components/services/trilobite/libtrilobite/trilobite-root-helper. h: * components/services/trilobite/libtrilobite/trilobite-root-helper. c: (trilobite_root_helper_run): Added a enum for a start-medusa command. * components/services/trilobite/utils/Makefile.am: * components/services/trilobite/utils/eazel-helper-test.c: (get_password_dude), (main): Added a program to test root helper, for educational reasons mostly. * configure.in: Added components/services/trilobite/utils/Makefile
Diffstat (limited to 'components')
-rw-r--r--components/services/trilobite/Makefile.am2
-rw-r--r--components/services/trilobite/helper/eazel-helper.c4
-rw-r--r--components/services/trilobite/libtrilobite/trilobite-root-helper.c5
-rw-r--r--components/services/trilobite/libtrilobite/trilobite-root-helper.h3
-rw-r--r--components/services/trilobite/utils/Makefile.am36
-rw-r--r--components/services/trilobite/utils/eazel-helper-test.c136
6 files changed, 183 insertions, 3 deletions
diff --git a/components/services/trilobite/Makefile.am b/components/services/trilobite/Makefile.am
index 9dbd0db73..ad496750f 100644
--- a/components/services/trilobite/Makefile.am
+++ b/components/services/trilobite/Makefile.am
@@ -1 +1 @@
-SUBDIRS = helper idl libtrilobite sample
+SUBDIRS = helper idl libtrilobite sample utils
diff --git a/components/services/trilobite/helper/eazel-helper.c b/components/services/trilobite/helper/eazel-helper.c
index ad9400420..66289c7be 100644
--- a/components/services/trilobite/helper/eazel-helper.c
+++ b/components/services/trilobite/helper/eazel-helper.c
@@ -161,6 +161,10 @@ main (int argc, char **argv)
do_command ("ls", args);
}
+ if (g_strncasecmp (buffer, "start-medusa", 12) == 0) {
+ do_command ("start-medusa", 0);
+ }
+
printf ("* What?\n");
exit (1);
}
diff --git a/components/services/trilobite/libtrilobite/trilobite-root-helper.c b/components/services/trilobite/libtrilobite/trilobite-root-helper.c
index adb54a046..c262db2eb 100644
--- a/components/services/trilobite/libtrilobite/trilobite-root-helper.c
+++ b/components/services/trilobite/libtrilobite/trilobite-root-helper.c
@@ -588,13 +588,16 @@ TrilobiteRootHelperStatus
trilobite_root_helper_run (TrilobiteRootHelper *root_helper, TrilobiteRootHelperCommand command, GList *argv, int *fd)
{
g_return_val_if_fail (root_helper != NULL, TRILOBITE_ROOT_HELPER_BAD_ARGS);
- g_return_val_if_fail (argv != NULL, TRILOBITE_ROOT_HELPER_BAD_ARGS);
+ /* g_return_val_if_fail (argv != NULL, TRILOBITE_ROOT_HELPER_BAD_ARGS); */
g_return_val_if_fail (TRILOBITE_IS_ROOT_HELPER (root_helper), TRILOBITE_ROOT_HELPER_BAD_ARGS);
g_return_val_if_fail (TRILOBITE_ROOT_HELPER_IS_CONNECTED (root_helper), TRILOBITE_ROOT_HELPER_BAD_ARGS);
switch (command) {
case TRILOBITE_ROOT_HELPER_RUN_RPM:
return trilobite_root_helper_run_program (root_helper, "rpm", argv, fd);
+ case TRILOBITE_ROOT_HELPER_RUN_START_MEDUSA:
+ return trilobite_root_helper_run_program (root_helper, "start-medusa",
+ NULL, fd);
case TRILOBITE_ROOT_HELPER_RUN_SET_TIME:
return trilobite_root_helper_set_time (root_helper, argv, fd);
case TRILOBITE_ROOT_HELPER_RUN_LS:
diff --git a/components/services/trilobite/libtrilobite/trilobite-root-helper.h b/components/services/trilobite/libtrilobite/trilobite-root-helper.h
index 9f3aa13a7..ffd0b523f 100644
--- a/components/services/trilobite/libtrilobite/trilobite-root-helper.h
+++ b/components/services/trilobite/libtrilobite/trilobite-root-helper.h
@@ -64,7 +64,8 @@ typedef enum {
/* commands that can be sent to the root helper, once it's running */
typedef enum {
TRILOBITE_ROOT_HELPER_RUN_RPM = 1, /* argv: args to rpm -- fd: pipe from rpm */
- TRILOBITE_ROOT_HELPER_RUN_SET_TIME, /* argv: list of 1 string containing a time_t -- fd: unused */
+ TRILOBITE_ROOT_HELPER_RUN_SET_TIME = 2, /* argv: list of 1 string containing a time_t -- fd: unused */
+ TRILOBITE_ROOT_HELPER_RUN_START_MEDUSA = 3, /* No args */
TRILOBITE_ROOT_HELPER_RUN_LS = 23 /* argv: args to ls -- fd: pipe from ls [DEMO] */
} TrilobiteRootHelperCommand;
diff --git a/components/services/trilobite/utils/Makefile.am b/components/services/trilobite/utils/Makefile.am
new file mode 100644
index 000000000..f05be4812
--- /dev/null
+++ b/components/services/trilobite/utils/Makefile.am
@@ -0,0 +1,36 @@
+include $(top_srcdir)/Makefile.shared
+
+INCLUDES = \
+ -DPREFIX=\"$(prefix)\" \
+ -DG_LOG_DOMAIN=\"EazelHelperTest\" \
+ -I$(top_srcdir) \
+ -I$(top_builddir) \
+ -I$(top_srcdir)/components/services/trilobite/libtrilobite \
+ -I$(top_builddir)/components/services/trilobite/libtrilobite \
+ -I$(top_srcdir)/components/services/trilobite \
+ -I$(top_builddir)/components/services/trilobite \
+ -DGNOMELOCALEDIR=\""$(datadir)/locale"\" \
+ $(GNOME_CFLAGS) \
+ $(GCONF_CFLAGS) \
+ $(VFS_CFLAGS) \
+ $(XML_CFLAGS) \
+ $(GHTTP_CFLAGS) \
+ $(NULL)
+
+LDADD = \
+ $(top_builddir)/components/services/trilobite/libtrilobite/libtrilobite.la \
+ $(BONOBO_LIBS) \
+ $(GNOME_LIBS) \
+ $(GCONF_LIBS) \
+ $(VFS_LIBS) \
+ $(GHTTP_LIBS) \
+ $(RPM_LIBS) \
+ $(NULL)
+
+bin_PROGRAMS = eazel-helper-test
+
+eazel_helper_test_SOURCES = \
+ eazel-helper-test.c \
+ $(NULL)
+
+
diff --git a/components/services/trilobite/utils/eazel-helper-test.c b/components/services/trilobite/utils/eazel-helper-test.c
new file mode 100644
index 000000000..3903b6367
--- /dev/null
+++ b/components/services/trilobite/utils/eazel-helper-test.c
@@ -0,0 +1,136 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
+/*
+ * Copyright (C) 2001 Eazel, Inc
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ *
+ * Authors: Eskil Heyn Olsen <eskil@eazel.com>
+ *
+ */
+
+#include <config.h>
+#include <gnome.h>
+#include <liboaf/liboaf.h>
+#include <bonobo.h>
+
+#include <libtrilobite/libtrilobite.h>
+#include <unistd.h>
+
+CORBA_ORB orb;
+CORBA_Environment ev;
+int cli_result = 0;
+
+/* Popt stuff */
+int arg_command = 0;
+
+static const struct poptOption options[] = {
+ {"command", '\0', POPT_ARG_INT, &arg_command, 0, N_("Command to run"), NULL},
+ {NULL, '\0', 0, NULL, 0}
+};
+
+static char *
+get_password_dude (TrilobiteRootHelper *helper, const char *prompt, void *user_data)
+{
+ char * passwd;
+
+ passwd = getpass ("root password: ");
+ return g_strdup (passwd);
+}
+
+int main(int argc, char *argv[]) {
+ poptContext ctxt;
+ TrilobiteRootHelper *helper;
+ int fd;
+ GList *args = NULL;
+ char *str;
+
+ CORBA_exception_init (&ev);
+
+ /* Seems that bonobo_main doens't like
+ not having gnome_init called, dies in a
+ X call, yech */
+
+#ifdef ENABLE_NLS /* sadly we need this ifdef because otherwise the following get empty statement warnings */
+ bindtextdomain (PACKAGE, GNOMELOCALEDIR);
+ textdomain (PACKAGE);
+#endif
+
+ trilobite_init ("Eazel Root Helper Test", "1.0", NULL, options, argc, argv);
+ ctxt = trilobite_get_popt_context ();
+
+ helper = trilobite_root_helper_new ();
+
+ while ((str = poptGetArg (ctxt)) != NULL) {
+ args = g_list_prepend (args, str);
+ }
+
+ bonobo_activate ();
+
+ gtk_signal_connect (GTK_OBJECT (helper),
+ "need_password",
+ GTK_SIGNAL_FUNC (get_password_dude),
+ NULL);
+
+ g_message ("Calling start");
+ if (trilobite_root_helper_start (helper) == 0) {
+ TrilobiteRootHelperStatus res;
+
+ g_message ("Calling run");
+ res = trilobite_root_helper_run (helper, arg_command, args, &fd);
+
+ switch (res) {
+ case TRILOBITE_ROOT_HELPER_SUCCESS:
+ if (fd>0) {
+ char b;
+ while (read (fd, &b, 1)) {
+ putchar (b);
+ }
+ } else {
+ g_warning ("success, but no fd");
+ }
+ break;
+ case TRILOBITE_ROOT_HELPER_NO_USERHELPER:
+ g_error ("No userhelper");
+ break;
+ case TRILOBITE_ROOT_HELPER_NEED_PASSWORD:
+ g_error ("Need password");
+ break;
+ case TRILOBITE_ROOT_HELPER_BAD_PASSWORD:
+ g_error ("Bad password, try again...");
+ break;
+ case TRILOBITE_ROOT_HELPER_LOST_PIPE:
+ g_error ("Lost pipe");
+ break;
+ case TRILOBITE_ROOT_HELPER_BAD_ARGS:
+ g_error ("Bad args");
+ break;
+ case TRILOBITE_ROOT_HELPER_BAD_COMMAND:
+ g_error ("Bad command");
+ break;
+ case TRILOBITE_ROOT_HELPER_INTERNAL_ERROR:
+ g_error ("Internal error");
+ break;
+ }
+ } else {
+ g_error ("Cannot start root helper");
+ }
+
+
+ /* Corba cleanup */
+ CORBA_exception_free (&ev);
+
+ return cli_result;
+};