Skip to content

Commit 100babd

Browse files
author
Kristan Kenney
committed
Merge branch 'staging/fixes' into staging/release/v1.3.0
2 parents 78f7c1a + d7094cc commit 100babd

File tree

5 files changed

+41
-15
lines changed

5 files changed

+41
-15
lines changed

bin/v-change-user-rkey

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
#!/bin/bash
2-
# info: change user password
3-
# options: USER
2+
# info: change user random key
3+
# options: USER [HASH]
44
#
5-
# The function changes user's password and updates RKEY value.
5+
# The function changes user's RKEY value thats has been used for security value to be used forgot password function only.
66

77

88
#----------------------------------------------------------#
@@ -11,8 +11,9 @@
1111

1212
# Argument definition
1313
user=$1
14+
hash=$2
1415

15-
16+
echo $rkeyhash;
1617
# Importing system enviroment as we run this script
1718
# mostly by cron wich not read it by itself
1819
source /etc/profile
@@ -25,14 +26,21 @@ source $HESTIA/conf/hestia.conf
2526
# Verifications #
2627
#----------------------------------------------------------#
2728

28-
check_args '1' "$#" 'USER'
29+
check_args '1' "$#" 'USER [HASH]'
2930
is_format_valid 'user'
3031
is_object_valid 'user' 'USER' "$user"
3132
is_object_unsuspended 'user' 'USER' "$user"
3233

3334
# Perform verification if read-only mode is enabled
3435
check_hestia_demo_mode
3536

37+
if [ ! -z "$hash" ]; then
38+
password=$hash
39+
is_password_valid
40+
hash=$password;
41+
else
42+
hash=$(generate_password)
43+
fi
3644
#----------------------------------------------------------#
3745
# Action #
3846
#----------------------------------------------------------#
@@ -44,7 +52,7 @@ d=$(date +%s)
4452
#----------------------------------------------------------#
4553

4654
# Changing RKEY value
47-
update_user_value "$user" '$RKEY' "$(generate_password)"
55+
update_user_value "$user" '$RKEY' "$hash"
4856

4957
#check if RKEYEXP exists
5058
if [ -z "$(grep RKEYEXP $USER_DATA/user.conf)" ]; then

install/hst-install-debian.sh

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -931,8 +931,13 @@ fi
931931

932932
# Restrict access to /proc fs
933933
# - Prevent unpriv users from seeing each other running processes
934-
mount -o remount,defaults,hidepid=2 /proc
935-
echo "@reboot root sleep 5 && mount -o remount,defaults,hidepid=2 /proc" > /etc/cron.d/hestia-proc
934+
mount -o remount,defaults,hidepid=2 /proc > /dev/null 2>&1
935+
if [ $? -ne 0 ]; then
936+
echo "Info: Cannot remount /proc (LXC containers require additional perm added to host apparmor profile)"
937+
else
938+
echo "@reboot root sleep 5 && mount -o remount,defaults,hidepid=2 /proc" > /etc/cron.d/hestia-proc
939+
fi
940+
936941

937942
#----------------------------------------------------------#
938943
# Configure Hestia #

install/hst-install-ubuntu.sh

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -988,8 +988,12 @@ fi
988988

989989
# Restrict access to /proc fs
990990
# - Prevent unpriv users from seeing each other running processes
991-
mount -o remount,defaults,hidepid=2 /proc
992-
echo "@reboot root sleep 5 && mount -o remount,defaults,hidepid=2 /proc" > /etc/cron.d/hestia-proc
991+
mount -o remount,defaults,hidepid=2 /proc > /dev/null 2>&1
992+
if [ $? -ne 0 ]; then
993+
echo "Info: Cannot remount /proc (LXC containers require additional perm added to host apparmor profile)"
994+
else
995+
echo "@reboot root sleep 5 && mount -o remount,defaults,hidepid=2 /proc" > /etc/cron.d/hestia-proc
996+
fi
993997

994998

995999
#----------------------------------------------------------#

install/upgrade/versions/1.3.0.sh

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,10 @@ fi
6565
# Restrict access to /proc fs
6666
if [ ! -e "/etc/cron.d/hestia-proc" ]; then
6767
echo "[ * ] Restrict access to /proc fs"
68-
echo "@reboot root sleep 5 && mount -o remount,defaults,hidepid=2 /proc" > /etc/cron.d/hestia-proc
69-
mount -o remount,defaults,hidepid=2 /proc
68+
mount -o remount,defaults,hidepid=2 /proc > /dev/null 2>&1
69+
if [ $? -ne 0 ]; then
70+
echo "Info: Cannot remount /proc (LXC containers require additional perm added to host apparmor profile)"
71+
else
72+
echo "@reboot root sleep 5 && mount -o remount,defaults,hidepid=2 /proc" > /etc/cron.d/hestia-proc
73+
fi
7074
fi

web/reset/index.php

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,16 @@
2020
$data = json_decode(implode('', $output), true);
2121
if($email == $data[$user]['CONTACT']){
2222
//genrate new rkey
23-
exec ("/usr/bin/sudo /usr/local/hestia/bin/v-change-user-rkey ".$v_user."", $output, $return_var);
23+
$rkey = substr( password_hash( 'hestiacp', PASSWORD_DEFAULT ), 5, 12 );
24+
$hash = password_hash($rkey, PASSWORD_DEFAULT);
25+
$v_rkey = tempnam("/tmp","vst");
26+
$fp = fopen($v_rkey, "w");
27+
fwrite($fp, $hash."\n");
28+
fclose($fp);
29+
exec ("/usr/bin/sudo /usr/local/hestia/bin/v-change-user-rkey ".$v_user." ".$v_rkey."", $output, $return_var);
2430
unset($output);
2531
exec ($cmd." ".$v_user." json", $output, $return_var);
2632
$data = json_decode(implode('', $output), true);
27-
$rkey = $data[$user]['RKEY'];
2833
$name = $data[$user]['NAME'];
2934
$contact = $data[$user]['CONTACT'];
3035
$to = $data[$user]['CONTACT'];
@@ -58,7 +63,7 @@
5863
if ( $return_var == 0 ) {
5964
$data = json_decode(implode('', $output), true);
6065
$rkey = $data[$user]['RKEY'];
61-
if (hash_equals($rkey, $_POST['code'])) {
66+
if (password_verify($_POST['code'], $rkey)) {
6267
unset($output);
6368
exec("/usr/bin/sudo /usr/local/hestia/bin/v-get-user-value ".$v_user." RKEYEXP", $output,$return_var);
6469
if($output[0] > time() - 900){

0 commit comments

Comments
 (0)