Minor server/daemon cleanups; reading sysdeps from server now working.
This commit is contained in:
@@ -51,6 +51,7 @@ __BEGIN_DECLS
|
|||||||
|
|
||||||
extern void glibtop_open_l __P((glibtop *, const char *, const unsigned long, const unsigned));
|
extern void glibtop_open_l __P((glibtop *, const char *, const unsigned long, const unsigned));
|
||||||
|
|
||||||
|
extern void glibtop_init_p __P((glibtop *, const unsigned long, const unsigned));
|
||||||
extern void glibtop_open_p __P((glibtop *, const char *, const unsigned long, const unsigned));
|
extern void glibtop_open_p __P((glibtop *, const char *, const unsigned long, const unsigned));
|
||||||
extern void glibtop_open_s __P((glibtop *, const char *, const unsigned long, const unsigned));
|
extern void glibtop_open_s __P((glibtop *, const char *, const unsigned long, const unsigned));
|
||||||
|
|
||||||
|
@@ -176,6 +176,8 @@ glibtop_open_l (glibtop *server, const char *program_name,
|
|||||||
|
|
||||||
server->features = sysdeps.features;
|
server->features = sysdeps.features;
|
||||||
|
|
||||||
|
memcpy (&server->sysdeps, &sysdeps, sizeof (glibtop_sysdeps));
|
||||||
|
|
||||||
fprintf (stderr, "Server features are %lu.\n",
|
fprintf (stderr, "Server features are %lu.\n",
|
||||||
server->features);
|
server->features);
|
||||||
}
|
}
|
||||||
|
@@ -1,9 +1,7 @@
|
|||||||
LINK = $(LIBTOOL) --mode=link $(CC) $(CFLAGS) $(LDFLAGS) -o $@
|
LINK = $(LIBTOOL) --mode=link $(CC) $(CFLAGS) $(LDFLAGS) -o $@
|
||||||
|
|
||||||
CFLAGS = -Wall -W @CFLAGS@ \
|
CFLAGS = -Wall -W @CFLAGS@ \
|
||||||
-DDEBUG -DREAL_DEBUG -D_BSD \
|
-D_BSD -DGLIBTOP_DAEMON_SLAVE
|
||||||
-DPARENT_DEBUG -DSLAVE_DEBUG \
|
|
||||||
-DGLIBTOP_DAEMON_SLAVE
|
|
||||||
|
|
||||||
if NEED_LIBGTOP
|
if NEED_LIBGTOP
|
||||||
suid_sysdeps = $(top_builddir)/sysdeps/@sysdeps_dir@/libgtop_sysdeps_suid.la
|
suid_sysdeps = $(top_builddir)/sysdeps/@sysdeps_dir@/libgtop_sysdeps_suid.la
|
||||||
|
@@ -56,6 +56,8 @@ handle_parent_connection (int s)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
memset (resp, 0, sizeof (glibtop_response));
|
||||||
|
|
||||||
memset (parameter, 0, sizeof (parameter));
|
memset (parameter, 0, sizeof (parameter));
|
||||||
|
|
||||||
if (cmnd->data_size) {
|
if (cmnd->data_size) {
|
||||||
@@ -88,6 +90,8 @@ handle_parent_connection (int s)
|
|||||||
#endif
|
#endif
|
||||||
return;
|
return;
|
||||||
case GLIBTOP_CMND_SYSDEPS:
|
case GLIBTOP_CMND_SYSDEPS:
|
||||||
|
memcpy (&resp->u.sysdeps, &server->sysdeps,
|
||||||
|
sizeof (glibtop_sysdeps));
|
||||||
resp->u.sysdeps.features = GLIBTOP_SYSDEPS_ALL;
|
resp->u.sysdeps.features = GLIBTOP_SYSDEPS_ALL;
|
||||||
do_output (s, resp, _offset_union (sysdeps), 0, NULL);
|
do_output (s, resp, _offset_union (sysdeps), 0, NULL);
|
||||||
break;
|
break;
|
||||||
|
@@ -49,14 +49,6 @@ GLIBTOP_SUID_PROC_SEGMENT;
|
|||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <locale.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
|
int
|
||||||
main(int argc, char *argv[])
|
main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
@@ -69,7 +61,7 @@ main(int argc, char *argv[])
|
|||||||
uid = getuid (); euid = geteuid ();
|
uid = getuid (); euid = geteuid ();
|
||||||
gid = getgid (); egid = getegid ();
|
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);
|
if (setreuid (euid, uid)) _exit (1);
|
||||||
|
|
||||||
@@ -77,11 +69,6 @@ main(int argc, char *argv[])
|
|||||||
|
|
||||||
/* !!! END OF SUID ROOT PART !!! */
|
/* !!! 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);
|
handle_slave_connection (0, 0);
|
||||||
|
|
||||||
_exit (0);
|
_exit (0);
|
||||||
|
@@ -43,6 +43,8 @@ handle_slave_connection (int input, int output)
|
|||||||
"but buffer is %d",
|
"but buffer is %d",
|
||||||
cmnd->size, BUFSIZ);
|
cmnd->size, BUFSIZ);
|
||||||
|
|
||||||
|
memset (resp, 0, sizeof (glibtop_response));
|
||||||
|
|
||||||
memset (parameter, 0, sizeof (parameter));
|
memset (parameter, 0, sizeof (parameter));
|
||||||
|
|
||||||
if (cmnd->data_size) {
|
if (cmnd->data_size) {
|
||||||
@@ -87,6 +89,10 @@ handle_slave_command (glibtop_command *cmnd, glibtop_response *resp,
|
|||||||
|
|
||||||
switch (cmnd->command) {
|
switch (cmnd->command) {
|
||||||
case GLIBTOP_CMND_SYSDEPS:
|
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->u.sysdeps.features = glibtop_server_features;
|
||||||
resp->offset = _offset_union (sysdeps);
|
resp->offset = _offset_union (sysdeps);
|
||||||
break;
|
break;
|
||||||
|
Reference in New Issue
Block a user