Arch Linux

Please read this before reporting a bug:
https://wiki.archlinux.org/title/Bug_reporting_guidelines

Do NOT report bugs when a package is just outdated, or it is in the AUR. Use the 'flag out of date' link on the package page, or the Mailing List.

REPEAT: Do NOT report bugs for outdated packages!
Tasklist

FS#32043 - [netcfg] Add support to logout connected users on a server reboot (systemd)

Attached to Project: Arch Linux
Opened by John (graysky) - Wednesday, 17 October 2012, 20:40 GMT
Last edited by Jouke Witteveen (jouke) - Saturday, 27 October 2012, 15:13 GMT
Task Type Bug Report
Category Packages: Core
Status Closed
Assigned To Jouke Witteveen (jouke)
Architecture All
Severity Medium
Priority Normal
Reported Version
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 2
Private No

Details

Description: My server is running netcfg+ifplugd using an ethernet-static configuration; systemd is bring it up via the /usr/lib/systemd/system/net-auto-wired.service just fine, but if I tell the box to reboot to shutdown, all ssh connections hang. Under sysv, the NETWORK_PERSIST="yes" in /etc/rc.conf fixed this via a hook. Support for this via netcfg would be great.

Additional info:
* package version(s) 2.8.11-2

Steps to reproduce:
Ask a systemd server to reboot or shutdown while connect via ssh to it.

% sudo shutdown -h now
<<terminal hangs>>
This task depends upon

Closed by  Jouke Witteveen (jouke)
Saturday, 27 October 2012, 15:13 GMT
Reason for closing:  Won't implement
Comment by Jouke Witteveen (jouke) - Wednesday, 17 October 2012, 20:56 GMT
Why not use PRE_DOWN for this? You can write a script in the style of the firewall example (/usr/share/doc/netcfg/contrib/iptables.hook) and even enable it per interface (put PRE_DOWN in /etc/network.d/interfaces/[interface]) if you don't want to specify it per profile (your profiles may override it).
Comment by John (graysky) - Thursday, 18 October 2012, 19:02 GMT
Excellent idea, jouke. I took a stab at it in the attached file but isn't very elegant and on my box, it doesn't work. I chmodded it to +x and placed in the location in its header. Upon issuing a `shutdown -r now` to the server, my terminal just hung... other times it hung for 10-20 sec and then reported " Write failed: Broken pipe." This is in contrast to when I execute the function manually. Then after about 3 sec, the connection is simply closed.

# /bin/ps aux | /usr/bin/grep ssh | /usr/bin/grep -v grep | /usr/bin/awk {'print $2'} | /usr/bin/xargs -r kill
Connection to mars closed by remote host.
Connection to mars closed.
   eth0 (0.2 KiB)
Comment by Jouke Witteveen (jouke) - Thursday, 18 October 2012, 19:10 GMT
I assume you have tested that line outside netcfg.
Does it work when placed literally in PRE_DOWN for a given profile?
PRE_DOWN='/bin/ps aux | /usr/bin/grep ssh | /usr/bin/grep -v grep | /usr/bin/awk {"print $2"} | /usr/bin/xargs -r kill'
Comment by John (graysky) - Thursday, 18 October 2012, 19:22 GMT
Yes! This is excellent. Three questions:

1) The string of commands proposed isn't really elegant. Is there a more "correct" method that you're aware of to accomplish this? I spend a good 45 minutes googling sshd-native commands to force a logout of all users but came up empty.

2) Perhaps we can edit the included example profiles to include this or a similar line so users do not need to rely on the wiki and have these in the Arch package. How do you feel about this solution?

3) Is this really a netcfg issue? Perhaps that or a similar command should really go into the sshd.service or .socket files?
Comment by John (graysky) - Friday, 26 October 2012, 19:25 GMT
@jouke - Any thoughts on #1 and #2?
Comment by Jouke Witteveen (jouke) - Saturday, 27 October 2012, 14:01 GMT
1) Try more googling, there are some alternatives. pkill seems to do it.

2) No, this is typical wiki material.

3) No, it should be part of ExecStop in the sshd service. In fact, if sshd behaves nicely, the spawned instances would belong to the right process group. All that would matter in that case, is that sshd is brought down before netcfg.
Comment by John (graysky) - Saturday, 27 October 2012, 15:10 GMT
@jouke - Thanks for the pkill suggestion+ExecStop. Works wonderfully. Safe to close this task I think.

https://bugs.archlinux.org/task/32251

Loading...