diff options
author | Martin Baulig <martin@home-of-linux.org> | 1998-08-25 08:03:52 +0000 |
---|---|---|
committer | Martin Baulig <martin@src.gnome.org> | 1998-08-25 08:03:52 +0000 |
commit | 8e540b8fc05f7a70e2b6d24c60c4ad7fa0da6912 (patch) | |
tree | 5823a51425922322c9b9ab7ceb123078cbf9bb22 | |
parent | 4789169c80650029be9c72e3543fe1f45855324d (diff) | |
download | libgtop-8e540b8fc05f7a70e2b6d24c60c4ad7fa0da6912.tar.gz |
Using correct `(1 << GLIBTOP_SYSDPES_*)'. (<glibtop_suid.h>): Include.
1998-08-25 Martin Baulig <martin@home-of-linux.org>
* *.c (glibtop_init_p): Using correct `(1 << GLIBTOP_SYSDPES_*)'.
(<glibtop_suid.h>): Include.
* glibtop_suid.h: New file.
* ChangeLog: New file.
-rw-r--r-- | sysdeps/sun4/cpu.c | 22 | ||||
-rw-r--r-- | sysdeps/sun4/glibtop_server.h | 1 | ||||
-rw-r--r-- | sysdeps/sun4/glibtop_suid.h | 42 | ||||
-rw-r--r-- | sysdeps/sun4/loadavg.c | 4 | ||||
-rw-r--r-- | sysdeps/sun4/mem.c | 11 | ||||
-rw-r--r-- | sysdeps/sun4/msg_limits.c | 4 | ||||
-rw-r--r-- | sysdeps/sun4/nosuid.c | 1 | ||||
-rw-r--r-- | sysdeps/sun4/prockernel.c | 6 | ||||
-rw-r--r-- | sysdeps/sun4/proclist.c | 7 | ||||
-rw-r--r-- | sysdeps/sun4/procmem.c | 4 | ||||
-rw-r--r-- | sysdeps/sun4/procsegment.c | 11 | ||||
-rw-r--r-- | sysdeps/sun4/procsignal.c | 4 | ||||
-rw-r--r-- | sysdeps/sun4/procstate.c | 4 | ||||
-rw-r--r-- | sysdeps/sun4/proctime.c | 4 | ||||
-rw-r--r-- | sysdeps/sun4/procuid.c | 4 | ||||
-rw-r--r-- | sysdeps/sun4/sem_limits.c | 4 | ||||
-rw-r--r-- | sysdeps/sun4/shm_limits.c | 4 | ||||
-rw-r--r-- | sysdeps/sun4/swap.c | 4 | ||||
-rw-r--r-- | sysdeps/sun4/uptime.c | 4 |
19 files changed, 111 insertions, 34 deletions
diff --git a/sysdeps/sun4/cpu.c b/sysdeps/sun4/cpu.c index a51bedfd..7a2a41b8 100644 --- a/sysdeps/sun4/cpu.c +++ b/sysdeps/sun4/cpu.c @@ -22,6 +22,8 @@ #include <glibtop.h> #include <glibtop/cpu.h> +#include <glibtop_suid.h> + static const unsigned long _glibtop_sysdeps_cpu = (1 << GLIBTOP_CPU_TOTAL) + (1 << GLIBTOP_CPU_USER) + (1 << GLIBTOP_CPU_NICE) + (1 << GLIBTOP_CPU_SYS) + @@ -35,13 +37,13 @@ glibtop_get_cpu_p (glibtop *server, glibtop_cpu *buf) long cp_time [CPUSTATES], mp_time [NCPU][CPUSTATES]; int i; - glibtop_init_p (&server, 0, 0); - + glibtop_init_p (server, (1 << GLIBTOP_SYSDEPS_CPU), 0); + memset (buf, 0, sizeof (glibtop_cpu)); /* !!! THE FOLLOWING CODE RUNS SGID KMEM - CHANGE WITH CAUTION !!! */ - - setregid (server->machine.gid, server->machine.egid); + + glibtop_suid_enter (server); /* get the cp_time array */ @@ -58,17 +60,17 @@ glibtop_get_cpu_p (glibtop *server, glibtop_cpu *buf) _glibtop_nlist [X_MP_TIME].n_name); } #endif - - if (setregid (server->machine.egid, server->machine.gid)) - _exit (1); + + glibtop_suid_leave (server); /* !!! END OF SUID ROOT PART !!! */ #ifdef MULTIPROCESSOR - /* If we have multiple processors, we add the times for each of them and set - frequency to 100 times the number of the processors. */ + /* If we have multiple processors, we add the times for each of them + * and set frequency to 100 times the number of the processors. */ - /* [FIXME]: I had no machine with more than one processor to test this code !!! */ + /* [FIXME]: I had no machine with more than one processor to test + * this code !!! */ if (server->machine.ncpu > 1) { for (i = 0; i < server->machine.ncpu; i++) { diff --git a/sysdeps/sun4/glibtop_server.h b/sysdeps/sun4/glibtop_server.h index 4b37edfc..199991ac 100644 --- a/sysdeps/sun4/glibtop_server.h +++ b/sysdeps/sun4/glibtop_server.h @@ -40,6 +40,7 @@ __BEGIN_DECLS #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) +#define GLIBTOP_SUID_PROC_MAP (1 << GLIBTOP_SYSDEPS_PROC_MAP) __END_DECLS diff --git a/sysdeps/sun4/glibtop_suid.h b/sysdeps/sun4/glibtop_suid.h new file mode 100644 index 00000000..bff87930 --- /dev/null +++ b/sysdeps/sun4/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 <martin@home-of-linux.org>, 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) { + setregid (server->machine.gid, server->machine.egid); +}; + +static inline void glibtop_suid_leave (glibtop *server) { + if (setregid (server->machine.egid, server->machine.gid)) + _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/sun4/loadavg.c b/sysdeps/sun4/loadavg.c index 61bb17a7..e433ccd2 100644 --- a/sysdeps/sun4/loadavg.c +++ b/sysdeps/sun4/loadavg.c @@ -22,6 +22,8 @@ #include <glibtop.h> #include <glibtop/loadavg.h> +#include <glibtop_suid.h> + static const unsigned long _glibtop_sysdeps_loadavg = (1 << GLIBTOP_LOADAVG_LOADAVG); @@ -33,7 +35,7 @@ glibtop_get_loadavg_p (glibtop *server, glibtop_loadavg *buf) load_avg avenrun [3]; int i; - glibtop_init_p (&server, 0, 0); + glibtop_init_p (server, (1 << GLIBTOP_SYSDEPS_LOADAVG), 0); memset (buf, 0, sizeof (glibtop_loadavg)); diff --git a/sysdeps/sun4/mem.c b/sysdeps/sun4/mem.c index 1d5c3738..93949576 100644 --- a/sysdeps/sun4/mem.c +++ b/sysdeps/sun4/mem.c @@ -22,6 +22,8 @@ #include <glibtop.h> #include <glibtop/mem.h> +#include <glibtop_suid.h> + static const unsigned long _glibtop_sysdeps_mem = (1 << GLIBTOP_MEM_TOTAL) + (1 << GLIBTOP_MEM_USED) + (1 << GLIBTOP_MEM_FREE) + (1 << GLIBTOP_MEM_LOCKED); @@ -35,13 +37,13 @@ static const unsigned long _glibtop_sysdeps_mem = void glibtop_get_mem_p (glibtop *server, glibtop_mem *buf) { - glibtop_init_p (&server, 0, 0); + glibtop_init_p (server, (1 << GLIBTOP_SYSDEPS_MEM), 0); memset (buf, 0, sizeof (glibtop_mem)); /* !!! THE FOLLOWING CODE RUNS SGID KMEM - CHANGE WITH CAUTION !!! */ - setregid (server->machine.gid, server->machine.egid); + glibtop_suid_enter (server); /* get the array of physpage descriptors */ @@ -49,9 +51,8 @@ glibtop_get_mem_p (glibtop *server, glibtop_mem *buf) (int *) server->machine.physpage, server->machine.bytesize, "array _page"); - - if (setregid (server->machine.egid, server->machine.gid)) - _exit (1); + + glibtop_suid_leave (server); /* !!! END OF SGID KMEM PART !!! */ diff --git a/sysdeps/sun4/msg_limits.c b/sysdeps/sun4/msg_limits.c index 11474a7a..80de8a49 100644 --- a/sysdeps/sun4/msg_limits.c +++ b/sysdeps/sun4/msg_limits.c @@ -22,6 +22,8 @@ #include <glibtop.h> #include <glibtop/msg_limits.h> +#include <glibtop_suid.h> + /* #define KERNEL to get declaration of `struct msginfo'. */ #define KERNEL @@ -41,7 +43,7 @@ glibtop_get_msg_limits_p (glibtop *server, glibtop_msg_limits *buf) { struct msginfo msginfo; - glibtop_init_p (&server, 0, 0); + glibtop_init_p (server, (1 << GLIBTOP_SYSDEPS_MSG_LIMITS), 0); memset (buf, 0, sizeof (glibtop_msg_limits)); diff --git a/sysdeps/sun4/nosuid.c b/sysdeps/sun4/nosuid.c index e43e5c9f..94d2b8e8 100644 --- a/sysdeps/sun4/nosuid.c +++ b/sysdeps/sun4/nosuid.c @@ -21,6 +21,7 @@ #include <glibtop.h> #include <glibtop/open.h> +#include <glibtop/close.h> void glibtop_open_s (glibtop *server, const char *program_name, diff --git a/sysdeps/sun4/prockernel.c b/sysdeps/sun4/prockernel.c index 97ba82a0..584ba810 100644 --- a/sysdeps/sun4/prockernel.c +++ b/sysdeps/sun4/prockernel.c @@ -22,6 +22,8 @@ #include <glibtop.h> #include <glibtop/prockernel.h> +#include <glibtop_suid.h> + static const unsigned long _glibtop_sysdeps_proc_kernel = (1 << GLIBTOP_PROC_KERNEL_K_FLAGS) + (1 << GLIBTOP_PROC_KERNEL_WCHAN); @@ -33,7 +35,7 @@ glibtop_get_proc_kernel_p (glibtop *server, glibtop_proc_kernel *buf, { struct proc *pp; - glibtop_init_p (&server, 0, 0); + glibtop_init_p (server, (1 << GLIBTOP_SYSDEPS_PROC_KERNEL), 0); memset (buf, 0, sizeof (glibtop_proc_kernel)); @@ -50,7 +52,7 @@ glibtop_get_proc_kernel_p (glibtop *server, glibtop_proc_kernel *buf, /* Fill in data fields. */ buf->k_flags = pp->p_flag; - buf->wchan = pp->p_wchan; + buf->nwchan = (unsigned long) pp->p_wchan; buf->flags = _glibtop_sysdeps_proc_kernel; } diff --git a/sysdeps/sun4/proclist.c b/sysdeps/sun4/proclist.c index 4241d94c..c417c000 100644 --- a/sysdeps/sun4/proclist.c +++ b/sysdeps/sun4/proclist.c @@ -23,6 +23,8 @@ #include <glibtop/xmalloc.h> #include <glibtop/proclist.h> +#include <glibtop_suid.h> + static const unsigned long _glibtop_sysdeps_proclist = (1 << GLIBTOP_PROCLIST_TOTAL) + (1 << GLIBTOP_PROCLIST_NUMBER) + (1 << GLIBTOP_PROCLIST_SIZE); @@ -35,14 +37,15 @@ static const unsigned long _glibtop_sysdeps_proclist = * each buf->size big. The total size is stored in buf->total. */ unsigned * -glibtop_get_proclist_p (glibtop *server, glibtop_proclist *buf) +glibtop_get_proclist_p (glibtop *server, glibtop_proclist *buf, + int64_t which, int64_t arg) { register struct proc *pp; register int i, nproc = 0; unsigned *proc_list = NULL; size_t proc_size; - glibtop_init_p (&server, 0, 0); + glibtop_init_p (server, (1 << GLIBTOP_SYSDEPS_PROCLIST), 0); memset (buf, 0, sizeof (glibtop_proclist)); diff --git a/sysdeps/sun4/procmem.c b/sysdeps/sun4/procmem.c index edb4378e..98dd0ae7 100644 --- a/sysdeps/sun4/procmem.c +++ b/sysdeps/sun4/procmem.c @@ -22,6 +22,8 @@ #include <config.h> #include <glibtop/procmem.h> +#include <glibtop_suid.h> + static const unsigned long _glibtop_sysdeps_proc_mem = (1 << GLIBTOP_PROC_MEM_SIZE) + (1 << GLIBTOP_PROC_MEM_RSS) + (1 << GLIBTOP_PROC_MEM_RSS_RLIM); @@ -34,7 +36,7 @@ glibtop_get_proc_mem_p (glibtop *server, glibtop_proc_mem *buf, { struct proc *pp; - glibtop_init_p (&server, 0, 0); + glibtop_init_p (server, (1 << GLIBTOP_SYSDEPS_PROC_MEM), 0); memset (buf, 0, sizeof (glibtop_proc_mem)); diff --git a/sysdeps/sun4/procsegment.c b/sysdeps/sun4/procsegment.c index de6ba44c..cf0e5276 100644 --- a/sysdeps/sun4/procsegment.c +++ b/sysdeps/sun4/procsegment.c @@ -22,8 +22,11 @@ #include <glibtop.h> #include <glibtop/procsegment.h> +#include <glibtop_suid.h> + static const unsigned long _glibtop_sysdeps_proc_segment = -(1 << GLIBTOP_PROC_SEGMENT_TRS) + (1 << GLIBTOP_PROC_SEGMENT_DRS); +(1 << GLIBTOP_PROC_SEGMENT_TEXT_RSS) + +(1 << GLIBTOP_PROC_SEGMENT_DATA_RSS); /* Provides detailed information about a process. */ @@ -33,7 +36,7 @@ glibtop_get_proc_segment_p (glibtop *server, glibtop_proc_segment *buf, { struct proc *pp; - glibtop_init_p (&server, 0, 0); + glibtop_init_p (server, (1 << GLIBTOP_SYSDEPS_PROC_SEGMENT), 0); memset (buf, 0, sizeof (glibtop_proc_segment)); @@ -49,8 +52,8 @@ glibtop_get_proc_segment_p (glibtop *server, glibtop_proc_segment *buf, /* Fill in data fields. */ - buf->trs = pp->p_tsize; - buf->drs = pp->p_dsize; + buf->text_rss = pp->p_tsize; + buf->data_rss = pp->p_dsize; buf->flags = _glibtop_sysdeps_proc_segment; } diff --git a/sysdeps/sun4/procsignal.c b/sysdeps/sun4/procsignal.c index 7726427f..5952ceba 100644 --- a/sysdeps/sun4/procsignal.c +++ b/sysdeps/sun4/procsignal.c @@ -22,6 +22,8 @@ #include <glibtop.h> #include <glibtop/procsignal.h> +#include <glibtop_suid.h> + static const unsigned long _glibtop_sysdeps_proc_signal = (1 << GLIBTOP_PROC_SIGNAL_SIGNAL) + (1 << GLIBTOP_PROC_SIGNAL_BLOCKED) + (1 << GLIBTOP_PROC_SIGNAL_SIGIGNORE) + (1 << GLIBTOP_PROC_SIGNAL_SIGCATCH); @@ -34,7 +36,7 @@ glibtop_get_proc_signal_p (glibtop *server, glibtop_proc_signal *buf, { struct proc *pp; - glibtop_init_p (&server, 0, 0); + glibtop_init_p (server, (1 << GLIBTOP_SYSDEPS_PROC_SIGNAL), 0); memset (buf, 0, sizeof (glibtop_proc_signal)); diff --git a/sysdeps/sun4/procstate.c b/sysdeps/sun4/procstate.c index ee99b5be..6d2140ab 100644 --- a/sysdeps/sun4/procstate.c +++ b/sysdeps/sun4/procstate.c @@ -22,6 +22,8 @@ #include <glibtop.h> #include <glibtop/procstate.h> +#include <glibtop_suid.h> + static const unsigned long _glibtop_sysdeps_proc_state = (1 << GLIBTOP_PROC_STATE_STATE) + (1 << GLIBTOP_PROC_STATE_UID); @@ -33,7 +35,7 @@ glibtop_get_proc_state_p (glibtop *server, glibtop_proc_state *buf, { struct proc *pp; - glibtop_init_p (&server, 0, 0); + glibtop_init_p (server, (1 << GLIBTOP_SYSDEPS_PROC_STATE), 0); memset (buf, 0, sizeof (glibtop_proc_state)); diff --git a/sysdeps/sun4/proctime.c b/sysdeps/sun4/proctime.c index 7bc4eb4c..35335a99 100644 --- a/sysdeps/sun4/proctime.c +++ b/sysdeps/sun4/proctime.c @@ -22,6 +22,8 @@ #include <glibtop.h> #include <glibtop/proctime.h> +#include <glibtop_suid.h> + static const unsigned long _glibtop_sysdeps_proc_time = (1 << GLIBTOP_PROC_TIME_START_TIME) + (1 << GLIBTOP_PROC_TIME_UTIME); @@ -33,7 +35,7 @@ glibtop_get_proc_time_p (glibtop *server, glibtop_proc_time *buf, { struct proc *pp; - glibtop_init_p (&server, 0, 0); + glibtop_init_p (server, (1 << GLIBTOP_SYSDEPS_PROC_TIME), 0); memset (buf, 0, sizeof (glibtop_proc_time)); diff --git a/sysdeps/sun4/procuid.c b/sysdeps/sun4/procuid.c index cd3525dc..ad615114 100644 --- a/sysdeps/sun4/procuid.c +++ b/sysdeps/sun4/procuid.c @@ -22,6 +22,8 @@ #include <glibtop.h> #include <glibtop/procuid.h> +#include <glibtop_suid.h> + static const unsigned long _glibtop_sysdeps_proc_uid = (1 << GLIBTOP_PROC_UID_UID) + (1 << GLIBTOP_PROC_UID_EUID) + (1 << GLIBTOP_PROC_UID_EGID) + (1 << GLIBTOP_PROC_UID_PID) + @@ -37,7 +39,7 @@ glibtop_get_proc_uid_p (glibtop *server, glibtop_proc_uid *buf, { struct proc *pp; - glibtop_init_p (&server, 0, 0); + glibtop_init_p (server, (1 << GLIBTOP_SYSDEPS_PROC_UID), 0); memset (buf, 0, sizeof (glibtop_proc_uid)); diff --git a/sysdeps/sun4/sem_limits.c b/sysdeps/sun4/sem_limits.c index 768d001e..0d352415 100644 --- a/sysdeps/sun4/sem_limits.c +++ b/sysdeps/sun4/sem_limits.c @@ -22,6 +22,8 @@ #include <glibtop.h> #include <glibtop/sem_limits.h> +#include <glibtop_suid.h> + /* #define KERNEL to get declaration of `struct seminfo'. */ #define KERNEL @@ -43,7 +45,7 @@ glibtop_get_sem_limits_p (glibtop *server, glibtop_sem_limits *buf) { struct seminfo seminfo; - glibtop_init_p (&server, 0, 0); + glibtop_init_p (server, (1 << GLIBTOP_SYSDEPS_SEM_LIMITS), 0); memset (buf, 0, sizeof (glibtop_sem_limits)); diff --git a/sysdeps/sun4/shm_limits.c b/sysdeps/sun4/shm_limits.c index c6ff9a7b..71791be8 100644 --- a/sysdeps/sun4/shm_limits.c +++ b/sysdeps/sun4/shm_limits.c @@ -22,6 +22,8 @@ #include <glibtop.h> #include <glibtop/shm_limits.h> +#include <glibtop_suid.h> + /* #define KERNEL to get declaration of `struct shminfo'. */ #define KERNEL @@ -41,7 +43,7 @@ glibtop_get_shm_limits_p (glibtop *server, glibtop_shm_limits *buf) { struct shminfo shminfo; - glibtop_init_p (&server, 0, 0); + glibtop_init_p (server, (1 << GLIBTOP_SYSDEPS_SHM_LIMITS), 0); memset (buf, 0, sizeof (glibtop_shm_limits)); diff --git a/sysdeps/sun4/swap.c b/sysdeps/sun4/swap.c index 3b43245b..63c3803b 100644 --- a/sysdeps/sun4/swap.c +++ b/sysdeps/sun4/swap.c @@ -22,12 +22,14 @@ #include <glibtop.h> #include <glibtop/swap.h> +#include <glibtop_suid.h> + /* Provides information about swap usage. */ void glibtop_get_swap_p (glibtop *server, glibtop_swap *buf) { - glibtop_init_p (&server, 0, 0); + glibtop_init_p (server, (1 << GLIBTOP_SYSDEPS_SWAP), 0); memset (buf, 0, sizeof (glibtop_swap)); } diff --git a/sysdeps/sun4/uptime.c b/sysdeps/sun4/uptime.c index 104d54ad..ef33b03d 100644 --- a/sysdeps/sun4/uptime.c +++ b/sysdeps/sun4/uptime.c @@ -23,6 +23,8 @@ #include <glibtop/cpu.h> #include <glibtop/uptime.h> +#include <glibtop_suid.h> + static const unsigned long _glibtop_sysdeps_uptime = (1 << GLIBTOP_UPTIME_UPTIME) + (1 << GLIBTOP_UPTIME_IDLETIME); @@ -33,7 +35,7 @@ glibtop_get_uptime_p (glibtop *server, glibtop_uptime *buf) { glibtop_cpu cpu; - glibtop_init_p (&server, 0, 0); + glibtop_init_p (server, (1 << GLIBTOP_SYSDEPS_UPTIME), 0); /* Get currect cpu usage. */ |