diff options
Diffstat (limited to 'devel/libgtop/files')
6 files changed, 241 insertions, 15 deletions
diff --git a/devel/libgtop/files/patch-sysdeps_freebsd_Makefile.am b/devel/libgtop/files/patch-sysdeps_freebsd_Makefile.am new file mode 100644 index 000000000..25ec1f7d7 --- /dev/null +++ b/devel/libgtop/files/patch-sysdeps_freebsd_Makefile.am @@ -0,0 +1,17 @@ +--- sysdeps/freebsd/Makefile.am.orig 2008-09-29 17:21:56.000000000 -0400 ++++ sysdeps/freebsd/Makefile.am 2008-09-29 17:22:07.000000000 -0400 +@@ -7,12 +7,12 @@ libgtop_sysdeps_2_0_la_SOURCES = nosuid. + cpu.c msg_limits.c sem_limits.c loadavg.c \ + uptime.c netlist.c fsusage.c mem.c \ + mountlist.c procopenfiles.c procwd.c \ +- procaffinity.c glibtop_private.c ++ procaffinity.c glibtop_private.c open.c + + libgtop_sysdeps_2_0_la_LDFLAGS = $(LT_VERSION_INFO) + + libgtop_sysdeps_suid_2_0_la_LIBADD = $(KVM_LIBS) $(EXTRA_SYSDEPS_LIBS) +-libgtop_sysdeps_suid_2_0_la_SOURCES = open.c close.c swap.c \ ++libgtop_sysdeps_suid_2_0_la_SOURCES = suid_open.c close.c swap.c \ + proclist.c procstate.c procuid.c \ + proctime.c procmem.c procsignal.c \ + prockernel.c procsegment.c procargs.c \ diff --git a/devel/libgtop/files/patch-sysdeps_freebsd_Makefile.in b/devel/libgtop/files/patch-sysdeps_freebsd_Makefile.in new file mode 100644 index 000000000..f68c6d0d1 --- /dev/null +++ b/devel/libgtop/files/patch-sysdeps_freebsd_Makefile.in @@ -0,0 +1,40 @@ +--- sysdeps/freebsd/Makefile.in.orig 2008-09-29 17:24:03.000000000 -0400 ++++ sysdeps/freebsd/Makefile.in 2008-09-29 17:24:44.000000000 -0400 +@@ -54,12 +54,13 @@ libgtop_sysdeps_2_0_la_LIBADD = + am_libgtop_sysdeps_2_0_la_OBJECTS = nosuid.lo siglist.lo sysinfo.lo \ + shm_limits.lo cpu.lo msg_limits.lo sem_limits.lo loadavg.lo \ + uptime.lo netlist.lo fsusage.lo mem.lo mountlist.lo \ +- procopenfiles.lo procwd.lo procaffinity.lo glibtop_private.lo ++ procopenfiles.lo procwd.lo procaffinity.lo glibtop_private.lo \ ++ open.lo + libgtop_sysdeps_2_0_la_OBJECTS = $(am_libgtop_sysdeps_2_0_la_OBJECTS) + am__DEPENDENCIES_1 = + libgtop_sysdeps_suid_2_0_la_DEPENDENCIES = $(am__DEPENDENCIES_1) \ + $(am__DEPENDENCIES_1) +-am_libgtop_sysdeps_suid_2_0_la_OBJECTS = open.lo close.lo swap.lo \ ++am_libgtop_sysdeps_suid_2_0_la_OBJECTS = suid_open.lo close.lo swap.lo \ + proclist.lo procstate.lo procuid.lo proctime.lo procmem.lo \ + procsignal.lo prockernel.lo procsegment.lo procargs.lo \ + procmap.lo netload.lo ppp.lo +@@ -306,11 +307,11 @@ libgtop_sysdeps_2_0_la_SOURCES = nosuid. + cpu.c msg_limits.c sem_limits.c loadavg.c \ + uptime.c netlist.c fsusage.c mem.c \ + mountlist.c procopenfiles.c procwd.c \ +- procaffinity.c glibtop_private.c ++ procaffinity.c glibtop_private.c open.c + + libgtop_sysdeps_2_0_la_LDFLAGS = $(LT_VERSION_INFO) + libgtop_sysdeps_suid_2_0_la_LIBADD = $(KVM_LIBS) $(EXTRA_SYSDEPS_LIBS) +-libgtop_sysdeps_suid_2_0_la_SOURCES = open.c close.c swap.c \ ++libgtop_sysdeps_suid_2_0_la_SOURCES = suid_open.c close.c swap.c \ + proclist.c procstate.c procuid.c \ + proctime.c procmem.c procsignal.c \ + prockernel.c procsegment.c procargs.c \ +@@ -385,6 +386,7 @@ distclean-compile: + @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/netlist.Plo@am__quote@ + @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/netload.Plo@am__quote@ + @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nosuid.Plo@am__quote@ ++@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/suid_open.Plo@am__quote@ + @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/open.Plo@am__quote@ + @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ppp.Plo@am__quote@ + @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/procaffinity.Plo@am__quote@ diff --git a/devel/libgtop/files/patch-sysdeps_freebsd_nosuid.c b/devel/libgtop/files/patch-sysdeps_freebsd_nosuid.c new file mode 100644 index 000000000..acb327f98 --- /dev/null +++ b/devel/libgtop/files/patch-sysdeps_freebsd_nosuid.c @@ -0,0 +1,19 @@ +--- sysdeps/freebsd/nosuid.c.orig 2008-09-29 17:28:31.000000000 -0400 ++++ sysdeps/freebsd/nosuid.c 2008-09-29 17:28:39.000000000 -0400 +@@ -21,16 +21,8 @@ + + #include <config.h> + #include <glibtop.h> +-#include <glibtop/open.h> + #include <glibtop/close.h> + + 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/devel/libgtop/files/patch-sysdeps_freebsd_open.c b/devel/libgtop/files/patch-sysdeps_freebsd_open.c index e1caeac7f..f7bf0e3b1 100644 --- a/devel/libgtop/files/patch-sysdeps_freebsd_open.c +++ b/devel/libgtop/files/patch-sysdeps_freebsd_open.c @@ -1,35 +1,91 @@ --- sysdeps/freebsd/open.c.orig 2008-05-23 18:13:23.000000000 -0400 -+++ sysdeps/freebsd/open.c 2008-09-29 14:45:16.000000000 -0400 -@@ -20,11 +20,14 @@ ++++ sysdeps/freebsd/open.c 2008-09-29 17:23:22.000000000 -0400 +@@ -20,76 +20,33 @@ */ #include <config.h> +#include <sys/types.h> +#include <sys/sysctl.h> #include <glibtop.h> - #include <glibtop/error.h> +-#include <glibtop/error.h> #include <glibtop/open.h> - #include <glibtop/init_hooks.h> +-#include <glibtop/init_hooks.h> +- +-/* !!! THIS FUNCTION RUNS SUID ROOT - CHANGE WITH CAUTION !!! */ +- +-void +-glibtop_init_p (glibtop *server, const unsigned long features, +- const unsigned flags) +-{ +- const _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_SYSDEPS) == 0) { +- glibtop_open_p (server, "glibtop", features, flags); ++#include <glibtop/cpu.h> ++#include <glibtop/error.h> -+ - /* !!! THIS FUNCTION RUNS SUID ROOT - CHANGE WITH CAUTION !!! */ +- for (init_fkt = _glibtop_init_hook_p; *init_fkt; init_fkt++) +- (*init_fkt) (server); ++#include <glibtop_private.h> + +- server->flags |= _GLIBTOP_INIT_STATE_SYSDEPS; +- } +-} void -@@ -53,11 +56,17 @@ glibtop_open_p (glibtop *server, const c +-glibtop_open_p (glibtop *server, const char *program_name, ++glibtop_open_s (glibtop *server, const char *program_name, const unsigned long features, const unsigned flags) { +-#ifdef DEBUG +- fprintf (stderr, "DEBUG (%d): glibtop_open_p ()\n", getpid ()); +-#endif + int ncpus; + size_t len; - #ifdef DEBUG - fprintf (stderr, "DEBUG (%d): glibtop_open_p ()\n", getpid ()); - #endif - /* !!! WE ARE ROOT HERE - CHANGE WITH CAUTION !!! */ +- /* !!! WE ARE ROOT HERE - CHANGE WITH CAUTION !!! */ + len = sizeof (ncpus); + sysctlbyname ("hw.ncpu", &ncpus, &len, NULL, 0); + server->real_ncpu = ncpus - 1; + server->ncpu = MIN(GLIBTOP_NCPU - 1, server->real_ncpu); - server->machine.uid = getuid (); - server->machine.euid = geteuid (); +- server->machine.uid = getuid (); +- server->machine.euid = geteuid (); +- server->machine.gid = getgid (); +- server->machine.egid = getegid (); + #if defined(__FreeBSD_kernel__) + server->os_version_code = __FreeBSD_kernel_version; + #else + server->os_version_code = __FreeBSD_version; + #endif +- /* Setup machine-specific data */ +- server->machine.kd = kvm_open (NULL, NULL, NULL, O_RDONLY, "kvm_open"); +- +- if (server->machine.kd == NULL) +- glibtop_error_io_r (server, "kvm_open"); +- +- /* 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. */ + +- /* NOTE: On FreeBSD, we do not need to be suid root, we just need to +- * be sgid kmem. +- * +- * The server will only use setegid() to get back it's priviledges, +- * so it will fail if it is suid root and not sgid kmem. */ + } diff --git a/devel/libgtop/files/patch-sysdeps_freebsd_suid_open.c b/devel/libgtop/files/patch-sysdeps_freebsd_suid_open.c new file mode 100644 index 000000000..a188b364c --- /dev/null +++ b/devel/libgtop/files/patch-sysdeps_freebsd_suid_open.c @@ -0,0 +1,94 @@ +--- sysdeps/freebsd/suid_open.c.orig 2008-09-29 17:22:12.000000000 -0400 ++++ sysdeps/freebsd/suid_open.c 2008-09-29 17:23:35.000000000 -0400 +@@ -0,0 +1,91 @@ ++/* Copyright (C) 1998 Joshua Sled ++ This file is part of LibGTop 1.0. ++ ++ Contributed by Joshua Sled <jsled@xcf.berkeley.edu>, July 1998. ++ ++ LibGTop is free software; you can redistribute it and/or modify it ++ under the terms of the GNU General Public License as published by ++ the Free Software Foundation; either version 2 of the License, ++ or (at your option) any later version. ++ ++ LibGTop 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 General Public License ++ for more details. ++ ++ You should have received a copy of the GNU General Public License ++ along with LibGTop; see the file COPYING. If not, write to the ++ Free Software Foundation, Inc., 59 Temple Place - Suite 330, ++ Boston, MA 02111-1307, USA. ++*/ ++ ++#include <config.h> ++#include <glibtop.h> ++#include <glibtop/error.h> ++#include <glibtop/cpu.h> ++#include <glibtop/open.h> ++#include <glibtop/init_hooks.h> ++ ++ ++/* !!! THIS FUNCTION RUNS SUID ROOT - CHANGE WITH CAUTION !!! */ ++ ++void ++glibtop_init_p (glibtop *server, const unsigned long features, ++ const unsigned flags) ++{ ++ const _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_SYSDEPS) == 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_SYSDEPS; ++ } ++} ++ ++void ++glibtop_open_p (glibtop *server, const char *program_name, ++ const unsigned long features, ++ const unsigned flags) ++{ ++#ifdef DEBUG ++ fprintf (stderr, "DEBUG (%d): glibtop_open_p ()\n", getpid ()); ++#endif ++ ++ /* !!! WE ARE ROOT HERE - CHANGE WITH CAUTION !!! */ ++ server->machine.uid = getuid (); ++ server->machine.euid = geteuid (); ++ server->machine.gid = getgid (); ++ server->machine.egid = getegid (); ++ /* Setup machine-specific data */ ++ server->machine.kd = kvm_open (NULL, NULL, NULL, O_RDONLY, "kvm_open"); ++ ++ if (server->machine.kd == NULL) ++ glibtop_error_io_r (server, "kvm_open"); ++ ++ /* 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. */ ++ ++ /* NOTE: On FreeBSD, we do not need to be suid root, we just need to ++ * be sgid kmem. ++ * ++ * The server will only use setegid() to get back it's priviledges, ++ * so it will fail if it is suid root and not sgid kmem. */ ++} diff --git a/devel/libgtop/files/patch-sysdeps_freebsd_sysinfo.c b/devel/libgtop/files/patch-sysdeps_freebsd_sysinfo.c index 5166a1a98..ab5fdd66d 100644 --- a/devel/libgtop/files/patch-sysdeps_freebsd_sysinfo.c +++ b/devel/libgtop/files/patch-sysdeps_freebsd_sysinfo.c @@ -1,5 +1,5 @@ ---- stsdeps/freebsd/sysinfo.c.orig 2008-05-23 18:13:23.000000000 -0400 -+++ stsdeps/freebsd/sysinfo.c 2008-09-29 14:35:25.000000000 -0400 +--- sysdeps/freebsd/sysinfo.c.orig 2008-05-23 18:13:23.000000000 -0400 ++++ sysdeps/freebsd/sysinfo.c 2008-09-29 14:35:25.000000000 -0400 @@ -45,8 +45,8 @@ init_sysinfo (glibtop *server) glibtop_init_s (&server, GLIBTOP_SYSDEPS_CPU, 0); |