Added `GLIBTOP_METHOD_PIPE' again.

1998-07-18  Martin Baulig  <martin@home-of-linux.org>

	* lib/{init, open}.c: Added `GLIBTOP_METHOD_PIPE' again.

	* src/server/main.c: Removed gettext stuff.
This commit is contained in:
Martin Baulig
1998-07-18 16:09:42 +00:00
committed by Martin Baulig
parent 540385da7e
commit 0e086aef25
5 changed files with 62 additions and 20 deletions

View File

@@ -1,3 +1,9 @@
1998-07-18 Martin Baulig <martin@home-of-linux.org>
* lib/{init, open}.c: Added `GLIBTOP_METHOD_PIPE' again.
* src/server/main.c: Removed gettext stuff.
1998-07-17 Martin Baulig <baulig@Stud.Informatik.uni-trier.de>
* sysdeps/common/sysdeps.c (glibtop_get_sysdeps_r): Using
@@ -11,9 +17,9 @@
* sysdeps/sun4/proclist.c (glibtop_get_proclist_p): Added
implementation of that feature.
* sysdeps/sun4/proc_{uid,state}.c: Now working quite well.
* sysdeps/sun4/proc_{uid, state}.c: Now working quite well.
* sysdeps/sun4/proc_{mem,time,signal,kernel,segment}.c: Added
* sysdeps/sun4/proc_{mem, time, signal, kernel, segment}.c: Added
some basic implementation; this isn't really working yet.
* sysdeps/linux/sem_limits.c: Applied patch from Albert K T Hui

View File

@@ -253,5 +253,6 @@ src/proxy/Makefile
src/daemon/Makefile
lib/Makefile
examples/Makefile
perl/Makefile.PL
support/Makefile
macros/Makefile],[sed -e "/POTFILES =/r po/POTFILES" po/Makefile.in > po/Makefile])

View File

@@ -136,6 +136,11 @@ _init_server (glibtop *server, const unsigned features)
/* Connect to unix domain socket. */
server->method = GLIBTOP_METHOD_UNIX;
} else if (!strcmp (command, "pipe")) {
/* Open pipe to server. */
server->method = GLIBTOP_METHOD_PIPE;
} else {
glibtop_error_r (server, "Unknown server method '%s'",

View File

@@ -33,7 +33,9 @@ void
glibtop_open_l (glibtop *server, const char *program_name,
const unsigned long features, const unsigned flags)
{
char version [BUFSIZ], buffer [BUFSIZ];
int connect_type;
unsigned nbytes;
server->name = program_name;
@@ -75,6 +77,52 @@ glibtop_open_l (glibtop *server, const char *program_name,
server->features = -1;
break;
case GLIBTOP_METHOD_PIPE:
fprintf (stderr, "Opening pipe to server (%s).\n",
GTOP_SERVER);
#if 0
if (socketpair (AF_UNIX, SOCK_STREAM, 0, server->input))
glibtop_error_io_r (server, "socketpair");
if (socketpair (AF_UNIX, SOCK_STREAM, 0, server->output))
glibtop_error_io_r (server, "socketpair");
#endif
if (pipe (server->input) || pipe (server->output))
glibtop_error_io_r (server, "cannot make a pipe");
server->pid = fork ();
if (server->pid < 0) {
glibtop_error_io_r (server, "fork failed");
} else if (server->pid == 0) {
close (0); close (1);
close (server->input [0]); close (server->output [1]);
dup2 (server->input [1], 1);
dup2 (server->output [0], 0);
execl (GTOP_SERVER, NULL);
glibtop_error_io_r (server, "execl %s", GTOP_SERVER);
_exit (2);
}
close (server->input [1]);
close (server->output [0]);
sprintf (version, "%s server %s ready.\n", PACKAGE, VERSION);
glibtop_read_l (server, sizeof (nbytes), &nbytes);
if (nbytes != strlen (version))
glibtop_error_r (server, "Requested %u bytes but got %u",
strlen (version), nbytes);
glibtop_read_l (server, nbytes, buffer);
if (memcmp (version, buffer, strlen (version)))
glibtop_error_r (server, "server version is not %s",
VERSION);
break;
}
/* If the server has been started, ask it for its features. */

View File

@@ -55,25 +55,8 @@ int main(int argc, char *argv[])
uid = getuid (); euid = geteuid ();
gid = getgid (); egid = getegid ();
if (setreuid (euid, uid)) _exit (1);
if (setregid (egid, gid)) _exit (1);
/* !!! END OF SUID ROOT PART !!! */
/* For security reasons, we temporarily drop our priviledges
* before doing the gettext stuff. */
setlocale (LC_ALL, "");
bindtextdomain (PACKAGE, GTOPLOCALEDIR);
textdomain (PACKAGE);
glibtop_version ();
/* !!! WE ARE ROOT HERE - CHANGE WITH CAUTION !!! */
setreuid (uid, euid); setregid (gid, egid);
glibtop_open_r (&server, argv [0], 0, 0);
if (setreuid (euid, uid)) _exit (1);
@@ -89,7 +72,6 @@ int main(int argc, char *argv[])
while(1) {
/* block on read from client */
/* fprintf (stderr, "waiting for input ...\n"); */
nread = read (0, &size, sizeof (size_t));
/* will return 0 if parent exits. */