From owner-freebsd-arch Tue Jan 23 2:18:38 2001 Delivered-To: freebsd-arch@freebsd.org Received: from ringworld.nanolink.com (ringworld.nanolink.com [195.24.48.189]) by hub.freebsd.org (Postfix) with SMTP id DE29D37B402 for ; Tue, 23 Jan 2001 02:18:06 -0800 (PST) Received: (qmail 3427 invoked by uid 1000); 23 Jan 2001 10:16:37 -0000 Date: Tue, 23 Jan 2001 12:16:37 +0200 From: Peter Pentchev To: Garrett Wollman Cc: freebsd-bugs@FreeBSD.org, freebsd-arch@FreeBSD.org Subject: Re: bin/24540: add '-c' flag to src/bin/domainname to clear domainname Message-ID: <20010123121637.E2376@ringworld.oblivion.bg> Mail-Followup-To: Garrett Wollman , freebsd-bugs@FreeBSD.org, freebsd-arch@FreeBSD.org References: <200101222010.f0MKA2185498@freefall.freebsd.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5i In-Reply-To: <200101222010.f0MKA2185498@freefall.freebsd.org>; from wollman@khavrinen.lcs.mit.edu on Mon, Jan 22, 2001 at 12:10:02PM -0800 Sender: owner-freebsd-arch@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG On Mon, Jan 22, 2001 at 12:10:02PM -0800, Garrett Wollman wrote: > The following reply was made to PR bin/24540; it has been noted by GNATS. > > From: Garrett Wollman > To: Pete Fritchman > Cc: freebsd-gnats-submit@FreeBSD.ORG, phk@FreeBSD.ORG > Subject: Re: bin/24540: add '-c' flag to src/bin/domainname to clear domainname > Date: Mon, 22 Jan 2001 15:02:57 -0500 (EST) > > < said: > > > electron# ./domainname foo.bar > > electron# ./domainname '' > > electron# ./domainname > > foo.bar > > I think this is a bug in sysctl. Note the following: > > root@khavrinen(6)# sysctl -w kern.domainname='' > kern.domainname: foo.bar -> foo.bar > > What is happening is that the sysctl() system call is interpreting the > request to set the MIB variable to a zero-length object as if it were > an indication that setting is not requested. Here is an (untested) > fix (beware cut&paste has bogotified whitespace): > > > > --- kern_sysctl.c 2000/07/28 22:40:04 1.100 > +++ kern_sysctl.c 2001/01/22 20:01:38 > @@ -862,7 +862,7 @@ > req.oldptr= old; > } > > - if (newlen) { > + if (new) { > req.newlen = newlen; > req.newptr = new; > } > @@ -1101,7 +1101,7 @@ > req.oldptr= old; > } > > - if (newlen) { > + if (new) { > if (!useracc(new, req.newlen, VM_PROT_READ)) > return (EFAULT); > req.newlen = newlen; > > -GAWollman This works for me; still, how about changing the test to if (newlen || (new != NULL)) in both places? I have a -current system which has been running fine for three hours now with this fix, and there have been no signs of breakage (there shouldn't be, unless somewhere someone passes uninit'd values to new or newval). -arch CC'd because of the proposed kern_sysctl change :) G'luck, Peter -- Nostalgia ain't what it used to be. To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-arch" in the body of the message