aboutsummaryrefslogtreecommitdiffhomepage
path: root/docker/rootfs
diff options
context:
space:
mode:
authorPaolo Asperti <[email protected]>2022-07-21 16:45:21 +0200
committerPaolo Asperti <[email protected]>2022-07-22 10:18:50 +0200
commitfab70ce8e73a4f3bd82dd25177a507e15db4d117 (patch)
treee028c11597d5428aef14f186250afd47e701ec6b /docker/rootfs
parent06bd1117f6e789bc9cc44db38a1dadaeeb427568 (diff)
downloadrustdesk-server-fab70ce8e73a4f3bd82dd25177a507e15db4d117.tar.gz
rustdesk-server-fab70ce8e73a4f3bd82dd25177a507e15db4d117.zip
keypair verification before container startup
Diffstat (limited to 'docker/rootfs')
-rwxr-xr-xdocker/rootfs/etc/s6-overlay/s6-rc.d/key-secret/up.real33
1 files changed, 28 insertions, 5 deletions
diff --git a/docker/rootfs/etc/s6-overlay/s6-rc.d/key-secret/up.real b/docker/rootfs/etc/s6-overlay/s6-rc.d/key-secret/up.real
index 90a13dc..e93ac95 100755
--- a/docker/rootfs/etc/s6-overlay/s6-rc.d/key-secret/up.real
+++ b/docker/rootfs/etc/s6-overlay/s6-rc.d/key-secret/up.real
@@ -26,10 +26,33 @@ if [ ! -f /data/id_ed25519 ] && [ ! "$KEY_PRIV" = "" ] ; then
echo "Private key created from ENV variable"
fi
-# fix perms
-if [ -f /data/id_ed25519.pub ] ; then
- chmod 600 /data/id_ed25519.pub
+# check if both keys provided
+if [ -f /data/id_ed25519.pub ] && [ ! -f /data/id_ed25519 ] ; then
+ echo "Private key missing."
+ echo "You must provide BOTH the private and the public key."
+ /run/s6/basedir/bin/halt
+ exit 1
fi
-if [ -f /data/id_ed25519 ] ; then
- chmod 600 /data/id_ed25519
+
+if [ ! -f /data/id_ed25519.pub ] && [ -f /data/id_ed25519 ] ; then
+ echo "Public key missing."
+ echo "You must provide BOTH the private and the public key."
+ /run/s6/basedir/bin/halt
+ exit 1
fi
+
+# here we have either no keys or both
+
+# if we have both keys, we fix permissions and ownership
+# and check for keypair validation
+if [ -f /data/id_ed25519.pub ] && [ -f /data/id_ed25519 ] ; then
+ chmod 0600 /data/id_ed25519.pub /data/id_ed25519
+ chown root:root /data/id_ed25519.pub /data/id_ed25519
+ /usr/bin/rustdesk-utils validatekeypair "$(cat /data/id_ed25519.pub)" "$(cat /data/id_ed25519)" || {
+ echo "Key pair not valid"
+ /run/s6/basedir/bin/halt
+ exit 1
+ }
+fi
+
+# if we have no keypair, hbbs will generate one