changeset 13547:7d365d7822b1

1894 ps goes walkabout through /dev in search of foreign ttys Reviewed by: Jerry Jelinek <jerry.jelinek@joyent.com> Reviewed by: Robert Mustacchi <rm@joyent.com> Reviewed by: Richard Lowe <richlowe@richlowe.net> Approved by: Garrett D'Amore <garrett@nexenta.com>
author Bryan Cantrill <bryan@joyent.com>
date Fri, 16 Dec 2011 20:10:44 -0500
parents 6d7e5def82fb
children c7b36cdbb672
files usr/src/cmd/ps/ps.c usr/src/cmd/ps/ucbps.c
diffstat 2 files changed, 11 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/usr/src/cmd/ps/ps.c	Sun May 15 23:09:23 2011 +0100
+++ b/usr/src/cmd/ps/ps.c	Fri Dec 16 20:10:44 2011 -0500
@@ -1228,10 +1228,14 @@
 gettty(psinfo_t *psinfo)
 {
 	extern char *_ttyname_dev(dev_t, char *, size_t);
+	static zoneid_t zid = -1;
 	char devname[TTYNAME_MAX];
 	char *retval;
 
-	if (psinfo->pr_ttydev == PRNODEV)
+	if (zid == -1)
+		zid = getzoneid();
+
+	if (psinfo->pr_ttydev == PRNODEV || psinfo->pr_zoneid != zid)
 		return ("?");
 
 	if ((retval = devlookup(psinfo->pr_ttydev)) != NULL)
--- a/usr/src/cmd/ps/ucbps.c	Sun May 15 23:09:23 2011 +0100
+++ b/usr/src/cmd/ps/ucbps.c	Fri Dec 16 20:10:44 2011 -0500
@@ -65,6 +65,7 @@
 #include <stdarg.h>
 #include <sys/proc.h>
 #include <priv_utils.h>
+#include <zone.h>
 
 #define	NTTYS	2	/* max ttys that can be specified with the -t option */
 			/* only one tty can be specified with SunOS ps */
@@ -803,10 +804,14 @@
 gettty(psinfo_t *psinfo)
 {
 	extern char *_ttyname_dev(dev_t, char *, size_t);
+	static zoneid_t zid = -1;
 	char devname[TTYNAME_MAX];
 	char *retval;
 
-	if (psinfo->pr_ttydev == PRNODEV)
+	if (zid == -1)
+		zid = getzoneid();
+
+	if (psinfo->pr_ttydev == PRNODEV || psinfo->pr_zoneid != zid)
 		return ("?");
 
 	if ((retval = devlookup(psinfo->pr_ttydev)) != NULL)