Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 8 May 2001 00:33:24 -0700
From:      Kris Kennaway <kris@obsecurity.org>
To:        audit@FreeBSD.org
Subject:   ipcs patch
Message-ID:  <20010508003324.A87133@xor.obsecurity.org>

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

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

This is partly taken from OpenBSD, the fixes to the alignment of the
output are mine.

Kris

Index: ipcs.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: /mnt/ncvs/src/usr.bin/ipcs/ipcs.c,v
retrieving revision 1.14
diff -u -r1.14 ipcs.c
--- ipcs.c	2000/05/01 10:49:41	1.14
+++ ipcs.c	2001/05/08 07:31:56
@@ -192,12 +192,17 @@
 	 * Discard setgid privileges if not the running kernel so that bad
 	 * guys can't print interesting stuff from kernel memory.
 	 */
-	if (namelist !=3D NULL || core !=3D NULL)
+	if (namelist !=3D NULL || core !=3D NULL) {
+		setegid(getgid());
 		setgid(getgid());
+	}
=20
 	if ((kd =3D kvm_open(namelist, core, NULL, O_RDONLY, "ipcs")) =3D=3D NULL)
 		exit(1);
=20
+	setegid(getgid());
+	setgid(getgid());
+
 	switch (kvm_nlist(kd, symbols)) {
 	case 0:
 		break;
@@ -240,7 +245,7 @@
 			kvm_read(kd, (u_long) msqids, xmsqids, sizeof(struct msqid_ds) * msginf=
o.msgmni);
=20
 			printf("Message Queues:\n");
-			printf("T     ID     KEY        MODE       OWNER    GROUP");
+			printf("T       ID     KEY        MODE       OWNER    GROUP");
 			if (option & CREATOR)
 				printf("  CREATOR   CGROUP");
 			if (option & OUTSTANDING)
@@ -262,7 +267,7 @@
 					cvt_time(msqptr->msg_rtime, rtime_buf);
 					cvt_time(msqptr->msg_ctime, ctime_buf);
=20
-					printf("q %6d %10d %s %8s %8s",
+					printf("q %8d %10d %s %8s %8s",
 					    IXSEQ_TO_IPCID(i, msqptr->msg_perm),
 					    msqptr->msg_perm.key,
 					    fmt_perm(msqptr->msg_perm.mode),
@@ -328,7 +333,7 @@
 			    shminfo.shmmni);
=20
 			printf("Shared Memory:\n");
-			printf("T     ID     KEY        MODE       OWNER    GROUP");
+			printf("T       ID     KEY        MODE       OWNER    GROUP");
 			if (option & CREATOR)
 				printf("  CREATOR   CGROUP");
 			if (option & OUTSTANDING)
@@ -350,7 +355,7 @@
 					cvt_time(shmptr->shm_dtime, dtime_buf);
 					cvt_time(shmptr->shm_ctime, ctime_buf);
=20
-					printf("m %6d %10d %s %8s %8s",
+					printf("m %8d %10d %s %8s %8s",
 					    IXSEQ_TO_IPCID(i, shmptr->shm_perm),
 					    shmptr->shm_perm.key,
 					    fmt_perm(shmptr->shm_perm.mode),
@@ -424,7 +429,7 @@
 			kvm_read(kd, (u_long) sema, xsema, sizeof(struct semid_ds) * seminfo.se=
mmni);
=20
 			printf("Semaphores:\n");
-			printf("T     ID     KEY        MODE       OWNER    GROUP");
+			printf("T       ID     KEY        MODE       OWNER    GROUP");
 			if (option & CREATOR)
 				printf("  CREATOR   CGROUP");
 			if (option & BIGGEST)
@@ -440,7 +445,7 @@
 					cvt_time(semaptr->sem_otime, otime_buf);
 					cvt_time(semaptr->sem_ctime, ctime_buf);
=20
-					printf("s %6d %10d %s %8s %8s",
+					printf("s %8d %10d %s %8s %8s",
 					    IXSEQ_TO_IPCID(i, semaptr->sem_perm),
 					    semaptr->sem_perm.key,
 					    fmt_perm(semaptr->sem_perm.mode),


--M9NhX3UHpAaciwkO
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.5 (FreeBSD)
Comment: For info see http://www.gnupg.org

iD8DBQE696FEWry0BWjoQKURAnBdAKDbNKA2wwNZXVowqPA16pYD+ncdbACgjT4l
tCRhsTfvzTtf772nKTHH6yY=
=By7g
-----END PGP SIGNATURE-----

--M9NhX3UHpAaciwkO--

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?20010508003324.A87133>