NetBSD Problem Report #47733

From campbell@mumble.net  Tue Apr  9 12:19:25 2013
Return-Path: <campbell@mumble.net>
Received: from mail.netbsd.org (mail.netbsd.org [149.20.53.66])
	by www.NetBSD.org (Postfix) with ESMTP id AA5B163F41A
	for <gnats-bugs@gnats.NetBSD.org>; Tue,  9 Apr 2013 12:19:25 +0000 (UTC)
Message-Id: <20130409121811.107C4604E7@jupiter.mumble.net>
Date: Tue,  9 Apr 2013 12:18:10 +0000 (UTC)
From: Taylor R Campbell <campbell+netbsd@mumble.net>
Reply-To: Taylor R Campbell <campbell+netbsd@mumble.net>
To: gnats-bugs@gnats.NetBSD.org
Subject: su messes with foreground process group
X-Send-Pr-Version: 3.95

>Number:         47733
>Category:       bin
>Synopsis:       su messes with foreground process group
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    bin-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Tue Apr 09 12:20:00 +0000 2013
>Last-Modified:  Mon Oct 07 07:35:00 +0000 2013
>Originator:     Taylor R Campbell <campbell+netbsd@mumble.net>
>Release:        NetBSD 6.99.17
>Organization:
>Environment:
System: NetBSD manticore.local 6.99.17 NetBSD 6.99.17 (RIAFAST) #3: Sun Mar 31 15:07:34 UTC 2013  root@manticore:/home/riastradh/netbsd/current/obj.amd64/sys/arch/amd64/compile/RIAFAST amd64
Architecture: amd64
Machine: amd64
>Description:

	su (with MKPAM=yes) messes with the foreground process group of
	its controlling terminal even if it is not in the foreground,
	with confusing consequences.

	It's not a priori clear to me why su needs to mess with the
	controlling terminal at all or leave an intermediate su process
	around until the subprocess exits, but it seems to have
	something to do with needing to bracket the subprocess by
	pam_open_session/pam_close_session.

	(We also have various crap in su to behave differently if the
	shell has `csh' in its name.  Whisky tango foxtrot?)

>How-To-Repeat:

	0# sh
	1# { su -l riastradh -c : & wait; }
	[1]   Done                    su -l riastradh -c :
	1# [1] + Stopped (tty input)     sh
	0# 

>Fix:

	Yes, please!

	Option 1: Figure out why we mess with the ctty and work around it.
	Option 2: Be more careful about the ctty state, like
	  <http://git.savannah.gnu.org/cgit/mit-scheme.git/tree/src/microcode/uxctty.c>
	(Option 3: Build with MKPAM=no...)

>Audit-Trail:
From: David Holland <dholland-bugs@netbsd.org>
To: gnats-bugs@NetBSD.org
Cc: 
Subject: Re: bin/47733: su messes with foreground process group
Date: Mon, 7 Oct 2013 07:34:15 +0000

 On Tue, Apr 09, 2013 at 12:20:01PM +0000, Taylor R Campbell wrote:
  > 	su (with MKPAM=yes) messes with the foreground process group of
  > 	its controlling terminal even if it is not in the foreground,
  > 	with confusing consequences.
  > 
  > 	It's not a priori clear to me why su needs to mess with the
  > 	controlling terminal at all or leave an intermediate su process
  > 	around until the subprocess exits, but it seems to have
  > 	something to do with needing to bracket the subprocess by
  > 	pam_open_session/pam_close_session.

 Yes. It is horribly bodgy. But at least nowadays the bogus extra
 process isn't your session leader.

 MKPAM=no is your friend unless you have some specific need for it.

 -- 
 David A. Holland
 dholland@netbsd.org

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.39 2013/11/01 18:47:49 spz Exp $
$NetBSD: gnats_config.sh,v 1.8 2006/05/07 09:23:38 tsutsui Exp $
Copyright © 1994-2007 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.