Minor server/daemon cleanups; reading sysdeps from server now working.

This commit is contained in:
Martin Baulig
1998-08-08 20:04:43 +00:00
parent 9cf583b2fa
commit c0641998cf
6 changed files with 15 additions and 17 deletions

View File

@@ -1,9 +1,7 @@
LINK = $(LIBTOOL) --mode=link $(CC) $(CFLAGS) $(LDFLAGS) -o $@
CFLAGS = -Wall -W @CFLAGS@ \
-DDEBUG -DREAL_DEBUG -D_BSD \
-DPARENT_DEBUG -DSLAVE_DEBUG \
-DGLIBTOP_DAEMON_SLAVE
-D_BSD -DGLIBTOP_DAEMON_SLAVE
if NEED_LIBGTOP
suid_sysdeps = $(top_builddir)/sysdeps/@sysdeps_dir@/libgtop_sysdeps_suid.la

View File

@@ -56,6 +56,8 @@ handle_parent_connection (int s)
return;
}
memset (resp, 0, sizeof (glibtop_response));
memset (parameter, 0, sizeof (parameter));
if (cmnd->data_size) {
@@ -88,6 +90,8 @@ handle_parent_connection (int s)
#endif
return;
case GLIBTOP_CMND_SYSDEPS:
memcpy (&resp->u.sysdeps, &server->sysdeps,
sizeof (glibtop_sysdeps));
resp->u.sysdeps.features = GLIBTOP_SYSDEPS_ALL;
do_output (s, resp, _offset_union (sysdeps), 0, NULL);
break;

View File

@@ -49,14 +49,6 @@ GLIBTOP_SUID_PROC_SEGMENT;
#include <fcntl.h>
#include <locale.h>
#if defined(HAVE_GETDTABLESIZE)
#define GET_MAX_FDS() getdtablesize()
#else
/* Fallthrough case - please add other #elif cases above
for different OS's as necessary */
#define GET_MAX_FDS() 256
#endif
int
main(int argc, char *argv[])
{
@@ -69,7 +61,7 @@ main(int argc, char *argv[])
uid = getuid (); euid = geteuid ();
gid = getgid (); egid = getegid ();
glibtop_open_p (glibtop_global_server, argv [0], 0, 0);
glibtop_init_p (glibtop_global_server, 0, 0);
if (setreuid (euid, uid)) _exit (1);
@@ -77,11 +69,6 @@ main(int argc, char *argv[])
/* !!! END OF SUID ROOT PART !!! */
/* close all file descriptors except ones used by the pipes (0 and 1). */
max_fd = GET_MAX_FDS();
for(fd = 3 /* The first fd after the pipes */; fd < max_fd; fd++)
close(fd);
handle_slave_connection (0, 0);
_exit (0);

View File

@@ -43,6 +43,8 @@ handle_slave_connection (int input, int output)
"but buffer is %d",
cmnd->size, BUFSIZ);
memset (resp, 0, sizeof (glibtop_response));
memset (parameter, 0, sizeof (parameter));
if (cmnd->data_size) {
@@ -87,6 +89,10 @@ handle_slave_command (glibtop_command *cmnd, glibtop_response *resp,
switch (cmnd->command) {
case GLIBTOP_CMND_SYSDEPS:
fprintf (stderr, "SYSDEPS: %p - %lx\n",
server, server->sysdeps.cpu);
memcpy (&resp->u.sysdeps, &server->sysdeps,
sizeof (glibtop_sysdeps));
resp->u.sysdeps.features = glibtop_server_features;
resp->offset = _offset_union (sysdeps);
break;