Skip to content

Commit e7be0cd

Browse files
authored
Merge pull request #751 from JacobBarthelmeh/scp
SCP hang with interop fix
2 parents 555449c + d5d45ca commit e7be0cd

File tree

2 files changed

+116
-0
lines changed

2 files changed

+116
-0
lines changed

.github/workflows/scp-test.yml

Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
name: wolfSSH SCP Test
2+
3+
on:
4+
push:
5+
branches: [ '*' ]
6+
pull_request:
7+
branches: [ '*' ]
8+
9+
concurrency:
10+
group: ${{ github.workflow }}-${{ github.ref }}
11+
cancel-in-progress: true
12+
13+
jobs:
14+
create_matrix:
15+
runs-on: ubuntu-latest
16+
outputs:
17+
versions: ${{ steps.json.outputs.versions }}
18+
steps:
19+
- name: Create wolfSSL version matrix
20+
id: json
21+
run: |
22+
current=`curl -s https://api.github.com/repos/wolfssl/wolfssl/releases | grep tag_name | cut -d : -f 2,3 | tr -d \" | tr -d , | tr -d ' ' | head -1`
23+
last=`curl -s https://api.github.com/repos/wolfssl/wolfssl/releases | grep tag_name | cut -d : -f 2,3 | tr -d \" | tr -d , | tr -d ' ' | head -2 | tail -1`
24+
VERSIONS=$(echo "[ \"master\", \"$current\", \"$last\" ]")
25+
echo "wolfSSL versions found: $VERSIONS"
26+
echo "versions=$VERSIONS" >> $GITHUB_OUTPUT
27+
28+
build_wolfssl:
29+
needs: create_matrix
30+
strategy:
31+
fail-fast: false
32+
matrix:
33+
os: [ ubuntu-latest ]
34+
wolfssl: ${{ fromJson(needs.create_matrix.outputs['versions']) }}
35+
name: Build wolfssl
36+
runs-on: ${{ matrix.os }}
37+
timeout-minutes: 4
38+
steps:
39+
- name: Checking cache for wolfssl
40+
uses: actions/cache@v4
41+
id: cache-wolfssl
42+
with:
43+
path: build-dir/
44+
key: wolfssh-sshd-wolfssl-${{ matrix.wolfssl }}-${{ matrix.os }}
45+
lookup-only: true
46+
47+
- name: Checkout, build, and install wolfssl
48+
if: steps.cache-wolfssl.outputs.cache-hit != 'true'
49+
uses: wolfSSL/actions-build-autotools-project@v1
50+
with:
51+
repository: wolfssl/wolfssl
52+
ref: ${{ matrix.wolfssl }}
53+
path: wolfssl
54+
configure: --enable-all
55+
check: false
56+
install: true
57+
58+
build_wolfssh:
59+
needs:
60+
- build_wolfssl
61+
- create_matrix
62+
strategy:
63+
fail-fast: false
64+
matrix:
65+
os: [ ubuntu-latest ]
66+
wolfssl: ${{ fromJson(needs.create_matrix.outputs['versions']) }}
67+
name: Build and test wolfsshd
68+
runs-on: ${{ matrix.os }}
69+
timeout-minutes: 10
70+
steps:
71+
- name: Checking cache for wolfssl
72+
uses: actions/cache@v4
73+
with:
74+
path: build-dir/
75+
key: wolfssh-sshd-wolfssl-${{ matrix.wolfssl }}-${{ matrix.os }}
76+
fail-on-cache-miss: true
77+
78+
- uses: actions/checkout@v4
79+
with:
80+
path: wolfssh/
81+
82+
- name: autogen
83+
working-directory: ./wolfssh/
84+
run: ./autogen.sh
85+
86+
- name: configure
87+
working-directory: ./wolfssh/
88+
run : |
89+
./configure --enable-all LDFLAGS="-L${{ github.workspace }}/build-dir/lib" CPPFLAGS="-I${{ github.workspace }}/build-dir/include -DWOLFSSH_NO_FPKI -DWOLFSSH_NO_SFTP_TIMEOUT -DMAX_PATH_SZ=120"
90+
91+
- name: make
92+
working-directory: ./wolfssh/
93+
run: make
94+
95+
- name: Setup test user
96+
run: sudo useradd -p password jak
97+
98+
# This is a regression test for a reported hang with SCP file transfer.
99+
# Verifying the error from a bad directory is propogated back, and
100+
# that the direcotry/file is not created. To account for potential
101+
# hanging of the operation, the timeout is set to 1 minute.
102+
- name: Run SCP example test
103+
timeout-minutes: 1
104+
working-directory: ./wolfssh/
105+
run: |
106+
mkdir /tmp/wolfssh
107+
echo "test file" > /tmp/wolfssh/test.txt
108+
./examples/scpclient/wolfscp -p 22 -u jak -P password -H 127.0.0.1 -L /tmp/wolfssh/test.txt:/tmp/non_existent_folder/ || true
109+
# check that the directory and file do not exist
110+
[ ! -d /tmp/non_existent_folder ]
111+
[ ! -f /tmp/non_existent_folder/test.txt ]

src/wolfscp.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1572,6 +1572,11 @@ int ReceiveScpConfirmation(WOLFSSH* ssh)
15721572
"scp error: peer sent error confirmation (code: %d)",
15731573
msg[0]);
15741574
ret = WS_FATAL_ERROR;
1575+
1576+
/* SCP peer signaled a failure, propogate the error back
1577+
* to the caller. If not set here WS_CHAN_RXD could be
1578+
* returned. */
1579+
ssh->error = ret;
15751580
break;
15761581
}
15771582
}

0 commit comments

Comments
 (0)