From owner-svn-src-all@FreeBSD.ORG Wed Jul 16 02:13:57 2014 Return-Path: Delivered-To: svn-src-all@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 964505D1; Wed, 16 Jul 2014 02:13:57 +0000 (UTC) Received: from shxd.cx (unknown [64.201.244.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 7E3702EBA; Wed, 16 Jul 2014 02:13:57 +0000 (UTC) Received: from 50-196-156-133-static.hfc.comcastbusiness.net ([50.196.156.133]:49949 helo=THEMADHATTER) by shxd.cx with esmtpsa (TLSv1:AES128-SHA:128) (Exim 4.77 (FreeBSD)) (envelope-from ) id 1X71t2-0002i4-TS; Tue, 15 Jul 2014 05:31:12 -0700 From: To: "'Mateusz Guzik'" , "'Bryan Drewery'" References: <201407150218.s6F2Itj8044531@svn.freebsd.org> <53C56BE9.9050304@FreeBSD.org> <20140715191553.GA31990@dft-labs.eu> In-Reply-To: <20140715191553.GA31990@dft-labs.eu> Subject: RE: svn commit: r268641 - head/usr.sbin/service Date: Tue, 15 Jul 2014 19:13:44 -0700 Message-ID: <011a01cfa09b$928b4710$b7a1d530$@FreeBSD.org> MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Mailer: Microsoft Outlook 15.0 Thread-Index: AQHOLaehGAwRwf+WS/ay3he7mLcSrwIdqyYRAXy+1UmbiAS0cA== Content-Language: en-us Sender: devin@shxd.cx Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, 'Devin Teske' , src-committers@freebsd.org X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 16 Jul 2014 02:13:57 -0000 > -----Original Message----- > From: owner-src-committers@freebsd.org [mailto:owner-src- > committers@freebsd.org] On Behalf Of Mateusz Guzik > Sent: Tuesday, July 15, 2014 12:16 PM > To: Bryan Drewery > Cc: Devin Teske; src-committers@freebsd.org; svn-src-all@freebsd.org; = svn- > src-head@freebsd.org > Subject: Re: svn commit: r268641 - head/usr.sbin/service >=20 > On Tue, Jul 15, 2014 at 12:59:05PM -0500, Bryan Drewery wrote: > > On 7/14/2014 9:18 PM, Devin Teske wrote: > > > Author: dteske > > > Date: Tue Jul 15 02:18:55 2014 > > > New Revision: 268641 > > > URL: http://svnweb.freebsd.org/changeset/base/268641 > > > > > > Log: > > > Fix an issue with service(8) where utilities such as screen(1) = and tmux(1) > > > would behave differently when utilizing rc-script was invoked = manually > vs. > > > service(8). The issue being that these utilities require the = TERM environ > > > variable to be set and service(8) was not passing it down. > > > > > > Reported by: Michael Dexter > > > PR: bin/191869 > > > Reviewed by: allanjude > > > MFC after: 3 days > > > X-MFC-to: stable/10, stable/9 > > > > > > Modified: > > > head/usr.sbin/service/service.sh > > > > > > Modified: head/usr.sbin/service/service.sh > > > > = =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > > > --- head/usr.sbin/service/service.sh Tue Jul 15 01:03:29 2014 > (r268640) > > > +++ head/usr.sbin/service/service.sh Tue Jul 15 02:18:55 2014 > (r268641) > > > @@ -139,7 +139,7 @@ cd / > > > for dir in /etc/rc.d $local_startup; do > > > if [ -x "$dir/$script" ]; then > > > [ -n "$VERBOSE" ] && echo "$script is located in $dir" > > > - exec env -i HOME=3D/ PATH=3D/sbin:/bin:/usr/sbin:/usr/bin > $dir/$script $* > > > + exec env -i HOME=3D/ PATH=3D/sbin:/bin:/usr/sbin:/usr/bin > TERM=3D"$TERM" $dir/$script $* > > > fi > > > done > > > > > > > > > > Hm, I'm not sure about this. The "behaves differently" is exactly = the > > reason for service(8). It runs with a clean environment such as the = boot > > does. Running an rc script without service(8) will give wrong = behavior > > in many scripts that do not match boot-time behavior. > > >=20 > Indeed, the whole point is to NOT inherit anything from calling = process. >=20 I would argue that not all programs are going to like having a nearly empty environment. Things like TERM and SHLVL at the very least should be passed (after-all, the boot process takes place on [a] a terminal and [b] in a shell). Blatting out the environment feels rude and non-UNIXy. UNIX programs can, and should expect at a minimum to be able to interrogate the environment they are running within -- destroying all vestiges of that environment purely for the sake of saying "it's clean" seems counter to the UNIX pathos. > > As far as I can tell, TERM is not set on boot. So the rc script = would > > also not work on boot. So this change is wrong. > > >=20 > Yes, but maybe there is a sensible default that could be used? >=20 I argue that the sensible default should be what was inherited. Otherwise, if you want to (for example) change said default from cons25 to xterm (just as a well-known example) then you risk having to make the change in more than one place (rather than letting it trickle down from ttys(5)). Furthermore, while I can believe that TERM is not set for rc.d scripts (because I tested it), I see no reason why this has to be. By the time the boot process has started, we have invoked init(8) and it has processed ttys(5) and we should know what type of terminal we are on. Since we ought to know this information, why _not_ pass it along to the boot scripts so that, god forbid, a boot script might be able to handle different terminal types appropriately (read: serial console situation). The alternative would be that the startup script would have to invoke some C code utilizing isatty(3) etc. on stdin which seems like more of a kludge than just revealing $TERM. > Alternatively, one would have to fixup rc scripts using tmux to do > what's best for them. >=20 The only thing that will work as a patch to an rc-script to allow said = rc- script to utilize tmux or screen would be to manually set the TERM variable to some guessed value. Considering the less-than-desired outcome from using the wrong TERM variable, it seems obvious to me that this is a less-than-desired solution (versus patching service(8)). > Either, the change as it is looks wrong. Please revert for the time = being. >=20 Reverting doesn't help anyone. I'm in-favor of modifying the boot process to reveal $TERM -- thus allowing scripts that rely on $TERM to be able (as is the intention) to function as-desired in all = situations. I will agree that the patch is not holistic in-that there still exists = the edge-case that boot-scripts utilizing screen and/or tmux will still fail because the boot-process does not reveal $TERM, but I think reverting the progress made so far ignores the larger picture (that honestly... = not providing $TERM is wrong). --=20 Devin