From owner-freebsd-hackers Thu May 17 22:40:43 2001 Delivered-To: freebsd-hackers@freebsd.org Received: from superconductor.rush.net (superconductor.rush.net [208.9.155.8]) by hub.freebsd.org (Postfix) with ESMTP id 9C1C437B424 for ; Thu, 17 May 2001 22:40:40 -0700 (PDT) (envelope-from bright@superconductor.rush.net) Received: (from bright@localhost) by superconductor.rush.net (8.11.2/8.11.2) id f4I5eYf05170; Fri, 18 May 2001 01:40:34 -0400 (EDT) Date: Fri, 18 May 2001 01:40:33 -0400 From: Alfred Perlstein To: Dima Dorfman Cc: hackers@FreeBSD.ORG Subject: Re: De-setgid-ifying ipcs(1) Message-ID: <20010518014032.N7118@superconductor.rush.net> References: <20010518050339.AB8153E0B@bazooka.unixfreak.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Mailer: Mutt 1.0us In-Reply-To: <20010518050339.AB8153E0B@bazooka.unixfreak.org>; from dima@unixfreak.org on Thu, May 17, 2001 at 10:03:39PM -0700 X-all-your-base: are belong to us. Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk List-ID: X-Loop: FreeBSD.ORG * Dima Dorfman [010518 01:05] wrote: > Hi folks, > > ipcs(1) is currently installed as setgid kmem. This isn't good for > obvious reasons. Moreover, the information it needs is easily > exported via sysctl. Below is a patch which adds the necessary sysctl > oids and changes ipcs(1) to use them. I had to export msgids, > msginfo, sema, seminfo, shmsegs, and shminfo. The *info variables > were exported via SYSCTL_STRUCT, and the rest via SYSCTL_PROC. All > read-only by anyone. I'm not particuarly sure it's appropriate to > export the *info variables like that--at least one of them has most > (all?) of its members already exported via SYSCTL_INT, but that would > be a pain to use in this case. The patch preserves ipcs(1)'s ability > to operate on a saved kernel and core. In addition, I also added a -y > command line flag that will cause it to use kvm(3) instead of > sysctl(3), even on a running system. > > Comments? Particuarly, I'd like comments on whether I exported > everything correctly. Probably not the commentary you're looking for, however the getopt parsing shouldn't be done like this: > - while ((i = getopt(argc, argv, "MmQqSsabC:cN:optT")) != -1) > + use_sysctl = 1; > + while ((i = getopt(argc, argv, "MmQqSsabC:cN:optTy")) != -1) > switch (i) { > case 'M': > display = SHMTOTAL; > @@ -184,39 +187,45 @@ > case 't': > option |= TIME; > break; > + case 'y': > + use_sysctl = !use_sysctl; > + break; > default: > usage(); > } Multiple -y options will invert the sense of the flag right? Might as well inialize it to 1 in the DATA segment and replace !use_sysctl with just 0. I'm glad you kept kmem backwards compatibility, as this is required for post mortem analysis of crashdumps. -- -Alfred Perlstein [alfred@freebsd.org] Instead of asking why a piece of software is using "1970s technology," start asking why software is ignoring 30 years of accumulated wisdom. To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message