From nobody@FreeBSD.org  Thu Jul 12 02:31:04 2012
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52])
	by hub.freebsd.org (Postfix) with ESMTP id 1BD8A1065672
	for <freebsd-gnats-submit@FreeBSD.org>; Thu, 12 Jul 2012 02:31:04 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from red.freebsd.org (red.freebsd.org [IPv6:2001:4f8:fff6::22])
	by mx1.freebsd.org (Postfix) with ESMTP id 0737A8FC15
	for <freebsd-gnats-submit@FreeBSD.org>; Thu, 12 Jul 2012 02:31:04 +0000 (UTC)
Received: from red.freebsd.org (localhost [127.0.0.1])
	by red.freebsd.org (8.14.4/8.14.4) with ESMTP id q6C2V3uT000108
	for <freebsd-gnats-submit@FreeBSD.org>; Thu, 12 Jul 2012 02:31:03 GMT
	(envelope-from nobody@red.freebsd.org)
Received: (from nobody@localhost)
	by red.freebsd.org (8.14.4/8.14.4/Submit) id q6C2V34N000106;
	Thu, 12 Jul 2012 02:31:03 GMT
	(envelope-from nobody)
Message-Id: <201207120231.q6C2V34N000106@red.freebsd.org>
Date: Thu, 12 Jul 2012 02:31:03 GMT
From: Arnaud Lacombe <lacombar@gmail.com>
To: freebsd-gnats-submit@FreeBSD.org
Subject: kenv(1) output is unreadable
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>Number:         169796
>Category:       bin
>Synopsis:       kenv(1) output is unreadable
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Thu Jul 12 02:40:00 UTC 2012
>Closed-Date:    Thu Jul 12 08:05:59 UTC 2012
>Last-Modified:  Mon Jul 16 01:20:07 UTC 2012
>Originator:     Arnaud Lacombe
>Release:        many.
>Organization:
n/a
>Environment:
FreeBSD coltar 9.0-STABLE FreeBSD 9.0-STABLE
>Description:
Output of kenv(1) is not escaped to be safely usable on terminals. Depending their content, variable value might end up being interpreted as terminal command. On 9.0-stable, we ends up having the following being output:

LINES="24"
ansi_caption[1]="ESC[1mBESC[37moot ESC[1m[ENTER]ESC[37m"
ansi_caption[2]="ESC[1mEscESC[37mape to loader prompt"
ansi_caption[4]="ESC[1mAESC[37mCPI Support: ESC[34;1mDisabledESC[37m"
ansi_caption[5]="Boot Safe ESC[1mMESC[37mode: ESC[34;1mNOESC[37m"
ansi_caption[6]="Boot ESC[1mSESC[37mingle User: ESC[34;1mNOESC[37m"
ansi_caption[7]="Boot ESC[1mVESC[37merbose: ESC[34;1mNOESC[37m"
bootfile="kernel"
comconsole_speed="115200"
console="comconsole"
currdev="disk0p2:"

Of course, ESC are not escaped and result in kenv(1)'s being unreadable.
>How-To-Repeat:
# kenv
>Fix:
escape variable content not to be interpreted as terminal command.

>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->closed 
State-Changed-By: jh 
State-Changed-When: Thu Jul 12 07:58:02 UTC 2012 
State-Changed-Why:  
Fixed in head (r228985) and stable/9 (r230219). stable/8 is not affected. 

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

From: Arnaud Lacombe <lacombar@gmail.com>
To: bug-followup@FreeBSD.org, lacombar@gmail.com
Cc:  
Subject: Re: bin/169796: kenv(1) output is unreadable
Date: Thu, 12 Jul 2012 10:01:19 -0400

 No, it is not resolved. The problem is not whatever piece of the
 bootloader script setting a variable, the problem is kenv(1) not
 properly escaping the variable's content.
 
 Please re-open.

From: Arnaud Lacombe <lacombar@gmail.com>
To: FreeBSD-gnats-submit@freebsd.org, freebsd-bugs@freebsd.org
Cc:  
Subject: Re: misc/169796: kenv(1) output is unreadable
Date: Fri, 13 Jul 2012 11:53:50 -0400

 How shall I ask this ? Please, re-open this issue.
 
 kenv(1) must escape control character, at least when STDOUT_FILENO is
 a terminal.
 
 Thanks,
  - Arnaud

From: Arnaud Lacombe <lacombar@gmail.com>
To: FreeBSD-gnats-submit@freebsd.org, freebsd-bugs@freebsd.org
Cc: Jaakko Heinonen <jh@freebsd.org>
Subject: Re: misc/169796: kenv(1) output is unreadable
Date: Sun, 15 Jul 2012 21:16:00 -0400

 Hi,
 
 I guess this is yet another example of FreeBSD's developer total lack
 of consideration for users.
 
 jh@, you were wrong in your decision to close PR169796. Killing the
 trigger a behavior does not fix the behavior itself, merely hide it.
 
 Thanks for your refusal to discuss the technical details of the issue.
 
 Please re-open the issue.
 
  - Arnaud
 
 On Fri, Jul 13, 2012 at 11:53 AM, Arnaud Lacombe <lacombar@gmail.com> wrote:
 > How shall I ask this ? Please, re-open this issue.
 >
 > kenv(1) must escape control character, at least when STDOUT_FILENO is
 > a terminal.
 >
 > Thanks,
 >  - Arnaud
>Unformatted:
