Skip to content

Commit 513acf8

Browse files
committed
Maintenance - go1.19 and deps
1 parent adc89ae commit 513acf8

File tree

104 files changed

+1582
-1614
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

104 files changed

+1582
-1614
lines changed

CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ endif()
3737
set(DEST_DIR "${PROJECT_SOURCE_DIR}/bin")
3838
message(STATUS "Installation directory: ${DEST_DIR}")
3939

40-
set(GO_MIN_REQURED_VERSION 1.17)
40+
set(GO_MIN_REQURED_VERSION 1.19)
4141
find_package(Go ${GO_MIN_REQURED_VERSION} REQUIRED)
4242
find_package(Git REQUIRED)
4343

@@ -60,7 +60,7 @@ endif()
6060
# Project version number
6161
set(PRJ_VERSION_Major "1")
6262
set(PRJ_VERSION_Minor "6")
63-
set(PRJ_VERSION_Patch "1")
63+
set(PRJ_VERSION_Patch "2")
6464

6565
if (EXISTS "${PROJECT_SOURCE_DIR}/.git" AND IS_DIRECTORY "${PROJECT_SOURCE_DIR}/.git")
6666
execute_process(COMMAND ${CMAKE_SOURCE_DIR}/cmake/githash.sh ${GIT_EXECUTABLE}

README.md

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -141,18 +141,14 @@ Options:
141141

142142
## WSL 2 compatibility
143143

144-
At the moment AF_UNIX interop does not seems to be working with WSL2 VMs. Hopefully this will be sorted out eventually. Meantime there is an easy workaround (proposed by multiple people) which does not use wsl-ssh-agent.exe at all and relies on combination of linux socat tool from your distribution and [npiperelay.exe](https://github.com/jstarks/npiperelay). Put npiperelay.exe somewhere on devfs for interop to work its magic (I have `winhome ⇒ /mnt/c/Users/rupor` in my $HOME directory for that) and add following lines in your .bashrc/.zshrc:
144+
At the moment AF_UNIX interop does not seems to be working with WSL2 VMs. Hopefully this will be sorted out eventually. Meantime there is an easy workaround (proposed by multiple people) which does not use wsl-ssh-agent.exe at all and relies on combination of linux socat tool from your distribution and [npiperelay.exe](https://github.com/jstarks/npiperelay). For example put `npiperelay.exe` on devfs for interop to work its magic (I have `winhome ⇒ /mnt/c/Users/rupor`, copy [wsl-ssh-agent-relay](docs/wsl-ssh-agent-relay) into your `~/.local/bin directory`, and add following 2 lines to your .bashrc/.zshrc file:
145145

146146
```bash
147-
export SSH_AUTH_SOCK=$HOME/.ssh/agent.sock
148-
ss -a | grep -q $SSH_AUTH_SOCK
149-
if [ $? -ne 0 ]; then
150-
rm -f $SSH_AUTH_SOCK
151-
( setsid socat UNIX-LISTEN:$SSH_AUTH_SOCK,fork EXEC:"$HOME/winhome/.wsl/npiperelay.exe -ei -s //./pipe/openssh-ssh-agent",nofork & ) >/dev/null 2>&1
152-
fi
147+
${HOME}/.local/bin/wsl-ssh-agent-relay start
148+
export SSH_AUTH_SOCK=${HOME}/.ssh/wsl-ssh-agent.sock
153149
```
154150

155-
You *really* have to be on WSL 2 in order for this to work - if you see errors like `Cannot open netlink socket: Protocol not supported` - you probably are under WSL 1 and should not use this workaround. Run `wsl.exe -l --all -v` to check what is going on. When on WSL 2 make sure that socat is installed and npiperelay.exe is on windows partition and path is right. For convinience I will be packing pre-build npiperelay.exe with wsl-ssh-agent. Please also ensure that `socat` is installed: `sudo apt install socat`.
151+
You *really* have to be on WSL 2 in order for this to work - if you see errors like `Cannot open netlink socket: Protocol not supported` - you probably are under WSL 1 and should not use this workaround. Run `wsl.exe -l --all -v` to check what is going on. When on WSL 2 make sure that socat is installed and npiperelay.exe is on windows partition and path is right. For convenience I will be packing pre-build npiperelay.exe with wsl-ssh-agent. Please also ensure that `socat` is installed: `sudo apt install socat`.
156152

157153
## Example
158154

docs/wsl-ssh-agent-relay

Lines changed: 163 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,163 @@
1+
#!/bin/bash
2+
3+
#### Add following lines to your shell rc file (.zshrc .bashrc)
4+
# ${HOME}/.local/bin/wsl-ssh-agent-relay start
5+
# export SSH_AUTH_SOCK=${HOME}/.ssh/wsl-ssh-agent.sock
6+
7+
# For debugging startup problems uncomment next line
8+
# exec 2> >(tee -a -i "$HOME/error.log")
9+
10+
#### Assuming ~/winhome links to %USERPROFILE on Windows side
11+
RELAY_BIN="${HOME}/winhome/.wsl/npiperelay.exe"
12+
13+
PIDFILE="${HOME}/.ssh/wsl-ssh-agent-relay.pid"
14+
WSL_AGENT_SSH_SOCK="${HOME}/.ssh/wsl-ssh-agent.sock"
15+
16+
log() {
17+
echo >&2 "$@"
18+
}
19+
20+
is_pid_running() {
21+
if [[ -z "$1" ]]; then
22+
return 1
23+
fi
24+
ps -p "$1" >/dev/null
25+
return $?
26+
}
27+
28+
_cleanup() {
29+
log "Cleaning up relay to ${WSL_AGENT_SSH_SOCK}..."
30+
if is_pid_running "${SOCAT_WSL_AGENT_SSH_PID}"; then
31+
kill -SIGTERM "${SOCAT_WSL_AGENT_SSH_PID}" || log "Failed."
32+
fi
33+
}
34+
35+
die() {
36+
if [[ -n "$1" ]]; then
37+
log "$1"
38+
fi
39+
log "Exiting."
40+
exit 1
41+
}
42+
43+
usage() {
44+
log "Usage: wsl-ssh-agent-relay [OPTIONS] COMMAND"
45+
log ""
46+
log " SUMMARY: Relay Windows openssh named pipe to local SSH socket in order to integrate WSL2 and host."
47+
log " To debug use foreground command"
48+
log ""
49+
log " OPTIONS:"
50+
log " -h|--help this page"
51+
log ""
52+
log " -v|--verbose verbose mode"
53+
log ""
54+
log " COMMAND: start, stop, foreground"
55+
}
56+
57+
fg_opts() {
58+
FG_OPTS=()
59+
# Generate opts for passing it to foreground version
60+
if [[ -n "$VERBOSE" ]]; then
61+
FG_OPTS+=("-v")
62+
fi
63+
}
64+
65+
main() {
66+
67+
POSITIONAL=()
68+
VERBOSE=""
69+
while (($# > 0)); do
70+
case "$1" in
71+
-v | --verbose)
72+
VERBOSE="ENABLED"
73+
shift # shift once since flags have no values
74+
;;
75+
76+
-h | --help)
77+
usage
78+
exit 0
79+
;;
80+
81+
*) # unknown flag/switch
82+
POSITIONAL+=("$1")
83+
shift
84+
if [[ "${#POSITIONAL[@]}" -gt 1 ]]; then
85+
usage
86+
die
87+
fi
88+
;;
89+
esac
90+
done
91+
92+
set -- "${POSITIONAL[@]}" # restore positional params
93+
94+
if [[ -z "$VERBOSE" ]]; then
95+
QUIET="QUIET"
96+
fi
97+
98+
case "${POSITIONAL[0]}" in
99+
start)
100+
fg_opts
101+
start-stop-daemon --start --oknodo --pidfile "${PIDFILE}" --name wsl-ssh-agent-r --make-pidfile --background --startas "$0" ${VERBOSE:+--verbose} ${QUIET:+--quiet} -- foreground "${FG_OPTS[@]}"
102+
;;
103+
104+
stop)
105+
start-stop-daemon --pidfile "${PIDFILE}" --stop --remove-pidfile ${VERBOSE:+--verbose} ${QUIET:+--quiet}
106+
;;
107+
108+
status)
109+
start-stop-daemon --pidfile "${PIDFILE}" --status ${VERBOSE:+--verbose} ${QUIET:+--quiet}
110+
local result=$?
111+
case $result in
112+
0) log "$0 is running" ;;
113+
1 | 3) log "$0 is not running" ;;
114+
4) log "$0 unable to determine status" ;;
115+
esac
116+
return $result
117+
;;
118+
119+
foreground)
120+
relay
121+
;;
122+
123+
*)
124+
usage
125+
die
126+
;;
127+
esac
128+
}
129+
130+
relay() {
131+
132+
trap _cleanup EXIT
133+
134+
[[ -f "${RELAY_BIN}" ]] || die "Unable to access ${RELAY_BIN}"
135+
136+
if pgrep -fx "^ssh-agent\s.+" >/dev/null; then
137+
log "Killing previously started local ssh-agent..."
138+
SSH_AGENT_PID="$(pidof ssh-agent)" ssh-agent -k >/dev/null 2>&1
139+
fi
140+
141+
if [ -e "${WSL_AGENT_SSH_SOCK}" ]; then
142+
log "WSL has been shutdown ungracefully, leaving garbage behind"
143+
rm "${WSL_AGENT_SSH_SOCK}"
144+
fi
145+
146+
socat UNIX-LISTEN:"\"${WSL_AGENT_SSH_SOCK}\"",fork EXEC:"\"\'${RELAY_BIN}\' -ei -s \'//./pipe/openssh-ssh-agent\'\"",nofork 1>/dev/null 2>&1 &
147+
SOCAT_WSL_AGENT_SSH_PID="$!"
148+
if ! is_pid_running "${SOCAT_WSL_AGENT_SSH_PID}"; then
149+
log "Relay for ${SOCAT_WSL_AGENT_SSH_PID} failed"
150+
return 1
151+
fi
152+
log "Relay is running with PID: ${SOCAT_WSL_AGENT_SSH_PID}"
153+
154+
log -n "Polling remote ssh-agent..."
155+
SSH_AUTH_SOCK="${WSL_AGENT_SSH_SOCK}" ssh-add -L >/dev/null 2>&1 || die "[$?] Failure communicating with ssh-agent"
156+
log "OK"
157+
158+
# Everything checks, we are ready for actions
159+
log "Entering wait..."
160+
wait ${SOCAT_WSL_AGENT_SSH_PID}
161+
}
162+
163+
main "$@"

go.mod

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
module github.com/rupor-github/wsl-ssh-agent
22

3-
go 1.17
3+
go 1.19
44

55
require (
66
github.com/Microsoft/go-winio v0.5.2
77
github.com/allan-simon/go-singleinstance v0.0.0-20210120080615-d0997106ab37
8-
github.com/rupor-github/gclpr v1.2.1
9-
golang.org/x/sys v0.0.0-20220422013727-9388b58f7150
10-
honnef.co/go/tools v0.3.0
8+
github.com/rupor-github/gclpr v1.2.2
9+
golang.org/x/sys v0.0.0-20220818161305-2296e01440c6
10+
honnef.co/go/tools v0.3.3
1111
)
1212

1313
require (
@@ -16,7 +16,6 @@ require (
1616
github.com/skratchdot/open-golang v0.0.0-20200116055534-eef842397966 // indirect
1717
golang.org/x/crypto v0.0.0-20220411220226-7b82a4e95df4 // indirect
1818
golang.org/x/exp/typeparams v0.0.0-20220218215828-6cf2b201936e // indirect
19-
golang.org/x/mod v0.6.0-dev.0.20220106191415-9b9b3d81d5e3 // indirect
20-
golang.org/x/tools v0.1.11-0.20220316014157-77aa08bb151a // indirect
21-
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect
19+
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4 // indirect
20+
golang.org/x/tools v0.1.11-0.20220513221640-090b14e8501f // indirect
2221
)

go.sum

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ github.com/atotto/clipboard v0.1.4 h1:EH0zSVneZPSuFR11BlR9YppQTVDbh5+16AmcJi4g1z
88
github.com/atotto/clipboard v0.1.4/go.mod h1:ZY9tmq7sm5xIbd9bOK4onWV4S6X0u6GY7Vn0Yu86PYI=
99
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
1010
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
11-
github.com/rupor-github/gclpr v1.2.1 h1:LaByitXVainoz4Ezm0uHwQv7KGB5ZookyyItX+8XcrU=
12-
github.com/rupor-github/gclpr v1.2.1/go.mod h1:PyhH4EaDiGk8gkTOqzlFzidhqCgb4WAMVoRRU7Gbn38=
11+
github.com/rupor-github/gclpr v1.2.2 h1:oAm6iaky59y29D6gysBDkTdGjLkg+hnTUILzCyA9g4E=
12+
github.com/rupor-github/gclpr v1.2.2/go.mod h1:PyhH4EaDiGk8gkTOqzlFzidhqCgb4WAMVoRRU7Gbn38=
1313
github.com/sirupsen/logrus v1.7.0/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0=
1414
github.com/skratchdot/open-golang v0.0.0-20200116055534-eef842397966 h1:JIAuq3EEf9cgbU6AtGPK4CTG3Zf6CKMNqf0MHTggAUA=
1515
github.com/skratchdot/open-golang v0.0.0-20200116055534-eef842397966/go.mod h1:sUM3LWHvSMaG192sy56D9F7CNvL7jUJVXoqM1QKLnog=
@@ -18,15 +18,13 @@ golang.org/x/crypto v0.0.0-20220411220226-7b82a4e95df4 h1:kUhD7nTDoI3fVd9G4ORWrb
1818
golang.org/x/crypto v0.0.0-20220411220226-7b82a4e95df4/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
1919
golang.org/x/exp/typeparams v0.0.0-20220218215828-6cf2b201936e h1:qyrTQ++p1afMkO4DPEeLGq/3oTsdlvdH4vqZUBWzUKM=
2020
golang.org/x/exp/typeparams v0.0.0-20220218215828-6cf2b201936e/go.mod h1:AbB0pIl9nAr9wVwH+Z2ZpaocVmF5I4GyWCDIsVjR0bk=
21-
golang.org/x/mod v0.6.0-dev.0.20220106191415-9b9b3d81d5e3 h1:kQgndtyPBW/JIYERgdxfwMYh3AVStj88WQTlNDi2a+o=
22-
golang.org/x/mod v0.6.0-dev.0.20220106191415-9b9b3d81d5e3/go.mod h1:3p9vT2HGsQu2K1YbXdKPJLVgG5VJdoTa1poYQBtP1AY=
21+
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4 h1:6zppjxzCulZykYSLyVDYbneBfbaBIQPYMevg0bEwv2s=
22+
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
2323
golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
2424
golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
25-
golang.org/x/sys v0.0.0-20220422013727-9388b58f7150 h1:xHms4gcpe1YE7A3yIllJXP16CMAGuqwO2lX1mTyyRRc=
26-
golang.org/x/sys v0.0.0-20220422013727-9388b58f7150/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
27-
golang.org/x/tools v0.1.11-0.20220316014157-77aa08bb151a h1:ofrrl6c6NG5/IOSx/R1cyiQxxjqlur0h/TvbUhkH0II=
28-
golang.org/x/tools v0.1.11-0.20220316014157-77aa08bb151a/go.mod h1:Uh6Zz+xoGYZom868N8YTex3t7RhtHDBrE8Gzo9bV56E=
29-
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE=
30-
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
31-
honnef.co/go/tools v0.3.0 h1:2LdYUZ7CIxnYgskbUZfY7FPggmqnh6shBqfWa8Tn3XU=
32-
honnef.co/go/tools v0.3.0/go.mod h1:vlRD9XErLMGT+mDuofSr0mMMquscM/1nQqtRSsh6m70=
25+
golang.org/x/sys v0.0.0-20220818161305-2296e01440c6 h1:Sx/u41w+OwrInGdEckYmEuU5gHoGSL4QbDz3S9s6j4U=
26+
golang.org/x/sys v0.0.0-20220818161305-2296e01440c6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
27+
golang.org/x/tools v0.1.11-0.20220513221640-090b14e8501f h1:OKYpQQVE3DKSc3r3zHVzq46vq5YH7x8xpR3/k9ixmUg=
28+
golang.org/x/tools v0.1.11-0.20220513221640-090b14e8501f/go.mod h1:SgwaegtQh8clINPpECJMqnxLv9I09HLqnW3RMqW0CA4=
29+
honnef.co/go/tools v0.3.3 h1:oDx7VAwstgpYpb3wv0oxiZlxY+foCpRAwY7Vk6XpAgA=
30+
honnef.co/go/tools v0.3.3/go.mod h1:jzwdWgg7Jdq75wlfblQxO4neNaFFSvgc1tD5Wv8U0Yw=

vendor/golang.org/x/sys/AUTHORS

Lines changed: 0 additions & 3 deletions
This file was deleted.

vendor/golang.org/x/sys/CONTRIBUTORS

Lines changed: 0 additions & 3 deletions
This file was deleted.

vendor/golang.org/x/sys/execabs/execabs.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/golang.org/x/sys/execabs/execabs_go118.go

Lines changed: 12 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/golang.org/x/sys/execabs/execabs_go119.go

Lines changed: 15 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/golang.org/x/sys/windows/exec_windows.go

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/golang.org/x/sys/windows/registry/key.go

Lines changed: 0 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/golang.org/x/sys/windows/setupapi_windows.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)