Bug 46352 - [patch] login(1) open file descriptors and signal handling in the child login process
Summary: [patch] login(1) open file descriptors and signal handling in the child login...
Status: Closed Unable to Reproduce
Alias: None
Product: Base System
Classification: Unclassified
Component: bin (show other bugs)
Version: 4.7-STABLE
Hardware: Any Any
: Normal Affects Only Me
Assignee: freebsd-bugs mailing list
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2002-12-18 11:40 UTC by Oleg V. Naumann
Modified: 2018-12-03 23:15 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Oleg V. Naumann 2002-12-18 11:40:01 UTC
	Child login process in STABLE leaves open file descriptors associated with terminal
	and has some problems with signals handling.

Fix: 

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.--tYA5dsN9aEAqgvIUw5bAkqDXsTVyY1hgys6prqTmZcKTlnNX
Content-Type: text/plain; name="file.diff"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment; filename="file.diff"

--- /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);
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
Comment 1 Jilles Tjoelker freebsd_committer 2015-01-21 23:12:57 UTC
Although I doubt pppd is still in use in 2015, the change to login made for bug 183495 may be helpful for this bug as well.
Comment 2 Jilles Tjoelker freebsd_committer 2018-12-03 23:15:35 UTC
I suspect the setup of the original report is no longer in use; something has been fixed about it as well.