Index: head/devel/libgtop/Makefile =================================================================== --- head/devel/libgtop/Makefile (revision 245729) +++ head/devel/libgtop/Makefile (revision 245730) @@ -1,50 +1,50 @@ # New ports collection makefile for: libgtop2 # Date Created: 29 April 2002 # Whom: Joe Marcus Clarke # # $FreeBSD$ # $MCom: ports/devel/libgtop/Makefile,v 1.52 2009/09/21 09:27:35 kwm Exp $ # PORTNAME= libgtop PORTVERSION= 2.28.0 -PORTREVISION= 1 +PORTREVISION= 2 CATEGORIES= devel gnome MASTER_SITES= GNOME DIST_SUBDIR= gnome2 MAINTAINER= gnome@FreeBSD.org COMMENT= GNOME 2 top library USE_BZIP2= yes USE_PERL5_BUILD=yes USE_GETTEXT= yes USE_GMAKE= yes USE_GNOME= gnomehack glib20 ltverhack intlhack USE_LDCONFIG= yes USE_AUTOTOOLS= libtool:22 CONFIGURE_ARGS= --disable-gtk-doc \ --with-html-dir=${PREFIX}/share/doc CONFIGURE_ENV= CPPFLAGS="-I${LOCALBASE}/include" \ LDFLAGS="-L${LOCALBASE}/lib" INFO= libgtop2 PKGMESSAGE= ${FILESDIR}/pkg-message .include .if ( ${OSVERSION} >= 800000 && ${OSVERSION} < 800019 ) || \ ${OSVERSION} < 700104 RUN_DEPENDS+= lsof:${PORTSDIR}/sysutils/lsof .endif post-patch: @${FIND} ${WRKSRC} -type f | ${XARGS} ${TOUCH} -f post-install: @${CHGRP} kmem ${PREFIX}/bin/libgtop_server2 @${CHMOD} 2555 ${PREFIX}/bin/libgtop_server2 @${CAT} ${PKGMESSAGE} .include Property changes on: head/devel/libgtop/Makefile ___________________________________________________________________ Modified: cvs2svn:cvs-rev ## -1 +1 ## -1.97 \ No newline at end of property +1.98 \ No newline at end of property Index: head/devel/libgtop/files/patch-sysdeps_freebsd_glibtop_machine.h =================================================================== --- head/devel/libgtop/files/patch-sysdeps_freebsd_glibtop_machine.h (nonexistent) +++ head/devel/libgtop/files/patch-sysdeps_freebsd_glibtop_machine.h (revision 245730) @@ -0,0 +1,10 @@ +--- sysdeps/freebsd/glibtop_machine.h.orig 2009-12-13 18:34:21.000000000 -0500 ++++ sysdeps/freebsd/glibtop_machine.h 2009-12-13 18:34:32.000000000 -0500 +@@ -24,6 +24,7 @@ + + #include + #include ++#include + #include + #include + #include Property changes on: head/devel/libgtop/files/patch-sysdeps_freebsd_glibtop_machine.h ___________________________________________________________________ Added: cvs2svn:cvs-rev ## -0,0 +1 ## +1.1 \ No newline at end of property Added: fbsd:nokeywords ## -0,0 +1 ## +yes \ No newline at end of property Index: head/devel/libgtop/files/patch-sysdeps_freebsd_procmap.c =================================================================== --- head/devel/libgtop/files/patch-sysdeps_freebsd_procmap.c (revision 245729) +++ head/devel/libgtop/files/patch-sysdeps_freebsd_procmap.c (revision 245730) @@ -1,25 +1,35 @@ ---- sysdeps/freebsd/procmap.c.orig 2009-12-13 13:47:22.000000000 -0500 -+++ sysdeps/freebsd/procmap.c 2009-12-13 13:47:27.000000000 -0500 -@@ -111,18 +111,18 @@ _glibtop_sysdeps_freebsd_dev_inode (glib +--- sysdeps/freebsd/procmap.c.orig 2009-12-13 18:53:02.827740000 -0500 ++++ sysdeps/freebsd/procmap.c 2009-12-13 19:00:04.000000000 -0500 +@@ -85,7 +85,9 @@ _glibtop_sysdeps_freebsd_dev_inode (glib + char tagstr[12]; + struct inode inode; + struct cdev_priv priv; ++#if __FreeBSD_version < 800039 + struct cdev si; ++#endif + + *inum = 0; + *dev = 0; +@@ -111,18 +113,18 @@ _glibtop_sysdeps_freebsd_dev_inode (glib return; } - if (kvm_read (server->machine.kd, (gulong) inode.i_dev, (char *) &si, - sizeof (si)) != sizeof (si) || #if __FreeBSD_version >= 800039 - kvm_read (server->machine.kd, (gulong) cdev2priv(&si), (char *) &priv, + if (kvm_read (server->machine.kd, (gulong) cdev2priv(inode.i_dev), (char *) &priv, sizeof (priv)) #else + if (kvm_read (server->machine.kd, (gulong) inode.i_dev, (char *) &si, + sizeof (si)) != sizeof (si) || kvm_read (server->machine.kd, (gulong) si.si_priv, (char *) &priv, sizeof (priv)) #endif != sizeof (priv)) { - glibtop_warn_io_r (server, "kvm_read (si)"); + glibtop_warn_io_r (server, "kvm_read (priv)"); return; } Property changes on: head/devel/libgtop/files/patch-sysdeps_freebsd_procmap.c ___________________________________________________________________ Modified: cvs2svn:cvs-rev ## -1 +1 ## -1.4 \ No newline at end of property +1.5 \ No newline at end of property Index: head/devel/libgtop/files/patch-sysdeps_freebsd_procopenfiles.c =================================================================== --- head/devel/libgtop/files/patch-sysdeps_freebsd_procopenfiles.c (revision 245729) +++ head/devel/libgtop/files/patch-sysdeps_freebsd_procopenfiles.c (revision 245730) @@ -1,59 +1,61 @@ ---- sysdeps/freebsd/procopenfiles.c.orig 2008-08-18 11:23:36.000000000 -0400 -+++ sysdeps/freebsd/procopenfiles.c 2008-12-07 00:17:26.000000000 -0500 +--- sysdeps/freebsd/procopenfiles.c.orig 2009-12-13 18:53:02.827740000 -0500 ++++ sysdeps/freebsd/procopenfiles.c 2009-12-13 18:54:55.000000000 -0500 @@ -35,6 +35,9 @@ #include #include #include -+#ifdef HAVE_KINFO_PROC ++#ifdef HAVE_KINFO_GETFILE +#include +#endif #include #include -@@ -263,8 +266,12 @@ glibtop_get_proc_open_files_s (glibtop * +@@ -263,9 +266,13 @@ glibtop_get_proc_open_files_s (glibtop * { #if __FreeBSD_version > 800018 || (__FreeBSD_version < 800000 && __FreeBSD_version >= 700104) struct kinfo_file *freep, *kif; +#ifndef HAVE_KINFO_GETFILE int name[4]; size_t len; +- size_t i; +#else + int cnt; +#endif - size_t i; ++ ssize_t i; #else char *output; + #endif @@ -274,6 +281,7 @@ glibtop_get_proc_open_files_s (glibtop * memset(buf, 0, sizeof (glibtop_proc_open_files)); #if __FreeBSD_version > 800018 || (__FreeBSD_version < 800000 && __FreeBSD_version >= 700104) +#ifndef HAVE_KINFO_GETFILE name[0] = CTL_KERN; name[1] = KERN_PROC; name[2] = KERN_PROC_FILEDESC; @@ -287,12 +295,25 @@ glibtop_get_proc_open_files_s (glibtop * g_free(freep); return NULL; } +#else + freep = kinfo_getfile(pid, &cnt); +#endif entries = g_array_new(FALSE, FALSE, sizeof(glibtop_open_files_entry)); +#ifndef HAVE_KINFO_GETFILE for (i = 0; i < len / sizeof(*kif); i++, kif++) { glibtop_open_files_entry entry = {0}; + if (kif->kf_structsize != sizeof(*kif)) + continue; +#else + for (i = 0; i < cnt; i++) { + glibtop_open_files_entry entry = {0}; + + kif = &freep[i]; +#endif + if (kif->kf_fd < 0) continue; Property changes on: head/devel/libgtop/files/patch-sysdeps_freebsd_procopenfiles.c ___________________________________________________________________ Modified: cvs2svn:cvs-rev ## -1 +1 ## -1.4 \ No newline at end of property +1.5 \ No newline at end of property Index: head/devel/libgtop/files/patch-sysdeps_freebsd_procwd.c =================================================================== --- head/devel/libgtop/files/patch-sysdeps_freebsd_procwd.c (revision 245729) +++ head/devel/libgtop/files/patch-sysdeps_freebsd_procwd.c (revision 245730) @@ -1,58 +1,67 @@ ---- sysdeps/freebsd/procwd.c.orig 2008-08-18 11:23:36.000000000 -0400 -+++ sysdeps/freebsd/procwd.c 2008-12-07 00:19:44.000000000 -0500 +--- sysdeps/freebsd/procwd.c.orig 2009-12-13 18:53:02.827740000 -0500 ++++ sysdeps/freebsd/procwd.c 2009-12-13 18:59:27.000000000 -0500 @@ -27,6 +27,9 @@ #include #include #include +#ifdef HAVE_KINFO_GETFILE +#include +#endif #include static const unsigned long _glibtop_sysdeps_proc_wd = +@@ -40,7 +43,7 @@ _glibtop_init_proc_wd_s(glibtop *server) + server->sysdeps.proc_wd = _glibtop_sysdeps_proc_wd; + } + +-#if (__FreeBSD_version >= 800000 && __FreeBSD_version < 800019) || _FreeBSD_version < 700104 ++#if (__FreeBSD_version >= 800000 && __FreeBSD_version < 800019) || __FreeBSD_version < 700104 + static GPtrArray * + parse_output(const char *output, glibtop_proc_wd *buf) + { @@ -101,10 +104,14 @@ glibtop_get_proc_wd_s(glibtop *server, g #if __FreeBSD_version > 800018 || (__FreeBSD_version < 800000 && __FreeBSD_version >= 700104) struct kinfo_file *freep, *kif; GPtrArray *dirs; +#ifndef HAVE_KINFO_GETFILE size_t len; - int i; int name[4]; #else + int cnt; +#endif + int i; +#else char *output; #endif @@ -115,6 +122,7 @@ glibtop_get_proc_wd_s(glibtop *server, g buf->flags |= (1 << GLIBTOP_PROC_WD_EXE); #if __FreeBSD_version > 800018 || (__FreeBSD_version < 800000 && __FreeBSD_version >= 700104) +#ifndef HAVE_KINFO_GETFILE name[0] = CTL_KERN; name[1] = KERN_PROC; name[2] = KERN_PROC_FILEDESC; @@ -127,10 +135,21 @@ glibtop_get_proc_wd_s(glibtop *server, g g_free(freep); return NULL; } +#else + freep = kinfo_getfile(pid, &cnt); +#endif dirs = g_ptr_array_sized_new(1); +#ifndef HAVE_KINFO_GETFILE for (i = 0; i < len / sizeof(*kif); i++, kif++) { + if (kif->kf_structsize != sizeof(*kif)) + continue; +#else + for (i = 0; i < cnt; i++) { + kif = &freep[i]; +#endif + switch (kif->kf_fd) { case KF_FD_TYPE_ROOT: g_strlcpy(buf->root, kif->kf_path, Property changes on: head/devel/libgtop/files/patch-sysdeps_freebsd_procwd.c ___________________________________________________________________ Modified: cvs2svn:cvs-rev ## -1 +1 ## -1.4 \ No newline at end of property +1.5 \ No newline at end of property Index: head/devel/libgtop/files/patch-sysdeps_freebsd_suid_open.c =================================================================== --- head/devel/libgtop/files/patch-sysdeps_freebsd_suid_open.c (revision 245729) +++ head/devel/libgtop/files/patch-sysdeps_freebsd_suid_open.c (revision 245730) @@ -1,94 +1,95 @@ ---- 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 @@ +--- sysdeps/freebsd/suid_open.c.orig 2009-12-13 13:47:12.739004000 -0500 ++++ sysdeps/freebsd/suid_open.c 2009-12-13 18:37:51.000000000 -0500 +@@ -0,0 +1,92 @@ +/* Copyright (C) 1998 Joshua Sled + This file is part of LibGTop 1.0. + + Contributed by Joshua Sled , 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 +#include +#include +#include +#include +#include + + +/* !!! 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) +{ ++ char errbuf[_POSIX2_LINE_MAX]; +#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"); ++ server->machine.kd = kvm_openfiles (NULL, NULL, NULL, O_RDONLY, errbuf); + + 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. */ +} Property changes on: head/devel/libgtop/files/patch-sysdeps_freebsd_suid_open.c ___________________________________________________________________ Modified: cvs2svn:cvs-rev ## -1 +1 ## -1.1 \ No newline at end of property +1.2 \ No newline at end of property