Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 19 Aug 2001 00:21:50 -0700
From:      Kris Kennaway <kris@obsecurity.org>
To:        audit@FreeBSD.org
Subject:   iostat signal handler patch
Message-ID:  <20010819002149.A52245@xor.obsecurity.org>

index | next in thread | raw e-mail

[-- Attachment #1 --]
iostat is still setgid kmem in RELENG_4..I don't know how easy it
would be to backport the sysctl additions which allowed us to remove
setgid kmem in -current, but in the meantime perhaps this patch should
be committed.  This patch is relative to the RELENG_4 code.

Kris

Index: iostat.c
===================================================================
RCS file: /usr2/ncvs/src/usr.sbin/iostat/iostat.c,v
retrieving revision 1.17.2.2
diff -u -r1.17.2.2 iostat.c
--- iostat.c	2001/07/19 04:15:42	1.17.2.2
+++ iostat.c	2001/08/19 07:20:02
@@ -108,6 +108,7 @@
 #include <ctype.h>
 #include <fcntl.h>
 #include <kvm.h>
+#include <signal.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
@@ -135,6 +136,7 @@
 struct device_selection *dev_select;
 int maxshowdevs;
 int dflag = 0, Iflag = 0, Cflag = 0, Tflag = 0, oflag = 0, Kflag = 0;
+volatile sig_atomic_t phdr_flag = 0;
 
 #define nlread(x, v) \
 	kvm_read(kd, namelist[x].n_value, &(v), sizeof(v))
@@ -142,6 +144,7 @@
 /* local function declarations */
 static void usage(void);
 static void phdr(int signo);
+static void do_phdr();
 static void devstats(int perf_select);
 static void cpustats(void);
 
@@ -406,8 +409,13 @@
 		long tmp;
 		double etime;
 
+		if (phdr_flag) {
+			phdr_flag = 0;
+			do_phdr();
+		}
+		
 		if (!--headercount) {
-			phdr(0);
+			do_phdr();
 			headercount = 20;
 		}
 		(void)kvm_read(kd, namelist[X_TK_NIN].n_value,
@@ -451,7 +459,7 @@
 				errx(1, "%s", devstat_errbuf);
 				break;
 			case 1:
-				phdr(0);
+				do_phdr();
 				headercount = 20;
 				break;
 			default:
@@ -482,7 +490,7 @@
 				errx(1,"%s", devstat_errbuf);
 				break;
 			case 1:
-				phdr(0);
+				do_phdr();
 				headercount = 20;
 				break;
 			default:
@@ -528,6 +536,13 @@
 
 static void
 phdr(int signo)
+{
+
+	phdr_flag = 1;	
+}
+
+static void
+do_phdr() 
 {
 	register int i;
 	int printed;


[-- Attachment #2 --]
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (FreeBSD)
Comment: For info see http://www.gnupg.org

iD8DBQE7f2kMWry0BWjoQKURAoEPAKCk9RqoQ7LnVbJZTrrwiq/S7ANH5ACdERJe
HAyawSM4Y4/pliDz1YQN4L0=
=JqCR
-----END PGP SIGNATURE-----
help

Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20010819002149.A52245>