Bug 1029 - SIGTERM and cleanup of wtmp files
Summary: SIGTERM and cleanup of wtmp files
Status: CLOSED FIXED
Alias: None
Product: Portable OpenSSH
Classification: Unclassified
Component: sshd (show other bugs)
Version: 4.0p1
Hardware: All All
: P2 normal
Assignee: OpenSSH Bugzilla mailing list
URL:
Keywords:
Depends on:
Blocks: 1047
  Show dependency treegraph
 
Reported: 2005-05-04 02:19 AEST by senthilkumar
Modified: 2006-10-07 11:40 AEST (History)
1 user (show)

See Also:


Attachments
SIGTERM handler for user sshd process (1.29 KB, patch)
2005-05-04 02:23 AEST, senthilkumar
no flags Details | Diff
cleanup with less code in signal handler (1.34 KB, patch)
2005-05-05 20:30 AEST, Darren Tucker
no flags Details | Diff
Patch for Protocol 2 support (1.89 KB, patch)
2005-05-12 23:41 AEST, senthilkumar
no flags Details | Diff
Updated patch (2.49 KB, patch)
2005-10-30 12:16 AEDT, Damien Miller
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description senthilkumar 2005-05-04 02:19:34 AEST
SSH is not cleaning up the wtmp files when SIGTERM is passed to user session 
process with Privilegeseparation disabled.
Comment 1 senthilkumar 2005-05-04 02:23:26 AEST
Created attachment 895 [details]
SIGTERM handler for user sshd process

The attached patch handles the SIGTERM to cleanup the wtmp files with
privilegeseparation disabled.
Comment 2 Darren Tucker 2005-05-05 20:30:36 AEST
Created attachment 897 [details]
cleanup with less code in signal handler

It's generally a bad idea to do too much in signal handlers since it's prone to
races.	(Some of the existing handlers break this rule, but we shouldn't add
any more, and should fix the existing ones if possible.)

Does the attached patch solve the problem?
Comment 3 senthilkumar 2005-05-06 19:36:24 AEST
The attachment id 897 is not cleaning the wtmp entries when SIGTERM is issued to 
user session process (Priv sep=no). My understanding is that, for Priv sep no, 
shell pid is logged for utmp/wtmp in OpenSSH code but when SIGTERM is issued, 
while doing do_cleanup() it may try to cleanup the entry for user sshd process. 
Comment 4 senthilkumar 2005-05-12 23:41:11 AEST
Created attachment 909 [details]
Patch for Protocol 2 support

The patch (id=897) works for Protocol 1 but my environment strictly adheres to
Protocol 2. I simply added the protocol 2 support and it is working fine. Let
me know if the patch has any problems. With this Patch, the problem gets solved
in HP-UX.

Also when parent process exits from the loop and while doing cleanup the
SIGCHLD handler is set to do its default for server_loop() but not in
server_loop2(). Is there any specific reason? Is such a thing necessary for
SIGTERM?
Comment 5 Damien Miller 2005-10-30 12:16:09 AEDT
Created attachment 1016 [details]
Updated patch

I think this is better: check for SIGTERM, SIGINT and SIGQUIT and only activate these signal handlers for the !use_privsep case.
Comment 6 Damien Miller 2005-10-30 12:16:59 AEDT
put this on the radar
Comment 7 Damien Miller 2005-10-31 22:47:25 AEDT
patch applied, will be in 4.3. thanks!
Comment 8 Darren Tucker 2006-10-07 11:40:04 AEST
Change all RESOLVED bug to CLOSED with the exception of the ones fixed post-4.4.