summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Baulig <martin@home-of-linux.org>1998-07-18 16:09:42 +0000
committerMartin Baulig <martin@src.gnome.org>1998-07-18 16:09:42 +0000
commit0e086aef2513d7263ba21f6835f74945fa9915e2 (patch)
treef49e387677074a37235fb1716ba8827564a5f38a
parent540385da7e909b0f05b141508e148b2abc3f638a (diff)
downloadlibgtop-0e086aef2513d7263ba21f6835f74945fa9915e2.tar.gz
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.
-rw-r--r--ChangeLog10
-rw-r--r--configure.in1
-rw-r--r--lib/init.c5
-rw-r--r--lib/open.c48
-rw-r--r--src/server/main.c18
5 files changed, 62 insertions, 20 deletions
diff --git a/ChangeLog b/ChangeLog
index 21200173..bc724f56 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -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
diff --git a/configure.in b/configure.in
index 9c70dbac..1e426ed1 100644
--- a/configure.in
+++ b/configure.in
@@ -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])
diff --git a/lib/init.c b/lib/init.c
index 367d5e14..71b6b71a 100644
--- a/lib/init.c
+++ b/lib/init.c
@@ -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'",
diff --git a/lib/open.c b/lib/open.c
index 7bf1126b..fe90bfff 100644
--- a/lib/open.c
+++ b/lib/open.c
@@ -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. */
diff --git a/src/server/main.c b/src/server/main.c
index a248c862..3aa7ca70 100644
--- a/src/server/main.c
+++ b/src/server/main.c
@@ -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. */