Files
one/share/ssh/bin/ssh-socks-cleaner
T
Petr OspalýandVlastimil Holer a96de2f14a F #1473: Update SSH config and sockets (#4733)
* F #1473: Update SSH config and sockets

- install files via install.sh script
- replace crontab with systemd timer
- update opennebula.service dependency
- move ssh master sockets from ~oneadmin to /run/one/ssh-socks
- modify ssh wrapper to not use external programs but only bash builtins
- update ssh configs

Signed-off-by: Petr Ospalý <pospaly@opennebula.io>

* F #1473: Update SSH config and sockets

* F #1473: Update SSH config and sockets

* F #1473: Update SSH wrapper

- rename SSH_USE_MASTER_SOCK to SSH_OPT_CONTROL_MASTER
- change the logic of this directive to be a value of the SSH
  'ControlMaster' option (default is 'auto')
- delete the SSH_USE_MASTER_SOCK from opennebula.service (not needed
  anymore)

Signed-off-by: Petr Ospalý <pospaly@opennebula.io>

Co-authored-by: Vlastimil Holer <vholer@opennebula.io>
2020-05-15 18:51:04 +02:00

46 lines
2.3 KiB
Bash
Executable File

#!/bin/sh
# -------------------------------------------------------------------------- #
# Copyright 2002-2020, OpenNebula Project, OpenNebula Systems #
# #
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
# not use this file except in compliance with the License. You may obtain #
# a copy of the License at #
# #
# http://www.apache.org/licenses/LICENSE-2.0 #
# #
# Unless required by applicable law or agreed to in writing, software #
# distributed under the License is distributed on an "AS IS" BASIS, #
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
# See the License for the specific language governing permissions and #
# limitations under the License. #
#--------------------------------------------------------------------------- #
##############################################################################
# WARNING: The arguments of the 'find' command below must be aligned with
# 'ControlPath' and 'ControlPersist' options in oneadmin's SSH configuration
# (/var/lib/one/.ssh/config) otherwise it will not have the desired effect!
##############################################################################
# This script enforce the cleanup of all oneadmin's SSH master sockets for the
# persistent connections when they reach their age of one minute. It as a
# workaround to a race condition inside the OpenSSH which occurs during the
# closing of the master sockets.
# Possibly related to: https://bugzilla.mindrot.org/show_bug.cgi?id=3067
find /var/run/one/ssh-socks \
-maxdepth 1 \
-type s \
-name 'ctl-M-*.sock' \
-mmin +1 \
-print | while read -r sockname ; do
# atomic operation - no other ssh client should be disrupted
mv -f "$sockname" "$sockname"~todelete
# stop the multiplexing ('this' is just unnecessary gibberish)
ssh -S "$sockname"~todelete -O stop this </dev/null >/dev/null
# delete the old socket
rm -f "$sockname"~todelete
done