Skip to content

Commit ac85a2a

Browse files
committed
Bugfix: in config, merge groups and user-defined routes to default ones,
instead of replacing them. Add a regression test for this.
1 parent 2183b28 commit ac85a2a

File tree

7 files changed

+50
-12
lines changed

7 files changed

+50
-12
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
SSHPROXY_VERSION ?= 1.3.5
1+
SSHPROXY_VERSION ?= 1.3.6
22
SSHPROXY_GIT_URL ?= github.com/cea-hpc/sshproxy
33

44
prefix ?= /usr

misc/sshproxy.spec

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
%global debug_package %{nil}
44

55
Name: sshproxy
6-
Version: 1.3.5
6+
Version: 1.3.6
77
Release: 1%{?dist}
88
Summary: SSH proxy
99
License: CeCILL-B
@@ -51,6 +51,9 @@ install -p -m 0644 config/sshproxy.yaml %{buildroot}%{_sysconfdir}/sshproxy
5151
%{_mandir}/man8/sshproxy-replay.8*
5252

5353
%changelog
54+
* Fri Apr 09 2021 Cyril Servant <[email protected]> - 1.3.6-1
55+
- sshproxy 1.3.6
56+
5457
* Thu Mar 04 2021 Cyril Servant <[email protected]> - 1.3.5-1
5558
- sshproxy 1.3.5
5659

@@ -72,7 +75,7 @@ install -p -m 0644 config/sshproxy.yaml %{buildroot}%{_sysconfdir}/sshproxy
7275
* Thu Apr 30 2020 Cyril Servant <[email protected]> - 1.2.0-1
7376
- sshproxy 1.2.0
7477

75-
* Thu Mar 06 2020 Cyril Servant <[email protected]> - 1.1.0-1
78+
* Fri Mar 06 2020 Cyril Servant <[email protected]> - 1.1.0-1
7679
- sshproxy 1.1.0
7780

7881
* Thu Jun 06 2019 Arnaud Guignard <[email protected]> - 1.0.0-1

misc/sshproxyctl-completion.bash

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ _sshproxyctl() {
55
COMPREPLY=()
66
cur="${COMP_WORDS[COMP_CWORD]}"
77
prev="${COMP_WORDS[COMP_CWORD-1]}"
8-
commands="enable disable help show version"
8+
commands="disable enable forget help show version"
99
opts="-h -c ${commands}"
1010

1111
case "${prev}" in

pkg/utils/config.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,8 +141,9 @@ func parseSubConfig(config *Config, subconfig *subConfig) error {
141141
config.SSH.Args = subconfig.SSH.Args
142142
}
143143

144-
if subconfig.Routes != nil {
145-
config.Routes = subconfig.Routes
144+
// merge routes
145+
for service, opts := range subconfig.Routes {
146+
config.Routes[service] = opts
146147
}
147148

148149
// merge environment

test/centos-image/Dockerfile

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,14 @@ RUN set -ex \
66
&& yum -y update \
77
&& yum -y install asciidoc etcd git golang iproute make openssh-server rpm-build
88

9-
# Create centos user and group
9+
# Create centos, user1 and user2 users ; centos and user1 groups
1010
RUN set -ex \
1111
&& useradd centos \
12-
&& install -d -m0755 -o centos -g centos /home/centos/.ssh
12+
&& install -d -m0755 -o centos -g centos /home/centos/.ssh \
13+
&& useradd -G centos user1 \
14+
&& install -d -m0755 -o user1 -g user1 /home/user1/.ssh \
15+
&& useradd -g user1 -G centos user2 \
16+
&& install -d -m0755 -o user2 -g user1 /home/user2/.ssh
1317

1418
# Copy centos public key to root authorized_keys
1519
RUN set -ex && install -d -m0700 /root/.ssh
@@ -27,6 +31,17 @@ COPY --chown=centos:centos ./ssh/id_ed25519.pub /home/centos/.ssh/authorized_key
2731
COPY --chown=centos:centos ./ssh/id_ed25519* ./ssh/known_hosts /home/centos/.ssh/
2832
RUN chmod 0600 /home/centos/.ssh/id_ed25519 /home/centos/.ssh/authorized_keys
2933

34+
# Copy user1 ssh keys
35+
COPY --chown=user1:user1 ./ssh/id_ed25519.pub /home/user1/.ssh/authorized_keys
36+
COPY --chown=user1:user1 ./ssh/id_ed25519* ./ssh/known_hosts /home/user1/.ssh/
37+
RUN chmod 0600 /home/user1/.ssh/id_ed25519 /home/user1/.ssh/authorized_keys
38+
39+
# Copy user2 ssh keys
40+
COPY --chown=user2:user1 ./ssh/id_ed25519.pub /home/user2/.ssh/authorized_keys
41+
COPY --chown=user2:user1 ./ssh/id_ed25519* ./ssh/known_hosts /home/user2/.ssh/
42+
RUN chmod 0600 /home/user2/.ssh/id_ed25519 /home/user2/.ssh/authorized_keys
43+
44+
3045
# Copy etcd certificates and keys
3146
COPY ./etcd/*.pem /etc/etcd/
3247
RUN chmod 0644 /etc/etcd/ca.pem

test/centos-image/gateway.sh

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,20 @@ routes:
5454
dest: ["server2"]
5555
default:
5656
dest: ["server3"]
57+
58+
groups:
59+
user1:
60+
routes:
61+
service2:
62+
source: ["gateway1:2023"]
63+
dest: ["server2"]
64+
65+
users:
66+
user2:
67+
routes:
68+
service3:
69+
source: ["gateway1:2024"]
70+
dest: ["server1"]
5771
EOF
5872

5973
exec "$@"

test/centos-image/sshproxy_test.go

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -209,19 +209,24 @@ func enableHost(host string) {
209209
}
210210

211211
var simpleConnectTests = []struct {
212+
user string
212213
port int
213214
want string
214215
}{
215-
{2023, "server1"},
216-
{2024, "server2"},
217-
{2025, "server3"},
216+
{"", 2023, "server1"},
217+
{"", 2024, "server2"},
218+
{"", 2025, "server3"},
219+
{"user1@", 2023, "server2"},
220+
{"user1@", 2024, "server2"},
221+
{"user2@", 2023, "server2"},
222+
{"user2@", 2024, "server1"},
218223
}
219224

220225
func TestSimpleConnect(t *testing.T) {
221226
for _, tt := range simpleConnectTests {
222227
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
223228
defer cancel()
224-
args, cmd := prepareCommand("gateway1", tt.port, "hostname")
229+
args, cmd := prepareCommand(tt.user+"gateway1", tt.port, "hostname")
225230
_, stdout, stderr, err := runCommand(ctx, "ssh", args, nil, nil)
226231
stdoutStr := strings.TrimSpace(string(stdout))
227232
if err != nil {

0 commit comments

Comments
 (0)