Commit 2ce76a9a authored by Robey Pointer's avatar Robey Pointer
Browse files

add new helper/ directory to trilobite for building eazel-helper, the sudo-ish...

add new helper/ directory to trilobite for building eazel-helper, the sudo-ish utility that lets trilobite services do stuff as root
parent d2e18259
2000-07-10 Robey Pointer <robey@eazel.com>
* components/services/trilobite/Makefile.am:
* components/services/trilobite/helper/.cvsignore:
* components/services/trilobite/helper/Makefile.am:
* components/services/trilobite/helper/README:
* components/services/trilobite/helper/eazel-helper.c:
* configure.in:
Add new helper/ directory to trilobite for building eazel-helper,
the sudo-ish utility that lets trilobite services do stuff as root.
2000-07-10 Ramiro Estrugo <ramiro@eazel.com>
* libnautilus-extensions/nautilus-graphic.c:
......
SUBDIRS = idl libtrilobite sample
SUBDIRS = helper idl libtrilobite sample
.deps
.libs
Makefile
Makefile.in
eazel-helper
NULL =
bin_PROGRAMS = eazel-helper
eazel_helper_SOURCES = \
eazel-helper.c \
$(NULL)
eazel_helper_LDADD = \
$(GLIB_LIBS) \
$(NULL)
INCLUDES = \
$(GLIB_CFLAGS) \
$(WERROR) \
$(NULL)
For eazel-helper to work, it must be installed in a well-known
location, and it needs two config files to be placed in the PAM setup
directories. Here are the files I use:
### /etc/pam.d/eazel-helper ###
#%PAM-1.0
auth sufficient /lib/security/pam_rootok.so
auth required /lib/security/pam_pwdb.so
session optional /lib/security/pam_xauth.so
account required /lib/security/pam_permit.so
### /etc/security/console.apps/eazel-helper ###
USER=root
PROGRAM=/root/eazel-helper
SESSION=true
FALLBACK=true
Obviously, PROGRAM in the latter file is where to find the actual
binary for eazel-helper. I'm not sure what SESSION and FALLBACK do; I
just copied them from helix-update. Likewise the whole pam.d file is
just a copy from helix-update. There may be better contents for these
files than my ham-handed bumbling.
The whole setup requires "userhelper" to be installed in /usr/sbin.
On Redhat, this is package "usermode-1.20-1".
Weirdly, "userhelper" doesn't seem to work remotely. Not sure what
the deal is.
-- Robey Pointer, 7 july 2000
/*
* very stupid.
*/
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <glib.h>
#define RPM_EXEC "/bin/rpm"
/* paths to search for executables (like RPM) in */
static const char *search_path[] = {
"/bin",
"/usr/bin",
"/usr/local/bin",
"/sbin",
"/usr/sbin",
"/usr/local/sbin",
NULL
};
static void
chomp (char *buffer)
{
int x = strlen (buffer);
while ((x > 0) && ((buffer[x - 1] == '\n') || (buffer[x - 1] == '\r'))) {
buffer[x - 1] = 0;
x--;
}
}
static const char *
find_path_to (const char *filename)
{
char *path;
int i;
for (i = 0; search_path[i]; i++) {
path = g_strdup_printf ("%s/%s", search_path[i], filename);
/* i guess g_file_exists() is going away, and not part of glib anyway :( */
if (access (path, X_OK) == 0) {
g_free (path);
return search_path[i];
}
g_free (path);
}
return NULL;
}
int
main (int argc, char **argv)
{
char buffer[256];
const char *path;
char *filename;
char **pargv;
int args, i;
printf ("* OK.\n");
fflush (stdout);
/* send stderr to stdout */
dup2 (1, 2);
/* get command */
fgets (buffer, 256, stdin);
if (feof (stdin)) {
/* give up */
exit (1);
}
chomp (buffer);
/* rpm <# of parameters> */
/* (followed by N lines of parameters) */
if (g_strncasecmp (buffer, "rpm ", 4) == 0) {
args = atoi (buffer + 4);
pargv = g_new0 (char *, args + 2);
path = find_path_to ("rpm");
if (! path) {
printf ("* Can't find RPM. :(\n");
exit (1);
}
filename = g_strdup_printf ("%s/%s", path, "rpm");
pargv[0] = "rpm";
for (i = 0; i < args; i++) {
fgets (buffer, 256, stdin);
chomp (buffer);
pargv[i + 1] = g_strdup (buffer);
}
pargv[args + 1] = NULL;
/* we never free any of the args, but it doesn't matter, because
* if the exec succeeds, this all suddenly vanishes. :)
*/
execv (filename, pargv);
printf ("* Can't run RPM. :(\n");
exit (1);
}
printf ("* What?\n");
exit (1);
}
......@@ -415,6 +415,7 @@ components/services/trilobite/sample/service/Makefile
components/services/trilobite/sample/command-line/Makefile
components/services/trilobite/sample/nautilus-view/Makefile
components/services/trilobite/sample/nautilus-view/icons/Makefile
components/services/trilobite/helper/Makefile
components/services/time/Makefile
components/services/time/service/Makefile
components/services/time/command-line/Makefile
......
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