Skip to content

Commit 3e1de0c

Browse files
authored
Check if an user already as sftp chroot was wrong (hestiacp#2223)
* Check if an user already as sftp chroot was wrong Causing new users to be not create as chroot * remove echo * Prevent new tests fails because users hasn't been delete propperly
1 parent 14eb2bb commit 3e1de0c

File tree

2 files changed

+5
-6
lines changed

2 files changed

+5
-6
lines changed

bin/v-add-user-sftp-jail

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,23 +30,21 @@ source_conf "$HESTIA/conf/hestia.conf"
3030

3131
check_args '1' "$#" 'USER'
3232
is_format_valid 'user'
33+
# Limit to only Hestia user(s)
34+
is_object_valid 'user' 'USER' "$user"
3335
user_str=$(grep "^$user:" /etc/passwd |egrep "rssh|nologin")
3436
if [ -z "$user_str" ]; then
3537
exit
3638
fi
3739

38-
# Do not create chroot for syslog user
39-
if [ $user = "syslog" ]; then
40-
exit
41-
fi
4240

4341
# Get current users and split into array
4442
ssh_users=$(grep -A1 "^# Hestia SFTP Chroot" /etc/ssh/sshd_config | sed -n 2p | sed 's/Match User //')
4543
IFS=',' read -r -a users <<< "$ssh_users"
4644

4745
match_string="$ssh_users,"
4846
# Check if jail exist
49-
if [[ ! "$match_string" =~ ,$user, ]]; then
47+
if [[ "$match_string" =~ ,$user, ]]; then
5048
if [[ -d /home/$user && -z "$(find /home/$user -user root -print -prune -o -prune)" ]]; then
5149
chown root:root /home/$user
5250
fi

test/test.bats

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1326,7 +1326,8 @@ function check_ip_not_banned(){
13261326
run v-add-web-domain $user2 $subdomain
13271327
assert_success
13281328
refute_output
1329-
1329+
}
1330+
@test "Allow Users: Delete user2" {
13301331
run v-delete-user $user2
13311332
assert_success
13321333
refute_output

0 commit comments

Comments
 (0)