Re: uniq busted?

From: Don Lewis <truckman_at_FreeBSD.org>
Date: Wed, 11 Sep 2013 04:52:47 -0700 (PDT)
On 11 Sep, To: freebsd-current_at_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_at_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 ...
Received on Wed Sep 11 2013 - 09:52:55 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:40:41 UTC