From owner-freebsd-bugs Wed Dec 18 3:40: 6 2002 Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 53FD737B401 for ; Wed, 18 Dec 2002 03:40:04 -0800 (PST) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id 8816543ED1 for ; Wed, 18 Dec 2002 03:40:03 -0800 (PST) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.12.6/8.12.6) with ESMTP id gBIBe3x3099821 for ; Wed, 18 Dec 2002 03:40:03 -0800 (PST) (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.12.6/8.12.6/Submit) id gBIBe3as099820; Wed, 18 Dec 2002 03:40:03 -0800 (PST) Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id A960A37B401 for ; Wed, 18 Dec 2002 03:37:18 -0800 (PST) Received: from core.zp.ua (core.zp.ua [193.108.112.7]) by mx1.FreeBSD.org (Postfix) with ESMTP id A831D43ED4 for ; Wed, 18 Dec 2002 03:37:16 -0800 (PST) (envelope-from oleg@core.zp.ua) Received: from core.zp.ua (oleg@localhost [127.0.0.1]) by core.zp.ua with ESMTP id gBIBb5af050363 for ; Wed, 18 Dec 2002 13:37:05 +0200 (EET) (envelope-from oleg@core.zp.ua) Received: (from oleg@localhost) by core.zp.ua id gBIBb53K050362; Wed, 18 Dec 2002 13:37:05 +0200 (EET) Message-Id: <200212181137.gBIBb53K050362@core.zp.ua> Date: Wed, 18 Dec 2002 13:37:05 +0200 (EET) From: "Oleg V. Nauman" Reply-To: "Oleg V. Nauman" To: FreeBSD-gnats-submit@FreeBSD.org X-Send-Pr-Version: 3.113 Subject: bin/46352: Open file descriptors and signal handling in the child login process Sender: owner-freebsd-bugs@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.org >Number: 46352 >Category: bin >Synopsis: Open file descriptors and signal handling in the child login process >Confidential: no >Severity: serious >Priority: medium >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Wed Dec 18 03:40:01 PST 2002 >Closed-Date: >Last-Modified: >Originator: Oleg V. Nauman >Release: FreeBSD 4.7-STABLE i386 >Organization: ReIS Ltd. >Environment: >Description: Child login process in STABLE leaves open file descriptors associated with terminal and has some problems with signals handling. >How-To-Repeat: Log in on the terminal line, start pppd and then kill -HUP pppd This leaves some errors in the ppp log file, such as: pppd: ioctl (PPPIOCGFLAGS): Inappropriate ioctl for device pppd: ioctl (PPPIOCGFLAGS): Inappropriate ioctl for device pppd: ioctl(PPPIOCSASYNCMAP): Inappropriate ioctl for device pppd: Couldn't restore device fd flags: Inappropriate ioctl for device pppd: ioctl(TIOCSETD): Inappropriate ioctl for device pppd: tcsetattr: Inappropriate ioctl for device >Fix: --- /usr/src/usr.bin/login/login.c Thu Mar 14 18:16:16 2002 +++ login.c Mon Dec 16 22:45:05 2002 @@ -632,6 +633,17 @@ } else if (pid) { /* parent - wait for child to finish, then cleanup session */ + fpurge(stdin); + close(STDIN_FILENO); + fpurge(stdout); + close(STDOUT_FILENO); + fpurge(stderr); + close(STDERR_FILENO); + (void)signal(SIGHUP, SIG_IGN); + (void)signal(SIGALRM, SIG_IGN); + (void)signal(SIGQUIT, SIG_IGN); + (void)signal(SIGINT, SIG_IGN); + wait(NULL); PAM_END; exit(0); As I understand, this is NOT better fix for signal handling problem. But it works for me and leaves for kill(0, SIG...) from pppd much smaller window for signal handling races in the current process group. >Release-Note: >Audit-Trail: >Unformatted: Environment: System: FreeBSD core.zp.ua 4.7-STABLE FreeBSD 4.7-STABLE #0: Mon Oct 28 21:50:40 EET 2002 root@core.zp.ua:/usr/src/sys/compile/core i386 To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-bugs" in the body of the message