Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 11 Sep 2013 04:52:47 -0700 (PDT)
From:      Don Lewis <truckman@FreeBSD.org>
To:        freebsd-current@FreeBSD.org
Subject:   Re: uniq busted?
Message-ID:  <201309111152.r8BBqlus001138@gw.catspoiler.org>
In-Reply-To: <201309110721.r8B7LYLG000420@gw.catspoiler.org>

next in thread | previous in thread | raw e-mail | index | archive | help
On 11 Sep, To: freebsd-current@freebsd.org wrote:
> I justed updated my 10.0-CURRENT box and ran into major problems with
> port building.  I tracked the problem down to uniq not working.
> 
> # wc -l /etc/termcap
>     4666 /etc/termcap
> # cat /etc/termcap | uniq
> uniq: unable to limit ioctls for stdout: Capabilities insufficient
> 
> It complains about capabilities and nothing comes out ...
> 
> My kernel and userland are in sync, so the 20130905 note in src/UPDATING
> shouldn't be a factor.  I'm not running a GENERIC kernel, but I include
> GENERIC in my kernel config file:
> 
> # uname -a
> FreeBSD scratch.catspoiler.org 10.0-CURRENT FreeBSD 10.0-CURRENT #32 r255089: Sat Aug 31 02:27:17 PDT 2013     dl@scratch.catspoiler.org:/usr/obj/usr/src/sys/GENERICSMB  i386
> 
> # cat GENERICSMB
> include 	GENERIC
> 
> nocpu		I486_CPU
> nocpu		I586_CPU
> 
> options 	EXT2FS			# ext2 Filesystem
> 
> options 	BREAK_TO_DEBUGGER
> options 	ALT_BREAK_TO_DEBUGGER
> options 	DEBUG_VFS_LOCKS
> #options 	DEBUG_LOCKS
> #options 	KTR
> #options 	KTR_VERBOSE
> #options 	KTR_COMPILE=(KTR_EVH)
> #options 	DEVICE_POLLING
> 
> #nooptions	WITNESS_SKIPSPIN
> #nooptions	SMP
> 
> 
> What am I doing wrong?

It seems like it was some sort of kernel/userland mismatch after all.

I played around with uniq and found that
	uniq /etc/termcap
was able to fstat() the input descriptor but read() would fail with
ENOTCAPABLE.  The cap_rights_init() call seemed to be doing the right
thing, so I tried adding a call to cap_rights_get() after
cap_rights_limit() to try to observe how the kernel was interpreting the
rights.  Strangely cap_rights_get() always failed with EFAULT.  I even
tried passing an invalid fd to cap_rights_get() and still got an EFAULT
return, even though sys___cap_rights_get() validates the fd before it
ever touches the buffer.  In order to debug that, I added a printf()
call to sys___cap_rights_get().  I then went to the kernel object
directory, ran make, which only recompiled sys_capability.c and relinked
the kernel, and then ran "make reinstall".  After rebooting, both uniq
and cap_rights_get() started working as they should.

I did check the timestamps on the kernel and /usr/bin/uniq before
sending my original message and they were both recent.  I also build
both world and the kernel using a script that does both, so I know that
they were both rebuilt before being installed.  The only thing I can
think of is that maybe I forgot to reboot to bring up the new kernel.

Sigh ...




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