Skip to content

Commit 789a2b0

Browse files
authored
Merge pull request hestiacp#1160 from hestiacp/staging/fixes
Staging/fixes
2 parents 0682fce + 5801e0e commit 789a2b0

File tree

12 files changed

+133
-175
lines changed

12 files changed

+133
-175
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ All notable changes to this project will be documented in this file.
4242
- Fixed an issue with PHPMyAdmin button (#1078)
4343
- Changed WordPress name in Webapp installer (#1074)
4444
- Add a free disk space validation during backup routine (#1115)
45+
- Removed PHP validation SSH keys allowing support other types then RSA / DSA
4546

4647

4748
## [1.2.3] - Service Release

func/upgrade.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ upgrade_send_notification_to_panel () {
246246
upgrade_send_notification_to_email () {
247247
if [ "$UPGRADE_SEND_EMAIL" = "true" ]; then
248248
# Retrieve admin email address, sendmail path, and message temp file path
249-
admin_email=$(v-list-user admin json | grep "CONTACT" | cut -d'"' -f4)
249+
admin_email=$($HESTIA/bin/v-list-user admin json | grep "CONTACT" | cut -d'"' -f4)
250250
send_mail="$HESTIA/web/inc/mail-wrapper.php"
251251
message_tmp_file="/tmp/hestia-upgrade-complete.txt"
252252

src/lxd_build_all.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
# Configs:
1616
oslist=('debian=9,10' 'ubuntu=16.04,18.04,20.04')
17-
branch='master'
17+
branch='main'
1818

1919

2020
function setup_container() {

src/lxd_compile.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
#!/bin/bash
22

3-
branch=${1-master}
3+
branch=${1-main}
44

55
apt -y install curl wget
66

7-
curl https://raw.githubusercontent.com/hestiacp/hestiacp/master/src/hst_autocompile.sh > /tmp/hst_autocompile.sh
7+
curl https://raw.githubusercontent.com/hestiacp/hestiacp/main/src/hst_autocompile.sh > /tmp/hst_autocompile.sh
88
chmod +x /tmp/hst_autocompile.sh
99

1010
mkdir -p /opt/hestiacp

web/add/key/index.php

Lines changed: 2 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -5,39 +5,6 @@
55
// Main include
66
include($_SERVER['DOCUMENT_ROOT']."/inc/main.php");
77

8-
//check for valid format ssh key. Doesn't check it is working!
9-
//https://gist.github.com/jupeter/3248095
10-
function validateKey($value)
11-
{
12-
$key_parts = explode(' ', $value, 3);
13-
if (count($key_parts) < 2) {
14-
return false;
15-
}
16-
if (count($key_parts) > 3) {
17-
return false;
18-
}
19-
20-
$algorithm = $key_parts[0];
21-
$key = $key_parts[1];
22-
23-
if (!in_array($algorithm, array('ssh-rsa', 'ssh-dss'))) {
24-
return false;
25-
}
26-
27-
$key_base64_decoded = base64_decode($key, true);
28-
if ($key_base64_decoded == FALSE) {
29-
return false;
30-
}
31-
32-
$check = base64_decode(substr($key,0,16));
33-
$check = preg_replace("/[^\w\-]/","", $check);
34-
35-
if((string) $check !== (string) $algorithm) {
36-
return false;
37-
}
38-
return true;
39-
}
40-
418
// Check POST request
429
if (!empty($_POST['ok'])) {
4310
// Check token
@@ -51,38 +18,30 @@ function validateKey($value)
5118
}
5219

5320
if(!$_SESSION['error_msg']){
54-
switch ($_POST['v_key']){
55-
default:
21+
if($_POST){
5622
//key if key already exisits
5723
exec (HESTIA_CMD . "v-list-user-ssh-key ".$user." json", $output, $return_var);
5824
$data = json_decode(implode('', $output), true);
25+
unset($output);
5926
$keylist = array();
6027
foreach($data as $key => $value){
6128
$idlist[] = trim($data[$key]['ID']);
6229
$keylist[] = trim($data[$key]['KEY']);
6330
}
64-
65-
if(!validateKey($_POST['v_key'])){
66-
$_SESSION['error_msg'] = _('SSH KEY is invalid');
67-
break;
68-
}
6931

7032
$v_key_parts = explode(' ',$_POST['v_key']);
7133
$key_id = trim($v_key_parts[2]);
7234
if($v_key_parts[2] == ''){
7335
$_SESSION['error_msg'] = _('SSH KEY is invalid');
74-
break;
7536
}
7637

7738
//for deleting / revoking key the last part user@domain is used therefore needs to be unique
7839
//maybe consider adding random generated message or even an human read able string set by user?
7940
if(in_array($v_key_parts[2], $idlist)){
8041
$_SESSION['error_msg'] = _('SSH KEY already exists');
81-
break;
8242
}
8343
if(in_array($v_key_parts[1], $keylist)){
8444
$_SESSION['error_msg'] = _('SSH KEY already exists');
85-
break;
8645
}
8746
$v_key = escapeshellarg(trim($_POST['v_key']));
8847
}
@@ -92,9 +51,7 @@ function validateKey($value)
9251
exec (HESTIA_CMD."v-add-user-ssh-key ".$user." ".$v_key, $output, $return_var);
9352
check_return_code($return_var,$output);
9453
}
95-
9654
unset($output);
97-
9855
// Flush field values on success
9956
if (empty($_SESSION['error_msg'])) {
10057
$_SESSION['ok_msg'] = _('SSH KEY created');

0 commit comments

Comments
 (0)