Commit 7d175dff authored by Dom Sekotill's avatar Dom Sekotill
Browse files

Removed SSH variable runtime

This trips 95% of the problems with the SSH variable config. Getting
rid of it will mean less visibility of bugs, but honestly the variable
config is only meant to handle a tiny number of edge cases, not fail
regularily.
parent 1910877e
Loading
Loading
Loading
Loading
+4 −26
Original line number Diff line number Diff line
@@ -29,29 +29,12 @@ config_sed() {
	esac
}

runtime() {
	if [ -n "${XDG_RUNTIME_DIR:-}" ] && [ -d "$XDG_RUNTIME_DIR" ]; then
		RUNTIME="$XDG_RUNTIME_DIR/ssh"
	elif [ -d /tmp ]; then
		RUNTIME=/tmp/user/`id -u`/ssh
	else
		RUNTIME=$HOME/.ssh/.runtime
	fi

	if ! [ -d "$RUNTIME" ]; then
		mkdir -p "$RUNTIME"
		chmod 0750 `dirname $RUNTIME`
	fi >&2
}

make_config() {
	[ -z "${SSH_CONFIG-}" ] || return 0

	ssh_version && runtime && config_sed || return 1
	ssh_version && config_sed || return 1

	PLATFORM_UNIQ="$PLATFORM:$KERNEL:`hostname -f 2>/dev/null || hostname`:$SSH_MAJOR.$SSH_MINOR"
	PLATFORM_ID=`echo "$PLATFORM_UNIQ" | md5sum | cut -f1 -d' '`
	SSH_CONFIG="$RUNTIME/config-$PLATFORM_ID"
	SSH_CONFIG=$HOME/.ssh/configs/$PLATFORM.$KERNEL.$SSH_MAJOR.$SSH_MINOR.config

	if [ -f "$SSH_CONFIG" ] &&
		[ "$SSH_CONFIG" -nt ~/.ssh/config ] &&
@@ -61,11 +44,12 @@ make_config() {
		return
	fi

	mkdir -p `dirname $SSH_CONFIG`

	cat ~/.ssh/config ~/.ssh/config.local 2>/dev/null |
		sed >"$SSH_CONFIG" "
			`rule_unix_sockets`
			`rule_canonisation`
			`rule_runtime`
		"

	# Ensure the GPG agent is running if installed
@@ -93,9 +77,3 @@ rule_canonisation() {
		echo '/Canonical/d;'
	fi
}

rule_runtime() {
	# Replace RUNTIME with the value of the RUNTIME variable
	[ -n "$RUNTIME" ] || die "RUNTIME not set"
	echo "s!${SED_WORD_START}RUNTIME${SED_WORD_END}!${RUNTIME-.}!g;"
}
+4 −2
Original line number Diff line number Diff line
@@ -4,11 +4,13 @@ authorized_keys
# local IDs
id*

# runtime directory
.runtime
# socket and config directories
socks:*/
configs/

# legacy runtime
.config.*
.runtime

# local configs
config.local
+2 −2
Original line number Diff line number Diff line
@@ -25,9 +25,9 @@ Host 192.168.* 10.* *.lan *.local localhost
	CheckHostIp no


# === Conection Sharing ===
# === Connection Sharing ===
# Use connection sharing for any host that does not explicitly block it.
Host *
	ControlMaster auto
	ControlPath RUNTIME/%r@%h:%p
	ControlPath %d/.ssh/socks:%l/%r@%h:%p
	ControlPersist 2h