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>

next in thread | raw e-mail | index | archive | help

--opJtzjQTFsWo+cga
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

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
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
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 =3D 0, Iflag =3D 0, Cflag =3D 0, Tflag =3D 0, oflag =3D 0, Kflag=
 =3D 0;
+volatile sig_atomic_t phdr_flag =3D 0;
=20
 #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);
=20
@@ -406,8 +409,13 @@
 		long tmp;
 		double etime;
=20
+		if (phdr_flag) {
+			phdr_flag =3D 0;
+			do_phdr();
+		}
+	=09
 		if (!--headercount) {
-			phdr(0);
+			do_phdr();
 			headercount =3D 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 =3D 20;
 				break;
 			default:
@@ -482,7 +490,7 @@
 				errx(1,"%s", devstat_errbuf);
 				break;
 			case 1:
-				phdr(0);
+				do_phdr();
 				headercount =3D 20;
 				break;
 			default:
@@ -528,6 +536,13 @@
=20
 static void
 phdr(int signo)
+{
+
+	phdr_flag =3D 1;=09
+}
+
+static void
+do_phdr()=20
 {
 	register int i;
 	int printed;


--opJtzjQTFsWo+cga
Content-Type: application/pgp-signature
Content-Disposition: inline

-----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-----

--opJtzjQTFsWo+cga--

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-audit" in the body of the message




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