Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 18 May 2001 01:40:33 -0400
From:      Alfred Perlstein <bright@rush.net>
To:        Dima Dorfman <dima@unixfreak.org>
Cc:        hackers@FreeBSD.ORG
Subject:   Re: De-setgid-ifying ipcs(1)
Message-ID:  <20010518014032.N7118@superconductor.rush.net>
In-Reply-To: <20010518050339.AB8153E0B@bazooka.unixfreak.org>; from dima@unixfreak.org on Thu, May 17, 2001 at 10:03:39PM -0700
References:  <20010518050339.AB8153E0B@bazooka.unixfreak.org>

next in thread | previous in thread | raw e-mail | index | archive | help
* Dima Dorfman <dima@unixfreak.org> [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




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