Tiny Core Linux

Tiny Core Extensions => TCE Bugs => Topic started by: hiro on March 07, 2013, 12:42:11 PM

Title: openssh init.d restart
Post by: hiro on March 07, 2013, 12:42:11 PM
Sometimes my sshd doesn't restart properly. that's quite bad especially for ssh cause that's the only way of accessing some machines.
I suspect it's because pidof tries to kill not only the main sshd, but also processes from logins that might not even exist any more after killing the main sshd, so pidof gives back bad status.

stop(){                                                                                                             
   kill $(pidof sshd)                                                                                               
}                                                                                                                   
                                                                                                                     
restart(){                                                                                                           
   if pidof sshd >/dev/null; then                                                                                   
      stop && start                                                                                                 
   else                         
      start                     
   fi                           
}                               
Title: Re: openssh init.d restart
Post by: Len on May 06, 2013, 09:45:45 PM
I ran into this problem today and made a change in my openssh init.d script:

stop()
{
   pkill /usr/local/sbin/sshd
}

the only draw backs of this solution are that:
1. we assume pkill is available to us.
2. the full pathname is hardcoded -- although it appears the rest of the init.d script assumes the same.

hope that helps
Title: Re: openssh init.d restart
Post by: gerald_clark on May 07, 2013, 12:58:06 AM
Why?
pkill is in /usr/bin and is part of busybox.
Title: Re: openssh init.d restart
Post by: Len on May 07, 2013, 01:31:12 AM
Hi gerald_clark,

I'm not sure if your "Why?" was directed at my comments or not, but if it was I was merely stating some assumptions I made and pointing out possible faults to my suggestion so that Hiro had some information to make a decision on using my suggestion or not.

Len
Title: Re: openssh init.d restart
Post by: Rich on May 07, 2013, 01:34:57 AM
Hi Len
Gerald_clark was merely pointing out that  pkill  is always available.