From d72da1bb2ff3a4eb7a8f3dcca2118756f6b961b5 Mon Sep 17 00:00:00 2001 From: Martin Baulig Date: Fri, 7 Aug 1998 12:35:20 +0000 Subject: [PATCH] New directory. This is mainly used as example for people porting libgtop 1998-08-07 Martin Baulig * sysdeps/stub_suid: New directory. This is mainly used as example for people porting libgtop to other systems. --- ChangeLog | 3 + sysdeps/stub_suid/.cvsignore | 25 ++++ sysdeps/stub_suid/Makefile.am | 15 +++ sysdeps/stub_suid/close.c | 28 +++++ sysdeps/stub_suid/cpu.c | 46 +++++++ sysdeps/stub_suid/glibtop_machine.h | 37 ++++++ sysdeps/stub_suid/glibtop_server.h | 46 +++++++ sysdeps/stub_suid/glibtop_suid.h | 42 +++++++ sysdeps/stub_suid/init.c | 43 +++++++ sysdeps/stub_suid/loadavg.c | 46 +++++++ sysdeps/stub_suid/mem.c | 46 +++++++ sysdeps/stub_suid/msg_limits.c | 46 +++++++ sysdeps/stub_suid/nosuid.c | 32 +++++ sysdeps/stub_suid/open.c | 75 ++++++++++++ sysdeps/stub_suid/procdata.c | 178 ++++++++++++++++++++++++++++ sysdeps/stub_suid/prockernel.c | 47 ++++++++ sysdeps/stub_suid/proclist.c | 46 +++++++ sysdeps/stub_suid/procmem.c | 47 ++++++++ sysdeps/stub_suid/procsegment.c | 47 ++++++++ sysdeps/stub_suid/procsignal.c | 47 ++++++++ sysdeps/stub_suid/procstate.c | 47 ++++++++ sysdeps/stub_suid/proctime.c | 47 ++++++++ sysdeps/stub_suid/procuid.c | 47 ++++++++ sysdeps/stub_suid/sem_limits.c | 46 +++++++ sysdeps/stub_suid/shm_limits.c | 46 +++++++ sysdeps/stub_suid/siglist.c | 26 ++++ sysdeps/stub_suid/swap.c | 46 +++++++ sysdeps/stub_suid/uptime.c | 46 +++++++ 28 files changed, 1293 insertions(+) create mode 100644 sysdeps/stub_suid/.cvsignore create mode 100644 sysdeps/stub_suid/Makefile.am create mode 100644 sysdeps/stub_suid/close.c create mode 100644 sysdeps/stub_suid/cpu.c create mode 100644 sysdeps/stub_suid/glibtop_machine.h create mode 100644 sysdeps/stub_suid/glibtop_server.h create mode 100644 sysdeps/stub_suid/glibtop_suid.h create mode 100644 sysdeps/stub_suid/init.c create mode 100644 sysdeps/stub_suid/loadavg.c create mode 100644 sysdeps/stub_suid/mem.c create mode 100644 sysdeps/stub_suid/msg_limits.c create mode 100644 sysdeps/stub_suid/nosuid.c create mode 100644 sysdeps/stub_suid/open.c create mode 100644 sysdeps/stub_suid/procdata.c create mode 100644 sysdeps/stub_suid/prockernel.c create mode 100644 sysdeps/stub_suid/proclist.c create mode 100644 sysdeps/stub_suid/procmem.c create mode 100644 sysdeps/stub_suid/procsegment.c create mode 100644 sysdeps/stub_suid/procsignal.c create mode 100644 sysdeps/stub_suid/procstate.c create mode 100644 sysdeps/stub_suid/proctime.c create mode 100644 sysdeps/stub_suid/procuid.c create mode 100644 sysdeps/stub_suid/sem_limits.c create mode 100644 sysdeps/stub_suid/shm_limits.c create mode 100644 sysdeps/stub_suid/siglist.c create mode 100644 sysdeps/stub_suid/swap.c create mode 100644 sysdeps/stub_suid/uptime.c diff --git a/ChangeLog b/ChangeLog index 7d386c9d..c6a66266 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,8 @@ 1998-08-07 Martin Baulig + * sysdeps/stub_suid: New directory. This is mainly used as example + for people porting libgtop to other systems. + * glibtop.h (_glibtop): New fields `error_method', `sysdeps' and `required'. I added an improved error handling: the client can tell the libraries which fields are absolutely required for each features diff --git a/sysdeps/stub_suid/.cvsignore b/sysdeps/stub_suid/.cvsignore new file mode 100644 index 00000000..259351e1 --- /dev/null +++ b/sysdeps/stub_suid/.cvsignore @@ -0,0 +1,25 @@ +.deps +.libs +Makefile +Makefile.in +close.lo +cpu.lo +init.lo +libgtop_sysdeps.la +loadavg.lo +mem.lo +msg_limits.lo +open.lo +prockernel.lo +proclist.lo +procmem.lo +procsegment.lo +procsignal.lo +procstate.lo +proctime.lo +procuid.lo +sem_limits.lo +shm_limits.lo +swap.lo +sysdeps.lo +uptime.lo diff --git a/sysdeps/stub_suid/Makefile.am b/sysdeps/stub_suid/Makefile.am new file mode 100644 index 00000000..046ec1bd --- /dev/null +++ b/sysdeps/stub_suid/Makefile.am @@ -0,0 +1,15 @@ +LINK = $(LIBTOOL) --mode=link $(CC) $(CFLAGS) $(LDFLAGS) -o $@ + +CFLAGS = -Wall -W @CFLAGS@ + +lib_LTLIBRARIES = libgtop_sysdeps.la libgtop_sysdeps_suid.la + +libgtop_sysdeps_la_SOURCES = nosuid.c siglist.c + +libgtop_sysdeps_suid_la_SOURCES = open.c close.c siglist.c cpu.c mem.c swap.c \ + uptime.c loadavg.c shm_limits.c msg_limits.c \ + sem_limits.c proclist.c procstate.c procuid.c \ + proctime.c procmem.c procsignal.c prockernel.c \ + procsegment.c + +include_HEADERS = glibtop_server.h glibtop_machine.h diff --git a/sysdeps/stub_suid/close.c b/sysdeps/stub_suid/close.c new file mode 100644 index 00000000..9506f275 --- /dev/null +++ b/sysdeps/stub_suid/close.c @@ -0,0 +1,28 @@ +/* $Id$ */ + +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Martin Baulig , April 1998. + + The Gnome Top Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. + + The Gnome Top Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#include + +/* Closes pipe to gtop server. */ + +void +glibtop_close_s (glibtop *server) +{ } diff --git a/sysdeps/stub_suid/cpu.c b/sysdeps/stub_suid/cpu.c new file mode 100644 index 00000000..25bb8c14 --- /dev/null +++ b/sysdeps/stub_suid/cpu.c @@ -0,0 +1,46 @@ +/* $Id$ */ + +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Martin Baulig , April 1998. + + The Gnome Top Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. + + The Gnome Top Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#include +#include +#include + +#include + +static const unsigned long _glibtop_sysdeps_cpu = 0; + +/* Init function. */ + +void +glibtop_init_cpu_p (glibtop *server) +{ + server->sysdeps.cpu = _glibtop_sysdeps_cpu; +} + +/* Provides information about cpu usage. */ + +void +glibtop_get_cpu_p (glibtop *server, glibtop_cpu *buf) +{ + glibtop_init_p (server, GLIBTOP_SYSDEPS_CPU, 0); + + memset (buf, 0, sizeof (glibtop_cpu)); +} diff --git a/sysdeps/stub_suid/glibtop_machine.h b/sysdeps/stub_suid/glibtop_machine.h new file mode 100644 index 00000000..f32bc787 --- /dev/null +++ b/sysdeps/stub_suid/glibtop_machine.h @@ -0,0 +1,37 @@ +/* $Id$ */ + +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Martin Baulig , April 1998. + + The Gnome Top Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. + + The Gnome Top Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#ifndef __GLIBTOP_MACHINE_H__ +#define __GLIBTOP_MACHINE_H__ + +__BEGIN_DECLS + +typedef struct _glibtop_machine glibtop_machine; + +struct _glibtop_machine +{ + uid_t uid, euid; /* Real and effective user id */ + gid_t gid, egid; /* Real and effective group id */ +}; + +__END_DECLS + +#endif diff --git a/sysdeps/stub_suid/glibtop_server.h b/sysdeps/stub_suid/glibtop_server.h new file mode 100644 index 00000000..4b37edfc --- /dev/null +++ b/sysdeps/stub_suid/glibtop_server.h @@ -0,0 +1,46 @@ +/* $Id$ */ + +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Martin Baulig , April 1998. + + The Gnome Top Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. + + The Gnome Top Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#ifndef __GLIBTOP_SERVER_H__ +#define __GLIBTOP_SERVER_H__ + +__BEGIN_DECLS + +#define GLIBTOP_SUID_CPU (1 << GLIBTOP_SYSDEPS_CPU) +#define GLIBTOP_SUID_MEM (1 << GLIBTOP_SYSDEPS_MEM) +#define GLIBTOP_SUID_SWAP (1 << GLIBTOP_SYSDEPS_SWAP) +#define GLIBTOP_SUID_UPTIME (1 << GLIBTOP_SYSDEPS_UPTIME) +#define GLIBTOP_SUID_LOADAVG (1 << GLIBTOP_SYSDEPS_LOADAVG) +#define GLIBTOP_SUID_SHM_LIMITS (1 << GLIBTOP_SYSDEPS_SHM_LIMITS) +#define GLIBTOP_SUID_MSG_LIMITS (1 << GLIBTOP_SYSDEPS_MSG_LIMITS) +#define GLIBTOP_SUID_SEM_LIMITS (1 << GLIBTOP_SYSDEPS_SEM_LIMITS) +#define GLIBTOP_SUID_PROCLIST (1 << GLIBTOP_SYSDEPS_PROCLIST) +#define GLIBTOP_SUID_PROC_STATE (1 << GLIBTOP_SYSDEPS_PROC_STATE) +#define GLIBTOP_SUID_PROC_UID (1 << GLIBTOP_SYSDEPS_PROC_UID) +#define GLIBTOP_SUID_PROC_MEM (1 << GLIBTOP_SYSDEPS_PROC_MEM) +#define GLIBTOP_SUID_PROC_TIME (1 << GLIBTOP_SYSDEPS_PROC_TIME) +#define GLIBTOP_SUID_PROC_SIGNAL (1 << GLIBTOP_SYSDEPS_PROC_SIGNAL) +#define GLIBTOP_SUID_PROC_KERNEL (1 << GLIBTOP_SYSDEPS_PROC_KERNEL) +#define GLIBTOP_SUID_PROC_SEGMENT (1 << GLIBTOP_SYSDEPS_PROC_SEGMENT) + +__END_DECLS + +#endif diff --git a/sysdeps/stub_suid/glibtop_suid.h b/sysdeps/stub_suid/glibtop_suid.h new file mode 100644 index 00000000..349d8f2a --- /dev/null +++ b/sysdeps/stub_suid/glibtop_suid.h @@ -0,0 +1,42 @@ +/* $Id$ */ + +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Martin Baulig , April 1998. + + The Gnome Top Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. + + The Gnome Top Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#ifndef __GLIBTOP_SUID_H__ +#define __GLIBTOP_SUID_H__ + +__BEGIN_DECLS + +static inline void glibtop_suid_enter (glibtop *server) { + setreuid (server->machine.uid, server->machine.euid); +}; + +static inline void glibtop_suid_leave (glibtop *server) { + if (setreuid (server->machine.euid, server->machine.uid)) + _exit (1); +}; + +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)); + +__END_DECLS + +#endif diff --git a/sysdeps/stub_suid/init.c b/sysdeps/stub_suid/init.c new file mode 100644 index 00000000..0fb589f6 --- /dev/null +++ b/sysdeps/stub_suid/init.c @@ -0,0 +1,43 @@ +/* $Id$ */ + +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Joshua Sled , July 1998. + + The Gnome Top Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. + + The Gnome Top Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#include +#include + +static glibtop _glibtop_global_server; +glibtop *glibtop_global_server = NULL; + +glibtop * +glibtop_init_r (glibtop **server, + const unsigned long features, + const unsigned flags) +{ + if (*server != NULL) + return *server; + + if (glibtop_global_server == NULL) { + glibtop_global_server = &_glibtop_global_server; + glibtop_open (glibtop_global_server, "glibtop", + features, flags); + } + + return *server = glibtop_global_server; +} diff --git a/sysdeps/stub_suid/loadavg.c b/sysdeps/stub_suid/loadavg.c new file mode 100644 index 00000000..733e263b --- /dev/null +++ b/sysdeps/stub_suid/loadavg.c @@ -0,0 +1,46 @@ +/* $Id$ */ + +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Martin Baulig , April 1998. + + The Gnome Top Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. + + The Gnome Top Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#include +#include +#include + +#include + +static const unsigned long _glibtop_sysdeps_loadavg = 0; + +/* Init function. */ + +void +glibtop_init_loadavg_p (glibtop *server) +{ + server->sysdeps.loadavg = _glibtop_sysdeps_loadavg; +} + +/* Provides load averange. */ + +void +glibtop_get_loadavg_p (glibtop *server, glibtop_loadavg *buf) +{ + glibtop_init_p (server, GLIBTOP_SYSDEPS_LOADAVG, 0); + + memset (buf, 0, sizeof (glibtop_loadavg)); +} diff --git a/sysdeps/stub_suid/mem.c b/sysdeps/stub_suid/mem.c new file mode 100644 index 00000000..f379f451 --- /dev/null +++ b/sysdeps/stub_suid/mem.c @@ -0,0 +1,46 @@ +/* $Id$ */ + +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Martin Baulig , April 1998. + + The Gnome Top Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. + + The Gnome Top Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#include +#include +#include + +#include + +static const unsigned long _glibtop_sysdeps_mem = 0; + +/* Init function. */ + +void +glibtop_init_mem_p (glibtop *server) +{ + server->sysdeps.mem = _glibtop_sysdeps_mem; +} + +/* Provides information about memory usage. */ + +void +glibtop_get_mem_p (glibtop *server, glibtop_mem *buf) +{ + glibtop_init_p (server, GLIBTOP_SYSDEPS_MEM, 0); + + memset (buf, 0, sizeof (glibtop_mem)); +} diff --git a/sysdeps/stub_suid/msg_limits.c b/sysdeps/stub_suid/msg_limits.c new file mode 100644 index 00000000..ea1417f2 --- /dev/null +++ b/sysdeps/stub_suid/msg_limits.c @@ -0,0 +1,46 @@ +/* $Id$ */ + +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Martin Baulig , April 1998. + + The Gnome Top Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. + + The Gnome Top Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#include +#include +#include + +#include + +static const unsigned long _glibtop_sysdeps_msg_limits = 0; + +/* Init function. */ + +void +glibtop_init_msg_limits_p (glibtop *server) +{ + server->sysdeps.msg_limits = _glibtop_sysdeps_msg_limits; +} + +/* Provides information about sysv ipc limits. */ + +void +glibtop_get_msg_limits_p (glibtop *server, glibtop_msg_limits *buf) +{ + glibtop_init_p (server, GLIBTOP_SYSDEPS_MSG_LIMITS, 0); + + memset (buf, 0, sizeof (glibtop_msg_limits)); +} diff --git a/sysdeps/stub_suid/nosuid.c b/sysdeps/stub_suid/nosuid.c new file mode 100644 index 00000000..e43e5c9f --- /dev/null +++ b/sysdeps/stub_suid/nosuid.c @@ -0,0 +1,32 @@ +/* $Id$ */ + +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Martin Baulig , April 1998. + + The Gnome Top Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. + + The Gnome Top Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#include +#include + +void +glibtop_open_s (glibtop *server, const char *program_name, + const unsigned long features, const unsigned flags) +{ } + +void +glibtop_close_s (glibtop *server) +{ } diff --git a/sysdeps/stub_suid/open.c b/sysdeps/stub_suid/open.c new file mode 100644 index 00000000..0e755905 --- /dev/null +++ b/sysdeps/stub_suid/open.c @@ -0,0 +1,75 @@ +/* $Id$ */ + +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Martin Baulig , April 1998. + + The Gnome Top Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. + + The Gnome Top Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#include +#include +#include + +/* !!! THIS FUNCTION RUNS SUID ROOT - CHANGE WITH CAUTION !!! */ + +void +glibtop_init_p (glibtop *server, const unsigned long features, + const unsigned flags) +{ + glibtop_init_func_t *init_fkt; + + if (server == NULL) + glibtop_error_r (NULL, "glibtop_init_p (server == NULL)"); + + /* Do the initialization, but only if not already initialized. */ + + if ((server->flags & _GLIBTOP_INIT_STATE_INIT) == 0) { + glibtop_open_p (server, "glibtop", features, flags); + + for (init_fkt = _glibtop_init_hook_p; *init_fkt; init_fkt++) + (*init_fkt) (server); + + server->flags |= _GLIBTOP_INIT_STATE_INIT; + } +} + +void +glibtop_open_p (glibtop *server, const char *program_name, + const unsigned long features, const unsigned flags) +{ + /* !!! WE ARE ROOT HERE - CHANGE WITH CAUTION !!! */ + + server->name = program_name; + + server->machine.uid = getuid (); + server->machine.euid = geteuid (); + server->machine.gid = getgid (); + server->machine.egid = getegid (); + + /* Drop priviledges. */ + + if (setreuid (server->machine.euid, server->machine.uid)) + _exit (1); + + if (setregid (server->machine.egid, server->machine.gid)) + _exit (1); + + /* !!! END OF SUID ROOT PART !!! */ + + /* Our effective uid is now those of the user invoking the server, + * so we do no longer have any priviledges. */ +} + diff --git a/sysdeps/stub_suid/procdata.c b/sysdeps/stub_suid/procdata.c new file mode 100644 index 00000000..71bed10b --- /dev/null +++ b/sysdeps/stub_suid/procdata.c @@ -0,0 +1,178 @@ +/* $Id$ */ + +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Joshua Sled , July 1998. + + The Gnome Top Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. + + The Gnome Top Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#include +#include + +#include + +#define LINUX_VERSION(x,y,z) (0x10000*(x) + 0x100*(y) + z) + +#define BIT_SHIFT(x) (1 << (x % 32)) + +static const unsigned long _glibtop_sysdeps_procdata_0 = +BIT_SHIFT(GLIBTOP_PROCDATA_CMD) + +BIT_SHIFT(GLIBTOP_PROCDATA_STATE) + +BIT_SHIFT(GLIBTOP_PROCDATA_UID) + +BIT_SHIFT(GLIBTOP_PROCDATA_PID) + +BIT_SHIFT(GLIBTOP_PROCDATA_PPID) + +BIT_SHIFT(GLIBTOP_PROCDATA_PGRP) + +BIT_SHIFT(GLIBTOP_PROCDATA_SESSION) + +BIT_SHIFT(GLIBTOP_PROCDATA_TTY) + +BIT_SHIFT(GLIBTOP_PROCDATA_TPGID) + +BIT_SHIFT(GLIBTOP_PROCDATA_PRIORITY) + +BIT_SHIFT(GLIBTOP_PROCDATA_NICE) + +BIT_SHIFT(GLIBTOP_PROCDATA_SIGNAL) + +BIT_SHIFT(GLIBTOP_PROCDATA_BLOCKED) + +BIT_SHIFT(GLIBTOP_PROCDATA_SIGIGNORE) + +BIT_SHIFT(GLIBTOP_PROCDATA_SIGCATCH) + +BIT_SHIFT(GLIBTOP_PROCDATA_START_TIME) + +BIT_SHIFT(GLIBTOP_PROCDATA_UTIME) + +BIT_SHIFT(GLIBTOP_PROCDATA_STIME) + +BIT_SHIFT(GLIBTOP_PROCDATA_CUTIME) + +BIT_SHIFT(GLIBTOP_PROCDATA_CSTIME) + +BIT_SHIFT(GLIBTOP_PROCDATA_SIZE) + +BIT_SHIFT(GLIBTOP_PROCDATA_RESIDENT) + +BIT_SHIFT(GLIBTOP_PROCDATA_SHARE) + +BIT_SHIFT(GLIBTOP_PROCDATA_TRS) + +BIT_SHIFT(GLIBTOP_PROCDATA_LRS) + +BIT_SHIFT(GLIBTOP_PROCDATA_DRS) + +BIT_SHIFT(GLIBTOP_PROCDATA_DT) + +BIT_SHIFT(GLIBTOP_PROCDATA_VSIZE) + +BIT_SHIFT(GLIBTOP_PROCDATA_RSS) + +BIT_SHIFT(GLIBTOP_PROCDATA_RSS_RLIM) + +BIT_SHIFT(GLIBTOP_PROCDATA_TIMEOUT) + +BIT_SHIFT(GLIBTOP_PROCDATA_IT_REAL_VALUE); + +static const unsigned long _glibtop_sysdeps_procdata_1 = +BIT_SHIFT(GLIBTOP_PROCDATA_K_FLAGS) + +BIT_SHIFT(GLIBTOP_PROCDATA_MIN_FLT) + +BIT_SHIFT(GLIBTOP_PROCDATA_MAJ_FLT) + +BIT_SHIFT(GLIBTOP_PROCDATA_CMIN_FLT) + +BIT_SHIFT(GLIBTOP_PROCDATA_CMAJ_FLT) + +BIT_SHIFT(GLIBTOP_PROCDATA_START_CODE) + +BIT_SHIFT(GLIBTOP_PROCDATA_END_CODE) + +BIT_SHIFT(GLIBTOP_PROCDATA_START_STACK) + +BIT_SHIFT(GLIBTOP_PROCDATA_KSTK_ESP) + +BIT_SHIFT(GLIBTOP_PROCDATA_KSTK_EIP) + +BIT_SHIFT(GLIBTOP_PROCDATA_WCHAN); + +/* Provides detailed information about a process. */ + +void +glibtop_get_procdata_s (glibtop *server, glibtop_procdata *buf, pid_t pid) +{ + char input [BUFSIZ], *tmp; + struct stat statb; + int nread; + FILE *f; + + glibtop_init_r (&server, 0, 0); + + memset (buf, 0, sizeof (glibtop_procdata)); + + if (pid == 0) { + /* Client is only interested in the flags. */ + buf->flags [0] = _glibtop_sysdeps_procdata_0; + buf->flags [1] = _glibtop_sysdeps_procdata_1; + return; + } + + + sprintf (input, "/proc/%d/stat", pid); + + if (stat (input, &statb)) return; + + buf->uid = statb.st_uid; + + f = fopen (input, "r"); + if (!f) return; + + nread = fread (input, 1, BUFSIZ, f); + + if (nread < 0) { + fclose (f); + return; + } + + input [nread] = 0; + + /* This is from guile-utils/gtop/proc/readproc.c */ + + /* split into "PID (cmd" and "" */ + tmp = strrchr (input, ')'); + *tmp = '\0'; /* replace trailing ')' with NUL */ + /* parse these two strings separately, skipping the leading "(". */ + memset (buf->cmd, 0, sizeof (buf->cmd)); + sscanf (input, "%d (%39c", &buf->pid, buf->cmd); + sscanf(tmp + 2, /* skip space after ')' too */ + "%c %d %d %d %d %d %lu %lu %lu %lu %lu " + "%ld %ld %ld %ld %d %d %lu %lu %ld %lu " + "%lu %lu %lu %lu %lu %lu %lu %d %d %d %d %lu", + &buf->state, &buf->ppid, &buf->pgrp, &buf->session, + &buf->tty, &buf->tpgid, &buf->k_flags, &buf->min_flt, + &buf->cmin_flt, &buf->maj_flt, &buf->cmaj_flt, + &buf->utime, &buf->stime, &buf->cutime, &buf->cstime, + &buf->priority, &buf->nice, &buf->timeout, + &buf->it_real_value, &buf->start_time, &buf->vsize, + &buf->rss, &buf->rss_rlim, &buf->start_code, + &buf->end_code, &buf->start_stack, &buf->kstk_esp, + &buf->kstk_eip, &buf->signal, &buf->blocked, + &buf->sigignore, &buf->sigcatch, &buf->wchan); + + if (buf->tty == 0) + /* the old notty val, update elsewhere bef. moving to 0 */ + buf->tty = -1; + + if (server->os_version_code < LINUX_VERSION(1,3,39)) { + /* map old meanings to new */ + buf->priority = 2*15 - buf->priority; + buf->nice = 15 - buf->nice; + } + if (server->os_version_code < LINUX_VERSION(1,1,30) && buf->tty != -1) + /* when tty wasn't full devno */ + buf->tty = 4*0x100 + buf->tty; + + fclose (f); + + sprintf (input, "/proc/%d/statm", pid); + + f = fopen (input, "r"); + if (!f) return; + + nread = fread (input, 1, BUFSIZ, f); + + if (nread < 0) { + fclose (f); + return; + } + + input [nread] = 0; + + sscanf (input, "%ld %ld %ld %ld %ld %ld %ld", + &buf->size, &buf->resident, &buf->share, + &buf->trs, &buf->lrs, &buf->drs, &buf->dt); + + fclose (f); + + buf->flags [0] = _glibtop_sysdeps_procdata_0; + buf->flags [1] = _glibtop_sysdeps_procdata_1; +} diff --git a/sysdeps/stub_suid/prockernel.c b/sysdeps/stub_suid/prockernel.c new file mode 100644 index 00000000..4f183894 --- /dev/null +++ b/sysdeps/stub_suid/prockernel.c @@ -0,0 +1,47 @@ +/* $Id$ */ + +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Martin Baulig , April 1998. + + The Gnome Top Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. + + The Gnome Top Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#include +#include +#include + +#include + +static const unsigned long _glibtop_sysdeps_proc_kernel = 0; + +/* Init function. */ + +void +glibtop_init_proc_kernel_p (glibtop *server) +{ + server->sysdeps.proc_kernel = _glibtop_sysdeps_proc_kernel; +} + +/* Provides detailed information about a process. */ + +void +glibtop_get_proc_kernel_p (glibtop *server, glibtop_proc_kernel *buf, + pid_t pid) +{ + glibtop_init_p (server, GLIBTOP_SYSDEPS_PROC_KERNEL, 0); + + memset (buf, 0, sizeof (glibtop_proc_kernel)); +} diff --git a/sysdeps/stub_suid/proclist.c b/sysdeps/stub_suid/proclist.c new file mode 100644 index 00000000..d94600ca --- /dev/null +++ b/sysdeps/stub_suid/proclist.c @@ -0,0 +1,46 @@ +/* $Id$ */ + +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Martin Baulig , April 1998. + + The Gnome Top Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. + + The Gnome Top Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#include +#include +#include + +#include + +static const unsigned long _glibtop_sysdeps_proclist = 0; + +/* Init function. */ + +void +glibtop_init_proclist_p (glibtop *server) +{ + server->sysdeps.proclist = _glibtop_sysdeps_proclist; +} + +unsigned * +glibtop_get_proclist_p (glibtop *server, glibtop_proclist *buf) +{ + glibtop_init_p (server, GLIBTOP_SYSDEPS_PROCLIST, 0); + + memset (buf, 0, sizeof (glibtop_proclist)); + + return NULL; +} diff --git a/sysdeps/stub_suid/procmem.c b/sysdeps/stub_suid/procmem.c new file mode 100644 index 00000000..357d9456 --- /dev/null +++ b/sysdeps/stub_suid/procmem.c @@ -0,0 +1,47 @@ +/* $Id$ */ + +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Martin Baulig , April 1998. + + The Gnome Top Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. + + The Gnome Top Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#include +#include +#include + +#include + +static const unsigned long _glibtop_sysdeps_proc_mem = 0; + +/* Init function. */ + +void +glibtop_init_proc_mem_p (glibtop *server) +{ + server->sysdeps.proc_mem = _glibtop_sysdeps_proc_mem; +} + +/* Provides detailed information about a process. */ + +void +glibtop_get_proc_mem_p (glibtop *server, glibtop_proc_mem *buf, + pid_t pid) +{ + glibtop_init_p (server, GLIBTOP_SYSDEPS_PROC_MEM, 0); + + memset (buf, 0, sizeof (glibtop_proc_mem)); +} diff --git a/sysdeps/stub_suid/procsegment.c b/sysdeps/stub_suid/procsegment.c new file mode 100644 index 00000000..0f087b21 --- /dev/null +++ b/sysdeps/stub_suid/procsegment.c @@ -0,0 +1,47 @@ +/* $Id$ */ + +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Martin Baulig , April 1998. + + The Gnome Top Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. + + The Gnome Top Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#include +#include +#include + +#include + +static const unsigned long _glibtop_sysdeps_proc_segment = 0; + +/* Init function. */ + +void +glibtop_init_proc_segment_p (glibtop *server) +{ + server->sysdeps.proc_segment = _glibtop_sysdeps_proc_segment; +} + +/* Provides detailed information about a process. */ + +void +glibtop_get_proc_segment_p (glibtop *server, glibtop_proc_segment *buf, + pid_t pid) +{ + glibtop_init_p (server, GLIBTOP_SYSDEPS_PROC_SEGMENT, 0); + + memset (buf, 0, sizeof (glibtop_proc_segment)); +} diff --git a/sysdeps/stub_suid/procsignal.c b/sysdeps/stub_suid/procsignal.c new file mode 100644 index 00000000..63b9ccad --- /dev/null +++ b/sysdeps/stub_suid/procsignal.c @@ -0,0 +1,47 @@ +/* $Id$ */ + +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Martin Baulig , April 1998. + + The Gnome Top Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. + + The Gnome Top Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#include +#include +#include + +#include + +static const unsigned long _glibtop_sysdeps_proc_signal = 0; + +/* Init function. */ + +void +glibtop_init_proc_signal_p (glibtop *server) +{ + server->sysdeps.proc_signal = _glibtop_sysdeps_proc_signal; +} + +/* Provides detailed information about a process. */ + +void +glibtop_get_proc_signal_p (glibtop *server, glibtop_proc_signal *buf, + pid_t pid) +{ + glibtop_init_p (server, GLIBTOP_SYSDEPS_PROC_SIGNAL, 0); + + memset (buf, 0, sizeof (glibtop_proc_signal)); +} diff --git a/sysdeps/stub_suid/procstate.c b/sysdeps/stub_suid/procstate.c new file mode 100644 index 00000000..c33e3a9b --- /dev/null +++ b/sysdeps/stub_suid/procstate.c @@ -0,0 +1,47 @@ +/* $Id$ */ + +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Martin Baulig , April 1998. + + The Gnome Top Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. + + The Gnome Top Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#include +#include +#include + +#include + +static const unsigned long _glibtop_sysdeps_proc_state = 0; + +/* Init function. */ + +void +glibtop_init_proc_state_p (glibtop *server) +{ + server->sysdeps.proc_state = _glibtop_sysdeps_proc_state; +} + +/* Provides detailed information about a process. */ + +void +glibtop_get_proc_state_p (glibtop *server, glibtop_proc_state *buf, + pid_t pid) +{ + glibtop_init_p (server, GLIBTOP_SYSDEPS_PROC_STATE, 0); + + memset (buf, 0, sizeof (glibtop_proc_state)); +} diff --git a/sysdeps/stub_suid/proctime.c b/sysdeps/stub_suid/proctime.c new file mode 100644 index 00000000..0d51542c --- /dev/null +++ b/sysdeps/stub_suid/proctime.c @@ -0,0 +1,47 @@ +/* $Id$ */ + +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Martin Baulig , April 1998. + + The Gnome Top Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. + + The Gnome Top Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#include +#include +#include + +#include + +static const unsigned long _glibtop_sysdeps_proc_time = 0; + +/* Init function. */ + +void +glibtop_init_proc_time_p (glibtop *server) +{ + server->sysdeps.proc_time = _glibtop_sysdeps_proc_time; +} + +/* Provides detailed information about a process. */ + +void +glibtop_get_proc_time_p (glibtop *server, glibtop_proc_time *buf, + pid_t pid) +{ + glibtop_init_p (server, GLIBTOP_SYSDEPS_PROC_TIME, 0); + + memset (buf, 0, sizeof (glibtop_proc_time)); +} diff --git a/sysdeps/stub_suid/procuid.c b/sysdeps/stub_suid/procuid.c new file mode 100644 index 00000000..fd6404bf --- /dev/null +++ b/sysdeps/stub_suid/procuid.c @@ -0,0 +1,47 @@ +/* $Id$ */ + +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Martin Baulig , April 1998. + + The Gnome Top Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. + + The Gnome Top Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#include +#include +#include + +#include + +static const unsigned long _glibtop_sysdeps_proc_uid = 0; + +/* Init function. */ + +void +glibtop_init_proc_uid_p (glibtop *server) +{ + server->sysdeps.proc_uid = _glibtop_sysdeps_proc_uid; +} + +/* Provides detailed information about a process. */ + +void +glibtop_get_proc_uid_p (glibtop *server, glibtop_proc_uid *buf, + pid_t pid) +{ + glibtop_init_p (server, GLIBTOP_SYSDEPS_PROC_UID, 0); + + memset (buf, 0, sizeof (glibtop_proc_uid)); +} diff --git a/sysdeps/stub_suid/sem_limits.c b/sysdeps/stub_suid/sem_limits.c new file mode 100644 index 00000000..188dc4d9 --- /dev/null +++ b/sysdeps/stub_suid/sem_limits.c @@ -0,0 +1,46 @@ +/* $Id$ */ + +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Martin Baulig , April 1998. + + The Gnome Top Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. + + The Gnome Top Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#include +#include +#include + +#include + +static const unsigned long _glibtop_sysdeps_sem_limits = 0; + +/* Init function. */ + +void +glibtop_init_sem_limits_p (glibtop *server) +{ + server->sysdeps.sem_limits = _glibtop_sysdeps_sem_limits; +} + +/* Provides information about sysv sem limits. */ + +void +glibtop_get_sem_limits_p (glibtop *server, glibtop_sem_limits *buf) +{ + glibtop_init_p (server, GLIBTOP_SYSDEPS_SEM_LIMITS, 0); + + memset (buf, 0, sizeof (glibtop_sem_limits)); +} diff --git a/sysdeps/stub_suid/shm_limits.c b/sysdeps/stub_suid/shm_limits.c new file mode 100644 index 00000000..6f81c819 --- /dev/null +++ b/sysdeps/stub_suid/shm_limits.c @@ -0,0 +1,46 @@ +/* $Id$ */ + +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Martin Baulig , April 1998. + + The Gnome Top Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. + + The Gnome Top Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#include +#include +#include + +#include + +static const unsigned long _glibtop_sysdeps_shm_limits = 0; + +/* Init function. */ + +void +glibtop_init_shm_limits_p (glibtop *server) +{ + server->sysdeps.shm_limits = _glibtop_sysdeps_shm_limits; +} + +/* Provides information about sysv ipc limits. */ + +void +glibtop_get_shm_limits_p (glibtop *server, glibtop_shm_limits *buf) +{ + glibtop_init_p (server, GLIBTOP_SYSDEPS_SHM_LIMITS, 0); + + memset (buf, 0, sizeof (glibtop_shm_limits)); +} diff --git a/sysdeps/stub_suid/siglist.c b/sysdeps/stub_suid/siglist.c new file mode 100644 index 00000000..a4afb9bb --- /dev/null +++ b/sysdeps/stub_suid/siglist.c @@ -0,0 +1,26 @@ +/* $Id$ */ + +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Martin Baulig , April 1998. + + The Gnome Top Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. + + The Gnome Top Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#include +#include + +const glibtop_signame glibtop_sys_siglist [] = +{ { 0, NULL, NULL } }; diff --git a/sysdeps/stub_suid/swap.c b/sysdeps/stub_suid/swap.c new file mode 100644 index 00000000..e0f72cae --- /dev/null +++ b/sysdeps/stub_suid/swap.c @@ -0,0 +1,46 @@ +/* $Id$ */ + +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Martin Baulig , April 1998. + + The Gnome Top Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. + + The Gnome Top Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#include +#include +#include + +#include + +static const unsigned long _glibtop_sysdeps_swap = 0; + +/* Init function. */ + +void +glibtop_init_swap_p (glibtop *server) +{ + server->sysdeps.swap = _glibtop_sysdeps_swap; +} + +/* Provides information about swap usage. */ + +void +glibtop_get_swap_p (glibtop *server, glibtop_swap *buf) +{ + glibtop_init_p (server, GLIBTOP_SYSDEPS_SWAP, 0); + + memset (buf, 0, sizeof (glibtop_swap)); +} diff --git a/sysdeps/stub_suid/uptime.c b/sysdeps/stub_suid/uptime.c new file mode 100644 index 00000000..5aa76522 --- /dev/null +++ b/sysdeps/stub_suid/uptime.c @@ -0,0 +1,46 @@ +/* $Id$ */ + +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Martin Baulig , April 1998. + + The Gnome Top Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. + + The Gnome Top Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#include +#include +#include + +#include + +static const unsigned long _glibtop_sysdeps_uptime = 0; + +/* Init function. */ + +void +glibtop_init_uptime_p (glibtop *server) +{ + server->sysdeps.uptime = _glibtop_sysdeps_uptime; +} + +/* Provides uptime and idle time. */ + +void +glibtop_get_uptime_p (glibtop *server, glibtop_uptime *buf) +{ + glibtop_init_p (server, GLIBTOP_SYSDEPS_UPTIME, 0); + + memset (buf, 0, sizeof (glibtop_uptime)); +}