diff options
author | marino <marino@pkgsrc.org> | 2012-08-08 18:37:07 +0000 |
---|---|---|
committer | marino <marino@pkgsrc.org> | 2012-08-08 18:37:07 +0000 |
commit | 8e66e6824f011673a37b5e0497a916288e95b226 (patch) | |
tree | 37734f700875d6aea7c73775de536f2c699324fa /sysutils | |
parent | 491a90d8eac7ab463abf02274813d8a467f2c3f2 (diff) | |
download | pkgsrc-8e66e6824f011673a37b5e0497a916288e95b226.tar.gz |
sysutils/whowatch: Fix LP64 and DragonFly regression
1) The 4th argument of the sysctl function requires type size_t, not int,
which matters for LP64.
2) DragonFly's kinfo structure changed dramatically a few years ago,
breaking this package. Repatched.
3) sysctl can return pid of -1 for pure kernel processes which must be
skipped to avoid a segfault.
Diffstat (limited to 'sysutils')
-rw-r--r-- | sysutils/whowatch/Makefile | 4 | ||||
-rw-r--r-- | sysutils/whowatch/distinfo | 5 | ||||
-rw-r--r-- | sysutils/whowatch/patches/patch-ad | 94 | ||||
-rw-r--r-- | sysutils/whowatch/patches/patch-proctree.c | 22 |
4 files changed, 114 insertions, 11 deletions
diff --git a/sysutils/whowatch/Makefile b/sysutils/whowatch/Makefile index e058d8f1132..21405a668b8 100644 --- a/sysutils/whowatch/Makefile +++ b/sysutils/whowatch/Makefile @@ -1,8 +1,8 @@ -# $NetBSD: Makefile,v 1.14 2010/01/27 20:35:10 joerg Exp $ +# $NetBSD: Makefile,v 1.15 2012/08/08 18:37:07 marino Exp $ # DISTNAME= whowatch-1.4 -PKGREVISION= 2 +PKGREVISION= 3 CATEGORIES= sysutils MASTER_SITES= http://wizard.ae.krakow.pl/~mike/download/ \ http://janek.ae.krakow.pl/~suszyckm/download/ diff --git a/sysutils/whowatch/distinfo b/sysutils/whowatch/distinfo index 725c4d79611..eaba473b71d 100644 --- a/sysutils/whowatch/distinfo +++ b/sysutils/whowatch/distinfo @@ -1,4 +1,4 @@ -$NetBSD: distinfo,v 1.5 2006/12/13 18:21:36 wiz Exp $ +$NetBSD: distinfo,v 1.6 2012/08/08 18:37:07 marino Exp $ SHA1 (whowatch-1.4.tar.gz) = 0d60c8ddb56b9bf9d2f3e1452832ccb2c862ff0c RMD160 (whowatch-1.4.tar.gz) = da2ee1d52e2a1d5292713259e66b4e7dd39b8dfd @@ -6,5 +6,6 @@ Size (whowatch-1.4.tar.gz) = 43084 bytes SHA1 (patch-aa) = a42dbcd3f9a7138a6ec2e52d34e616e7113b87e2 SHA1 (patch-ab) = f66829eaf7d148df10c2ca064ed81bdedf5c9adc SHA1 (patch-ac) = 9482d1b1759858a83b1efeaa5fc9dd9ec49043c7 -SHA1 (patch-ad) = cd9a57e6b633927d8373c292a6b6d1ed265fc05c +SHA1 (patch-ad) = 41a9e710b8bbe427c715da5d82e77bf32a2f7a34 SHA1 (patch-ae) = ebb4f046df6ce950a320216f2d9f5238340a10b1 +SHA1 (patch-proctree.c) = 54bd828dac7f3f6dfd51f869e812e0c5a3a989fd diff --git a/sysutils/whowatch/patches/patch-ad b/sysutils/whowatch/patches/patch-ad index 0122e4ba308..8aa7e24013e 100644 --- a/sysutils/whowatch/patches/patch-ad +++ b/sysutils/whowatch/patches/patch-ad @@ -1,16 +1,96 @@ -$NetBSD: patch-ad,v 1.1 2006/06/12 16:41:30 joerg Exp $ +$NetBSD: patch-ad,v 1.2 2012/08/08 18:37:07 marino Exp $ ---- procinfo.c.orig 2006-06-12 16:36:48.000000000 +0000 +Fix LP64 support on FreeBSD/DragonFly (size_t instead of int) +Add DragonFly support -- kinfo structure is unique on DragonFly + +--- procinfo.c.orig 2000-06-06 18:36:47.000000000 +0000 +++ procinfo.c -@@ -85,7 +85,11 @@ void get_info(int pid, struct procinfo * +@@ -65,7 +65,7 @@ void get_info(int pid, struct procinfo * + int fill_kinfo(struct kinfo_proc *info, int pid) + { + int mib[] = { CTL_KERN, KERN_PROC, KERN_PROC_PID, pid }; +- int len = sizeof *info; ++ size_t len = sizeof *info; + if(sysctl(mib, 4, info, &len, 0, 0) == -1) + return -1; + return len?0:-1; +@@ -83,12 +83,21 @@ void get_info(int pid, struct procinfo * + + if(fill_kinfo(&info, pid) == -1) return; ++#ifdef __DragonFly__ ++ p->ppid = info.kp_ppid; ++ p->tpgid = info.kp_tpgid; ++ p->euid = info.kp_svuid; ++ p->stat = info.kp_stat; ++ strncpy(p->exec_file, info.kp_comm, EXEC_FILE); ++ p->cterm = info.kp_tdev; ++#else p->ppid = info.kp_eproc.e_ppid; p->tpgid = info.kp_eproc.e_tpgid; -+#if defined(__DragonFly__) -+ p->euid = info.kp_eproc.e_ucred.cr_svuid; -+#else p->euid = info.kp_eproc.e_pcred.p_svuid; -+#endif p->stat = info.kp_proc.p_stat; strncpy(p->exec_file, info.kp_proc.p_comm, EXEC_FILE); p->cterm = info.kp_eproc.e_tdev; ++#endif + p->exec_file[EXEC_FILE] = '\0'; + } + #endif +@@ -124,7 +133,8 @@ int get_term(char *tty) + int get_login_pid(char *tty) + { + int mib[4] = {CTL_KERN, KERN_PROC, KERN_PROC_TTY, 0}; +- int len, t, el, i, pid, cndt = -1, l; ++ size_t len; ++ int t, el, i, pid, cndt = -1, l; + struct kinfo_proc *info; + struct procinfo p; + +@@ -142,6 +152,17 @@ int get_login_pid(char *tty) + if(sysctl(mib, 4, info, &len, 0, 0) == -1) + return -1; + for(i = 0; i < el; i++) { ++#ifdef __DragonFly__ ++ if(!(pid = info[i].kp_pid)) continue; ++ get_info(get_ppid(pid), &p); ++ if(p.cterm == -1 || p.cterm != t) { ++ cndt = pid; ++ l = strlen(info[i].kp_comm); ++ if(l > 1 && !strncmp("sh",info[i].kp_comm+l-2,2)) { ++ free(info); ++ return pid; ++ } ++#else + if(!(pid = info[i].kp_proc.p_pid)) continue; + get_info(get_ppid(pid), &p); + if(p.cterm == -1 || p.cterm != t) { +@@ -157,6 +178,7 @@ int get_login_pid(char *tty) + free(info); + return pid; + } ++#endif + } + } + free(info); +@@ -169,7 +191,8 @@ int get_login_pid(char *tty) + int get_all_info(struct kinfo_proc **info) + { + int mib[3] = { CTL_KERN, KERN_PROC, KERN_PROC_ALL }; +- int len, el; ++ size_t len; ++ int el; + + if(sysctl(mib, 3, 0, &len, 0, 0) == -1) + return 0; +@@ -239,7 +262,11 @@ char *get_cmdline(int pid) + bzero(buf, sizeof buf); + if(fill_kinfo(&info, pid) == -1) + return "-"; ++#ifdef __DragonFly__ ++ memcpy(buf, info.kp_comm, sizeof buf - 1); ++#else + memcpy(buf, info.kp_proc.p_comm, sizeof buf - 1); ++#endif + if(!full_cmd) return buf; + #ifdef HAVE_LIBKVM + if(!can_use_kvm) return buf; diff --git a/sysutils/whowatch/patches/patch-proctree.c b/sysutils/whowatch/patches/patch-proctree.c new file mode 100644 index 00000000000..f2e262814b7 --- /dev/null +++ b/sysutils/whowatch/patches/patch-proctree.c @@ -0,0 +1,22 @@ +$NetBSD: patch-proctree.c,v 1.1 2012/08/08 18:37:07 marino Exp $ + +Add DragonFly support (kernel proc can return pid of -1, skip) +kinfo structure is unique on DragonFly + +--- proctree.c.orig 2000-06-06 09:03:28.000000000 +0000 ++++ proctree.c +@@ -170,8 +170,14 @@ int update_tree(void del(void*)) + #ifdef HAVE_PROCESS_SYSCTL + el = get_all_info(&pi); + for(i = 0; i < el; i++) { ++#ifdef __DragonFly__ ++ if (pi[i].kp_pid == -1) continue; ++ p = validate_proc(pi[i].kp_pid); ++ q = validate_proc(pi[i].kp_ppid); ++#else + p = validate_proc(pi[i].kp_proc.p_pid); + q = validate_proc(pi[i].kp_eproc.e_ppid); ++#endif + #else + + d=opendir(PROCDIR); |