From owner-freebsd-pkgbase@freebsd.org Mon Dec 4 19:48:32 2017 Return-Path: Delivered-To: freebsd-pkgbase@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id BE8D4E6917B for ; Mon, 4 Dec 2017 19:48:32 +0000 (UTC) (envelope-from freebsd-rwg@pdx.rh.CN85.dnsmgr.net) Received: from pdx.rh.CN85.dnsmgr.net (br1.CN84in.dnsmgr.net [69.59.192.140]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id AA1377664A; Mon, 4 Dec 2017 19:48:32 +0000 (UTC) (envelope-from freebsd-rwg@pdx.rh.CN85.dnsmgr.net) Received: from pdx.rh.CN85.dnsmgr.net (localhost [127.0.0.1]) by pdx.rh.CN85.dnsmgr.net (8.13.3/8.13.3) with ESMTP id vB4JmTQS047634; Mon, 4 Dec 2017 11:48:29 -0800 (PST) (envelope-from freebsd-rwg@pdx.rh.CN85.dnsmgr.net) Received: (from freebsd-rwg@localhost) by pdx.rh.CN85.dnsmgr.net (8.13.3/8.13.3/Submit) id vB4JmTRp047633; Mon, 4 Dec 2017 11:48:29 -0800 (PST) (envelope-from freebsd-rwg) From: "Rodney W. Grimes" Message-Id: <201712041948.vB4JmTRp047633@pdx.rh.CN85.dnsmgr.net> Subject: Re: Recent issue with pkg base missing setuid In-Reply-To: <20171204185956.GH22326@FreeBSD.org> To: Glen Barber Date: Mon, 4 Dec 2017 11:48:29 -0800 (PST) CC: Kris Moore , freebsd-pkgbase@freebsd.org X-Mailer: ELM [version 2.4ME+ PL121h (25)] MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII X-BeenThere: freebsd-pkgbase@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: "Packaging the FreeBSD base system." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 04 Dec 2017 19:48:32 -0000 > On Mon, Dec 04, 2017 at 10:46:56AM -0800, Rodney W. Grimes wrote: > > > On Mon, Dec 04, 2017 at 12:46:37PM -0500, Kris Moore wrote: > > > > On 12/04/2017 11:37, Brad Davis wrote: > > > > > On Mon, Dec 4, 2017, at 09:25 AM, Kris Moore wrote: > > > > >> Anybody else noticed a recent regression (say past month or so) where > > > > >> pkg base of latest HEAD is now failing to throw setuid on some files? We > > > > >> saw it at first because /sbin/shutdown lost its setuid bit, so users > > > > >> can't shutdown the box. I rolled back pkg to 1.10.1 which was working, > > > > >> and that didn't seem to make a difference. Now I suspect something in > > > > >> HEAD itself changed, but for the life of me can't find where. > > > > > Hey Kris, > > > > > > > > > > Can you look at the plist file and see if it is correctly flagging the > > > > > file there? > > > > > > > > > > > > > > > Regards, > > > > > Brad Davis > > > > > _______________________________________________ > > > > > freebsd-pkgbase@freebsd.org mailing list > > > > > https://lists.freebsd.org/mailman/listinfo/freebsd-pkgbase > > > > > To unsubscribe, send any mail to "freebsd-pkgbase-unsubscribe@freebsd.org" > > > > > > > > Here's what I have in the plist: > > > > > > > > @(root,operator,04554,) /sbin/shutdown > > > > > > > > I'll note that ping/ping6 also have similar, and they install setuid > > > > properly: > > > > > > > > @(root,wheel,04555,) /sbin/ping > > > > @(root,wheel,04555,) /sbin/ping6 > > > > > > > > Here's what I have in the pkg tarball: > > > > > > > > # tar tvf FreeBSD-runtime-12.0.s20171204170123.txz | grep shutdown > > > > hr-sr-xr-- 0 root operator 0 Dec 4 17:05 /sbin/shutdown link to > > > > /sbin/poweroff > > > > > > > > # tar tvf FreeBSD-runtime-12.0.s20171204170123.txz | grep poweroff > > > > -r-xr-xr-- 0 root wheel 15440 Dec 4 17:05 /sbin/poweroff > > > > hr-sr-xr-- 0 root operator 0 Dec 4 17:05 /sbin/shutdown link to > > > > /sbin/poweroff > > > > > > > > > > > > And installing it again sure enough gives version without setuid: > > > > > > > > # pkg-static add -f FreeBSD-runtime-12.0.s20171204170123.txz > > > > Installing FreeBSD-runtime-12.0.s20171204170123... > > > > package FreeBSD-runtime is already installed, forced install > > > > Extracting FreeBSD-runtime-12.0.s20171204170123: 100% > > > > > > > > [root@chimera] > > > > /usr/obj/usr/src/repo/FreeBSD:12:amd64/12.0.s20171204170123# ls -al > > > > /sbin/shutdown > > > > -r-xr-xr-- 2 root wheel 15440 Dec 4 17:05 /sbin/shutdown > > > > > > > > > > I think this is the problem. I believe /sbin/poweroff should be a hard > > > link to /sbin/shutdown. Meaning, the links are reversed, so the setuid > > > bit is lost because poweroff is not installed with the setuid bit. > > > > > > The only thing I can think of so far is r325859, which sorts the METALOG > > > to ensure metadata reproducibility. > > > > > > Glen > > > > > > > I do not believe that order is at issue here at all, or it shouldnt be, > > once the files are hardlinked any chown/chmod effects the one inode > > used by both files. > > > > It does appear to be the problem, because the files are packaged > alphabetically now. In a repository from September, I see: > > % tar tvf FreeBSD-runtime-12.0*.txz | grep -E '/sbin/(poweroff|shutdown)' > -r-sr-xr-- 0 root operator 15864 Sep 27 15:40 /sbin/shutdown > hr-xr-xr-- 0 root wheel 0 Sep 27 15:40 /sbin/poweroff link to /sbin/shutdown > > In a more recent repository, I see: > > % tar tvf FreeBSD-runtime-12.0*.txz | grep -E '/sbin/(poweroff|shutdown)' > -r-xr-xr-- 0 root wheel 15864 Nov 15 15:28 /sbin/poweroff > hr-sr-xr-- 0 root operator 0 Nov 15 15:28 /sbin/shutdown link to /sbin/poweroff > > Glen Then something is wrong with pkg cause it should be doing the chmod/chown after processing the tar extract, anything else is gona be error prone. As Kris showed in the ls -i output the files have the same inode, so the hard linking worked correctly, and the chown/chmod has failed. Note that NEITHER file got set, so that kinda blows the order is important hypothisis out of the water. -- Rod Grimes rgrimes@freebsd.org