From nobody@FreeBSD.org  Tue Mar 11 22:36:26 2014
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1])
	(using TLSv1 with cipher ADH-AES256-SHA (256/256 bits))
	(No client certificate requested)
	by hub.freebsd.org (Postfix) with ESMTPS id 94E4A5DB
	for <freebsd-gnats-submit@FreeBSD.org>; Tue, 11 Mar 2014 22:36:26 +0000 (UTC)
Received: from cgiserv.freebsd.org (cgiserv.freebsd.org [IPv6:2001:1900:2254:206a::50:4])
	(using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits))
	(No client certificate requested)
	by mx1.freebsd.org (Postfix) with ESMTPS id 82060C4B
	for <freebsd-gnats-submit@FreeBSD.org>; Tue, 11 Mar 2014 22:36:26 +0000 (UTC)
Received: from cgiserv.freebsd.org ([127.0.1.6])
	by cgiserv.freebsd.org (8.14.8/8.14.8) with ESMTP id s2BMaQFw009096
	for <freebsd-gnats-submit@FreeBSD.org>; Tue, 11 Mar 2014 22:36:26 GMT
	(envelope-from nobody@cgiserv.freebsd.org)
Received: (from nobody@localhost)
	by cgiserv.freebsd.org (8.14.8/8.14.8/Submit) id s2BMaQAI009093;
	Tue, 11 Mar 2014 22:36:26 GMT
	(envelope-from nobody)
Message-Id: <201403112236.s2BMaQAI009093@cgiserv.freebsd.org>
Date: Tue, 11 Mar 2014 22:36:26 GMT
From: Adam McDougall <mcdouga9@egr.msu.edu>
To: freebsd-gnats-submit@FreeBSD.org
Subject: sysrc silently and unexpectedly bootstraps pkg
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>Number:         187458
>Category:       bin
>Synopsis:       sysrc(8) silently and unexpectedly bootstraps pkg
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    dteske
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Tue Mar 11 22:40:00 UTC 2014
>Closed-Date:    
>Last-Modified:  Wed Apr 16 01:47:49 UTC 2014
>Originator:     Adam McDougall
>Release:        10.0-STABLE
>Organization:
>Environment:
FreeBSD build10 10.0-STABLE FreeBSD 10.0-STABLE #0 r262298: Fri Feb 21 18:28:26 EST 2014     root@build10:/usr/obj/usr/src/sys/BUILD10  amd64
>Description:
Recently I began setting up some fresh FreeBSD installs and I used sysrc to enable some services in /etc/rc.conf that I would use later on.  From a fresh install, I have no ports or packages installed.  A few steps later I ran 'pkg bootstrap' and it told me pkg was already installed.  Huh?  The first time I thought I was crazy, the second time I tracked it down.  When sysrc runs, it runs some subroutines from /usr/share/bsdconfig/common.subr which runs  "ASSUME_ALWAYS_YES=1 pkg -vv" which will bootstrap pkg silently if it can, because it is not installed and it was told to assume yes.  In my environment, the end result is not problematic but it is confusing and very unexpected, especially the brief delay during the first execution while it bootstraps.
>How-To-Repeat:
on a system without pkg installed but with sysrc, run:

script output.log sh -x `which sysrc` test=yes

In output.log you'll see sysrc call /usr/share/bsdconfig/common.subr which runs "ASSUME_ALWAYS_YES=1 pkg -vv"   which will bootstrap pkg silently.

to check status, but if pkg is not already bootstrapped, it will silently attempt to and continue on after a short delay if it succeeds.
>Fix:
No specific fix suggestion.  If there is a way to check if pkg is actually installed and not just the /usr/sbin/pkg stub, maybe the full "ASSUME_ALWAYS_YES=1 pkg -vv" execution could be avoided.  Checking for /usr/local/sbin/pkg may be insufficient if some has it in a custom path.

>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->dteske 
Responsible-Changed-By: eadler 
Responsible-Changed-When: Tue Mar 11 23:07:09 UTC 2014 
Responsible-Changed-Why:  
Over to maintainer. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=187458 

From: <dteske@FreeBSD.org>
To: <bug-followup@FreeBSD.org>, <mcdouga9@egr.msu.edu>
Cc: "'Devin Teske'" <dteske@freebsd.org>
Subject: Re: bin/187458: sysrc silently and unexpectedly bootstraps pkg
Date: Fri, 21 Mar 2014 11:59:38 -0700

 During the run-up to 10.0-RELEASE, we had to switch bsdconfig
 over to using pkgng, but at the time pkgng did not support the
 flags it now does for getting the pkg ABI.
 
 While pkg has a "-N" flag for checking whether pkgng is boot-
 strapped, it will take some work to make sure we have a usable
 ABI in the pre-bootstrap stage.
 -- 
 Devin
 
 _____________
 The information contained in this message is proprietary and/or confidential. If you are not the intended recipient, please: (i) delete the message and all copies; (ii) do not disclose, distribute or use the message in any manner; and (iii) notify the sender immediately. In addition, please be aware that any message addressed to our domain is subject to archiving and review by persons other than the intended recipient. Thank you.
>Unformatted:
