From 61d2162429b1f0f4b00095ac5f041071a810a1fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wojciech=20Nag=C3=B3rski?= Date: Wed, 19 Apr 2023 14:09:27 +0200 Subject: [PATCH 1/4] Remove old target frameworks --- docker/DockerFile | 4 +++- src/SshNetTests/Common/AsyncSocketListener.cs | 7 ++++++- src/SshNetTests/SshNetTests.csproj | 9 +++++---- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/docker/DockerFile b/docker/DockerFile index 7bdec7f..c7e79ca 100644 --- a/docker/DockerFile +++ b/docker/DockerFile @@ -4,11 +4,13 @@ COPY --chown=root:root server/ssh /etc/ssh/ COPY --chown=root:root server/script /opt/sshnet COPY --chown=sshnet:sshnet user/sshnet /home/sshnet/.ssh -RUN apk add --no-cache syslog-ng && \ +RUN apk update && apk upgrade --no-cache && \ + apk add --no-cache syslog-ng && \ # install and configure sshd apk add --no-cache openssh && \ # install openssh-server-pam to allow for keyboard-interactive authentication apk add --no-cache openssh-server-pam && \ + dos2unix /etc/ssh/* && \ chmod 400 /etc/ssh/ssh*key && \ sed -i 's/#PasswordAuthentication yes/PasswordAuthentication yes/' /etc/ssh/sshd_config && \ sed -i 's/#LogLevel\s*INFO/LogLevel DEBUG3/' /etc/ssh/sshd_config && \ diff --git a/src/SshNetTests/Common/AsyncSocketListener.cs b/src/SshNetTests/Common/AsyncSocketListener.cs index d446408..581010c 100644 --- a/src/SshNetTests/Common/AsyncSocketListener.cs +++ b/src/SshNetTests/Common/AsyncSocketListener.cs @@ -87,9 +87,14 @@ private void AcceptCallback(IAsyncResult ar) var state = new SocketStateObject(handler); handler.BeginReceive(state.Buffer, 0, state.Buffer.Length, 0, ReadCallback, state); } + catch (SocketException) + { + // when the socket is closed, an SocketException is thrown since .NET 5 + // by Socket.EndAccept(IAsyncResult) + } catch (ObjectDisposedException) { - // when the socket is closed, an ObjectDisposedException is thrown + // when the socket is closed, an ObjectDisposedException is thrown on old .NET Framework // by Socket.EndAccept(IAsyncResult) } } diff --git a/src/SshNetTests/SshNetTests.csproj b/src/SshNetTests/SshNetTests.csproj index 1fd8329..27f1b8d 100644 --- a/src/SshNetTests/SshNetTests.csproj +++ b/src/SshNetTests/SshNetTests.csproj @@ -2,12 +2,12 @@ Library - net45;netcoreapp2.1;netcoreapp3.1 + net472;net7.0 false true - + TRACE;FEATURE_MSTEST_DATATEST;FEATURE_SOCKET_EAP;FEATURE_ENCODING_ASCII;FEATURE_THREAD_SLEEP;FEATURE_THREAD_THREADPOOL @@ -28,16 +28,17 @@ - + - + + From b7972a83fe43b2248baf32131d6c68d0f173e11e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wojciech=20Nag=C3=B3rski?= Date: Wed, 19 Apr 2023 14:12:50 +0200 Subject: [PATCH 2/4] Fix --- src/SshNetTests/SshNetTests.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/SshNetTests/SshNetTests.csproj b/src/SshNetTests/SshNetTests.csproj index 27f1b8d..4886001 100644 --- a/src/SshNetTests/SshNetTests.csproj +++ b/src/SshNetTests/SshNetTests.csproj @@ -32,7 +32,7 @@ - + From 99ff8e439ed7046479c37a3ed3f6f4005a60b6af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wojciech=20Nag=C3=B3rski?= Date: Wed, 19 Apr 2023 14:35:46 +0200 Subject: [PATCH 3/4] Update SshNetBenchmarks.csproj --- src/SshNetBenchmarks/SshNetBenchmarks.csproj | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/SshNetBenchmarks/SshNetBenchmarks.csproj b/src/SshNetBenchmarks/SshNetBenchmarks.csproj index 81223fb..f1878dc 100644 --- a/src/SshNetBenchmarks/SshNetBenchmarks.csproj +++ b/src/SshNetBenchmarks/SshNetBenchmarks.csproj @@ -7,11 +7,12 @@ - + + From 0abdeb4e297a4c59e5010ea0bdc00365a2d84b0d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wojciech=20Nag=C3=B3rski?= Date: Mon, 15 May 2023 06:15:38 +0200 Subject: [PATCH 4/4] Add comments --- docker/DockerFile | 3 +++ 1 file changed, 3 insertions(+) diff --git a/docker/DockerFile b/docker/DockerFile index c7e79ca..f0853ff 100644 --- a/docker/DockerFile +++ b/docker/DockerFile @@ -10,6 +10,7 @@ RUN apk update && apk upgrade --no-cache && \ apk add --no-cache openssh && \ # install openssh-server-pam to allow for keyboard-interactive authentication apk add --no-cache openssh-server-pam && \ + # make sure scripts and keys have unix (LF) line endings dos2unix /etc/ssh/* && \ chmod 400 /etc/ssh/ssh*key && \ sed -i 's/#PasswordAuthentication yes/PasswordAuthentication yes/' /etc/ssh/sshd_config && \ @@ -27,6 +28,7 @@ RUN apk update && apk upgrade --no-cache && \ adduser -D sshnet && \ passwd -u sshnet && \ echo 'sshnet:ssh4ever' | chpasswd && \ + # make sure scripts and keys have unix (LF) line endings dos2unix /home/sshnet/.ssh/* && \ chown -R sshnet:sshnet /home/sshnet && \ chmod -R 700 /home/sshnet/.ssh && \ @@ -36,6 +38,7 @@ RUN apk update && apk upgrade --no-cache && \ passwd -u sshnetadm && \ echo 'sshnetadm:ssh4ever' | chpasswd && \ addgroup sshnetadm sudo && \ + # make sure scripts and keys have unix (LF) line endings dos2unix /opt/sshnet/* && \ # install shadow package; we use chage command in this package to expire/unexpire password of the sshnet user apk add --no-cache shadow && \