summaryrefslogtreecommitdiff
path: root/sysutils/skill
diff options
context:
space:
mode:
authorsimonb <simonb>2000-06-26 07:54:40 +0000
committersimonb <simonb>2000-06-26 07:54:40 +0000
commitd75d60fdd350a6d315019ed08f91832c03dd693e (patch)
tree6554b6b39d6504190db49dd2b72fb2751ee84ced /sysutils/skill
parentc90d92a8addf2dfaf4554b86cbe7fb5d86be1db6 (diff)
downloadpkgsrc-d75d60fdd350a6d315019ed08f91832c03dd693e.tar.gz
Use the kern.proc (or kern.proc2 if available) sysctl directly, so that
libkvm isn't needed, and skill/snice can run without setgid. Tested on 1.3.3, 1.4 and 1.5A, and should work all the way back to NetBSD 0.8. Note: applies for NetBSD only, not Solaris :)
Diffstat (limited to 'sysutils/skill')
-rw-r--r--sysutils/skill/Makefile7
-rw-r--r--sysutils/skill/files/patch-sum5
-rw-r--r--sysutils/skill/patches/patch-aa11
-rw-r--r--sysutils/skill/patches/patch-ab158
4 files changed, 169 insertions, 12 deletions
diff --git a/sysutils/skill/Makefile b/sysutils/skill/Makefile
index ef3b9a6e45c..31f32f336ef 100644
--- a/sysutils/skill/Makefile
+++ b/sysutils/skill/Makefile
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.8 2000/02/20 02:02:51 wiz Exp $
+# $NetBSD: Makefile,v 1.9 2000/06/26 07:54:40 simonb Exp $
#
# The version number for skill does not match the @P number.
# This is normal.
@@ -12,13 +12,12 @@ EXTRACT_SUFX= _tar.Z
MAINTAINER= kim@tac.nyc.ny.us
-BINMODE= 02555
-
.include "../../mk/bsd.prefs.mk"
.if ${OPSYS} == "NetBSD"
-MAKE_ENV+= OSTYPE=bsd-44 BINGRP=kmem COPTS=-DUVM
+MAKE_ENV+= OSTYPE=bsd-44
.elif ${OPSYS} == "SunOS"
+BINMODE= 02555
MAKE_ENV+= OSTYPE=sys-5r4 BINGRP=sys CPPFLAGS=
.endif
diff --git a/sysutils/skill/files/patch-sum b/sysutils/skill/files/patch-sum
index 2238a4d343e..ec488004567 100644
--- a/sysutils/skill/files/patch-sum
+++ b/sysutils/skill/files/patch-sum
@@ -1,3 +1,4 @@
-$NetBSD: patch-sum,v 1.4 2000/02/20 02:02:52 wiz Exp $
+$NetBSD: patch-sum,v 1.5 2000/06/26 07:54:42 simonb Exp $
-MD5 (patch-aa) = f923b45b898f5a9d5db09a45dceedabc
+MD5 (patch-aa) = c650e9348d22bb07487b0bf9b4e5c599
+MD5 (patch-ab) = 2884b29a7d91bc52d190fa669127f082
diff --git a/sysutils/skill/patches/patch-aa b/sysutils/skill/patches/patch-aa
index 394b6d72e34..73f7c29dacb 100644
--- a/sysutils/skill/patches/patch-aa
+++ b/sysutils/skill/patches/patch-aa
@@ -1,4 +1,4 @@
-$NetBSD: patch-aa,v 1.7 2000/02/20 02:02:52 wiz Exp $
+$NetBSD: patch-aa,v 1.8 2000/06/26 07:54:42 simonb Exp $
--- ./Makefile.orig Tue Feb 8 04:21:15 2000
+++ ./Makefile Sun Feb 20 02:55:27 2000
@@ -10,7 +10,8 @@ $NetBSD: patch-aa,v 1.7 2000/02/20 02:02:52 wiz Exp $
-BINGRP= kmem
+BINDIR= ${PREFIX}/bin
+#BINGRP= kmem
- BINMOD= 2755
+-BINMOD= 2755
++#BINMOD= ${BINMODE}
# CONFIGURE: Set location of man directory and man page suffix.
-MANDIR= /usr/man/manl
@@ -23,12 +24,10 @@ $NetBSD: patch-aa,v 1.7 2000/02/20 02:02:52 wiz Exp $
+#OSTYPE= bsd-44
# CONFIGURE(Config): Add any OS-specific options here.
--COPTS=
-+#COPTS= -DUVM
+ COPTS=
# CONFIGURE(Config): Add any special libraries your system needs.
--LIBS=
-+LIBS= -lkvm
+ LIBS=
SRCS= main.c argparse.c getproc.c
OBJS= main.o argparse.o getproc.o
diff --git a/sysutils/skill/patches/patch-ab b/sysutils/skill/patches/patch-ab
new file mode 100644
index 00000000000..da1b40f86d7
--- /dev/null
+++ b/sysutils/skill/patches/patch-ab
@@ -0,0 +1,158 @@
+$NetBSD: patch-ab,v 1.5 2000/06/26 07:54:42 simonb Exp $
+
+--- machdep/bsd-44.c.orig Sun Feb 20 07:37:39 2000
++++ machdep/bsd-44.c Fri Jun 23 13:33:09 2000
+@@ -135,9 +135,6 @@
+ * Now, set up everything we need to write a GetProc() routine.
+ */
+
+-#include <kvm.h>
+-#include <fcntl.h>
+-
+ #if defined(BSD4_4) && (BSD < 199306)
+ #include <sys/kinfo.h>
+ #include <sys/kinfo_proc.h>
+@@ -155,8 +152,28 @@
+ static char *pidmap[] = { "swapper", "init", "pagedaemon" };
+ static int pidmapsiz = sizeof(pidmap) / sizeof(pidmap[0]);
+
+-#define PROC(kprocp) kprocp->kp_proc
+-#define EPROC(kprocp) kprocp->kp_eproc
++#ifdef KERN_PROC2
++#define CMDLEN KI_MAXCOMLEN
++#define PROCTYPE struct kinfo_proc2
++#define SYSCTL_TO_USE KERN_PROC2
++#define SYSCTL_MIBS 6
++#define PROC_COMM(kprocp) kprocp->p_comm
++#define PROC_FLAG(kprocp) kprocp->p_flag
++#define PROC_PID(kprocp) kprocp->p_pid
++#define PROC_STAT(kprocp) kprocp->p_stat
++#define PROC_TDEV(kprocp) kprocp->p_tdev
++#define PROC_UID(kprocp) kprocp->p_uid
++#else
++#define PROCTYPE struct kinfo_proc
++#define SYSCTL_TO_USE KERN_PROC
++#define SYSCTL_MIBS 4
++#define PROC_COMM(kprocp) kprocp->kp_proc.p_comm
++#define PROC_FLAG(kprocp) kprocp->kp_proc.p_flag
++#define PROC_PID(kprocp) kprocp->kp_proc.p_pid
++#define PROC_STAT(kprocp) kprocp->kp_proc.p_stat
++#define PROC_TDEV(kprocp) kprocp->kp_eproc.e_tdev
++#define PROC_UID(kprocp) kprocp->kp_eproc.e_ucred.cr_uid
++#endif
+
+ /*
+ * GetProc()
+@@ -169,54 +186,59 @@
+ {
+ static struct ProcInfo procinfo;
+ static int nproc = -1;
+- static struct kinfo_proc *aproc;
+- static kvm_t *kd = NULL;
++ static PROCTYPE *aproc;
+ #ifdef _POSIX2_LINE_MAX
+ char errbuf[_POSIX2_LINE_MAX];
+ #else
+ char errbuf[2048];
+ #endif
++ int mib[6];
++ size_t size;
+
+ /*
+ * If this is our first time here, prepare to read procs from kernel.
+ */
+ if (nproc == -1) {
+- kd = kvm_openfiles((char *)NULL, (char *)NULL, (char *)NULL,
+- O_RDONLY, errbuf);
+- if (kd == NULL) {
+- fprintf(stderr, "%s: %s\n", ProgName, errbuf);
+- exit(EX_SERR);
+- }
++ mib[0] = CTL_KERN;
++ mib[1] = SYSCTL_TO_USE;
++ mib[2] = _ALLPROCFLAG;
++ mib[3] = 0;
++#ifdef KERN_PROC2
++ mib[4] = sizeof(PROCTYPE);
++ mib[5] = 0;
++#endif
++ if (sysctl(mib, SYSCTL_MIBS, NULL, &size, NULL, 0) < 0)
++ err(1, "sysctl kern.proc2");
++ aproc = (PROCTYPE *)malloc(size);
++ if (aproc == NULL)
++ errx(1, "out of memory");
+
+- if ((aproc=kvm_getprocs(kd, _ALLPROCFLAG, 0, &nproc)) == NULL) {
+- fprintf(stderr, "%s: %s\n", ProgName, kvm_geterr(kd));
+- exit(EX_SERR);
+- }
++#ifdef KERN_PROC2
++ mib[5] = size / sizeof(PROCTYPE);
++#endif
++ if (sysctl(mib, SYSCTL_MIBS, aproc, &size, NULL, 0) < 0)
++ err(1, "sysctl kern.proc2");
++ nproc = size / sizeof(PROCTYPE);
+ }
+
+- if (nproc == 0) {
+- if (kd != NULL) {
+- kvm_close(kd);
+- kd = NULL;
+- }
+- return((struct ProcInfo *)NULL);
+- }
++ if (nproc == 0)
++ return(NULL);
+
+ do {
+- if (PROC(aproc).p_stat != 0) {
++ if (PROC_STAT(aproc) != 0) {
+ /*
+ * Make sure this isn't a "zombie" or "exiting"
+ * process. If it is, fill in procinfo and return.
+ */
+ procinfo.pi_flags = 0;
+- procinfo.pi_pid = (pid_T) PROC(aproc).p_pid;
+- procinfo.pi_uid = (uid_T) EPROC(aproc).e_ucred.cr_uid;
++ procinfo.pi_pid = (pid_T) PROC_PID(aproc);
++ procinfo.pi_uid = (uid_T) PROC_UID(aproc);
+
+- if (PROC(aproc).p_stat == SZOMB) { /* zombie */
++ if (PROC_STAT(aproc) == SZOMB) { /* zombie */
+ static char *zombie = "<defunct>";
+ procinfo.pi_flags |= PI_ZOMBIE;
+ procinfo.pi_cmd = zombie;
+- } else if (PROC(aproc).p_flag & P_WEXIT) { /* exiting */
++ } else if (PROC_FLAG(aproc) & P_WEXIT) { /* exiting */
+ static char *exiting = "<exiting>";
+ procinfo.pi_flags |= PI_SWEXIT;
+ procinfo.pi_cmd = exiting;
+@@ -228,22 +250,22 @@
+ return(&procinfo);
+ }
+ }
+- } while (PROC(aproc).p_stat == 0);
++ } while (PROC_STAT(aproc) == 0);
+
+ /*
+ * We now have a process (`aproc').
+ * Fill in the rest of `procinfo'.
+ */
+- if (EPROC(aproc).e_tdev != NODEV) { /* controlling tty */
++ if (PROC_TDEV(aproc) != NODEV) { /* controlling tty */
+ procinfo.pi_flags |= PI_CTLTTY;
+- procinfo.pi_tty = (tty_T) EPROC(aproc).e_tdev;
++ procinfo.pi_tty = (tty_T) PROC_TDEV(aproc);
+ }
+
+- if (PROC(aproc).p_pid < pidmapsiz) { /* special */
+- procinfo.pi_cmd = pidmap[PROC(aproc).p_pid];
++ if (PROC_PID(aproc) < pidmapsiz) { /* special */
++ procinfo.pi_cmd = pidmap[PROC_PID(aproc)];
+ procinfo.pi_flags |= PI_ASKUSR;
+ } else /* set path-stripped command name */
+- SETCMD(procinfo.pi_cmd, PROC(aproc).p_comm, MAXCOMLEN)
++ SETCMD(procinfo.pi_cmd, PROC_COMM(aproc), MAXCOMLEN)
+
+ nproc--;
+ aproc++;