Allow SSH keys for only "/"

This commit is contained in:
Miraty 2023-11-16 21:29:37 +01:00
parent 18fa6d794a
commit 808de3fdbf

View file

@ -9,7 +9,7 @@ foreach ($_POST['keys'] as $i => $key) {
unset($_POST['keys'][$i]); unset($_POST['keys'][$i]);
continue; continue;
} }
if (preg_match('#^/[/\p{L}\{M}\p{N}\p{P}\p{S}\p{Zs}]{1,254}$#Du', $key['dir'] ?? '') !== 1) if (preg_match('#^/[/\p{L}\{M}\p{N}\p{P}\p{S}\p{Zs}]{0,254}$#Du', $key['dir'] ?? '') !== 1)
output(403, _('Path is not valid.')); output(403, _('Path is not valid.'));
if (preg_match('#' . ED25519_PUBKEY_REGEX . '#D', $key['public-key']) !== 1) if (preg_match('#' . ED25519_PUBKEY_REGEX . '#D', $key['public-key']) !== 1)
output(403, _('Ed25519 public key seems wrongly formatted.')); output(403, _('Ed25519 public key seems wrongly formatted.'));