mirror of
https://gitlab.gnome.org/GNOME/nautilus
synced 2024-10-06 07:50:01 +00:00
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
This commit is contained in:
parent
3f3dd3bf85
commit
c857ceecf0
25
ChangeLog
25
ChangeLog
|
@ -1,3 +1,28 @@
|
|||
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
|
||||
|
||||
2001-03-30 John Sullivan <sullivan@eazel.com>
|
||||
|
||||
reviewed by: Darin Adler <darin@eazel.com>
|
||||
|
|
|
@ -1 +1 @@
|
|||
SUBDIRS = helper idl libtrilobite sample
|
||||
SUBDIRS = helper idl libtrilobite sample utils
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
36
components/services/trilobite/utils/Makefile.am
Normal file
36
components/services/trilobite/utils/Makefile.am
Normal file
|
@ -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)
|
||||
|
||||
|
136
components/services/trilobite/utils/eazel-helper-test.c
Normal file
136
components/services/trilobite/utils/eazel-helper-test.c
Normal file
|
@ -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;
|
||||
};
|
|
@ -1067,6 +1067,7 @@ components/services/trilobite/Makefile
|
|||
components/services/trilobite/idl/Makefile
|
||||
components/services/trilobite/libtrilobite/Makefile
|
||||
components/services/trilobite/libtrilobite/makefile.staticlib
|
||||
components/services/trilobite/utils/Makefile
|
||||
components/services/trilobite/sample/Makefile
|
||||
components/services/trilobite/sample/idl/Makefile
|
||||
components/services/trilobite/sample/lib/Makefile
|
||||
|
|
Loading…
Reference in a new issue