<p dir="ltr">Hi Lennart,</p>
<p dir="ltr">Thank you, I will reconsider this design.</p>
<p dir="ltr">John Lin</p>
<br><div class="gmail_quote"><div dir="ltr">Lennart Poettering <<a href="mailto:lennart@poettering.net">lennart@poettering.net</a>> 於 2018年1月24日 週三 19:41 寫道:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">On Di, 26.12.17 01:39, 林自均 (<a href="mailto:johnlinp@gmail.com" target="_blank">johnlinp@gmail.com</a>) wrote:<br>
<br>
> Hi folks,<br>
><br>
> I am trying to achieve:<br>
><br>
> # systemctl start sshd-shell.service (1)<br>
> # systemctl start sshd-sftp.service (2)<br>
> # systemctl stop sshd-shell.service (3)<br>
> # systemctl stop sshd-sftp.service (4)<br>
><br>
> Before the command (1), sshd is not running. By typing (1),<br>
> /etc/sshd_config is configured to accept ssh shell connections but no sftp<br>
> connections, and then start sshd. By typing (2), /etc/sshd_config is<br>
> configured to accept sftp connections too, and sshd is reloaded. By typing<br>
> (3), /etc/sshd_config is configured to refuse ssh shell connection, and<br>
> sshd is reloaded again. By typing (4), sshd will be stopped.<br>
<br>
Quite frankly, this is not really in line with how systemd services<br>
are supposed to be used. They are supposed to wrap running processes,<br>
but not wrap configuration applied to others really.<br>
<br>
But anyway, of course, it's up to you how to make use of this stuff...<br>
<br>
> The current problem is that I don't know if there is a better way to<br>
> achieve this. For example, I have to sleep 1 second before reloading<br>
> sshd-core.service in sshd-shell.service because otherwise sshd didn't setup<br>
> the signal handler for SIGHUP and will terminate itself. Or systemd doesn't<br>
> suggest such use case?<br>
<br>
Yes, it's not really in-line with how this stuff was designed...<br>
<br>
That said, I am pretty sure there's something wrong with your<br>
sshd-core.service: the unit should not be considered up before the<br>
daemon process is fully running, and that includes having set up<br>
SIGHUP handlers properly.<br>
<br>
Most likely the Type= stuff is not set up correctly in that unit (or<br>
sshd is broken and doesn't set things up fully before reporting its<br>
startup being complete).<br>
<br>
Lennart<br>
<br>
--<br>
Lennart Poettering, Red Hat<br>
</blockquote></div>