LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Red Hat
User Name
Password
Red Hat This forum is for the discussion of Red Hat Linux.

Notices


Reply
  Search this Thread
Old 04-07-2016, 02:16 AM   #1
louigi600
Member
 
Registered: Dec 2013
Location: Italy
Distribution: Slackware
Posts: 635
Blog Entries: 20

Rep: Reputation: 81
Odd behavior after accidental shutdown from within chroot container


I'm experiencing a really wired thing on a server where I run several chroot containers.
On one of them I issued accidentally a
Code:
shutdown -h now
which made the entire server shutdown, but that's not the odd thing !
What's puzzling me is that, on that one container where I ran the accidental shutdown, upon taking down sshd within it, all the sshd daemons go down (in the other containers and on the server itself).
The other containers don't do that and after recreating the damaged container it's working normally again.

The sshd for each container, and for the server itself, are all bound to separate IP address and the /var/run/sshd.pid in each container has the correct pid in it (including the container that misbehaved). The init script for sshd (/etc/init.d/sshd) are all identical.
In fact the chroot containers are all created as a minimal subset of the host OS itself and since the issue I've removed init and shutdown from the containers (that had crept in dew to dependencies requiring stuff from upstart package).

Has anyone got any idea why it was happening ?

Last edited by louigi600; 04-07-2016 at 02:18 AM.
 
Old 04-14-2016, 07:27 AM   #2
louigi600
Member
 
Registered: Dec 2013
Location: Italy
Distribution: Slackware
Posts: 635

Original Poster
Blog Entries: 20

Rep: Reputation: 81
I got it: RHEL 6 sshd script arbitrarily kills all sshd if it's asked to stop sshd daemon when system is going into runlevel 0 or 6.
Running the "shutdown" from within the container will put in it's utmp runlevel 0 or 6 (depending on whether you halt or reboot) which will then never get updated in the container .... hence the sshd script will always determine that the system is going down and thus kill all sshd .... having proc bind mounted lets the container kill all the other sshd.


Code:
stop()
{
        echo -n $"Stopping $prog: "
        killproc -p $PID_FILE $SSHD
        RETVAL=$?
        # if we are in halt or reboot runlevel kill all running sessions
        # so the TCP connections are closed cleanly
        if [ "x$runlevel" = x0 -o "x$runlevel" = x6 ] ; then
            trap '' TERM
            killall $prog 2>/dev/null
            trap TERM
        fi
        [ $RETVAL -eq 0 ] && rm -f $lockfile
        echo
}
and "strace runlevel" reveals :
Code:
open("/var/run/utmp", O_RDONLY|O_CLOEXEC) = 3

I should be able to give myself good reputation for answering my own difficult questions !

Last edited by louigi600; 04-14-2016 at 08:00 AM.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] BASH: Odd behavior gearge Programming 11 09-08-2011 10:19 AM
How can Firefox 5 remember open tabs in case of an accidental shutdown? LAPIII General 1 08-19-2011 03:19 PM
Odd CD Light Behavior pdgardin Linux - General 1 08-06-2006 10:30 PM
Container/Dir/File encryption ofr chroot jail The_JinJ Linux - Security 4 12-17-2005 11:40 AM
RH 6.2 ... odd behavior jubal Linux - Networking 3 02-27-2001 09:04 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Red Hat

All times are GMT -5. The time now is 06:24 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration