Skip to content

Commit db2e842

Browse files
committed
Reverted commit "Remove old Vesta Filemanager files completly"
1 parent cd9de1c commit db2e842

23 files changed

+2330
-28
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@ All notable changes to this project will be documented in this file.
2121
- Implemented warning message for creating web domains under admin user.
2222
- v-generate-api-key: Fixed wrong quotes used for default keys folder location.
2323
- Fixed permissions to allow access for FTP users created in web domains under admin account.
24-
- Removed obsolete Vesta Filemanager files completely.
2524
- Check if user home exists before set permission on sftp jail.
2625
- Fix several security issues, thanks to Andrea Cardaci (https://cardaci.xyz/)
2726

27+
2828
## [1.0.4] - 2019-07-09 - Hotfix
2929
### Bugfixes
3030
- Delayed start of services to prevent restart limit.

bin/v-add-fs-archive

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
#!/bin/bash
2+
# info: archive directory
3+
# options: USER ARCHIVE SOURCE
4+
#
5+
# The function creates tar archive
6+
7+
user=$1
8+
archive=$2
9+
src0=$3
10+
11+
# Checking arguments
12+
if [ -z "$src0" ]; then
13+
echo "Usage: USER ARCHIVE FILE [FILE_2] [FILE_3] [FILE ...]"
14+
exit 1
15+
fi
16+
17+
# Checking hestia user
18+
if [ ! -d "$HESTIA/data/users/$user" ]; then
19+
echo "Error: hestia user $user doesn't exist"
20+
exit 3
21+
fi
22+
23+
# Checking user homedir
24+
homedir=$(grep "^$user:" /etc/passwd |cut -f 6 -d :)
25+
if [ -z $homedir ]; then
26+
echo "Error: user home directory doesn't exist"
27+
exit 12
28+
fi
29+
30+
# Checking archive
31+
if [ -e "$archive" ]; then
32+
echo "Error: archive already exist $archive"
33+
exit 1
34+
fi
35+
36+
# Checking source path
37+
IFS=$'\n'
38+
i=1
39+
for src in $*; do
40+
if [ "$i" -gt 2 ]; then
41+
rpath=$(readlink -f "$src")
42+
if [ -z "$(echo $rpath |egrep "^/tmp|^$homedir")" ]; then
43+
echo "Error: invalid source path $src"
44+
exit 1
45+
fi
46+
fi
47+
((i++))
48+
done
49+
50+
i=1
51+
for src in $*; do
52+
if [ "$i" -gt 2 ]; then
53+
# Deleting leading home path
54+
src=$(echo "$src"| sed -e "s|/home/$user/||")
55+
56+
# Creating tar.gz archive
57+
sudo -u $user tar -rf "${archive/.gz/}" -C /home/$user $src >\
58+
/dev/null 2>&1
59+
if [ "$?" -ne 0 ]; then
60+
echo "Error: archive $archive was not created"
61+
exit 3
62+
fi
63+
fi
64+
((i++))
65+
done
66+
67+
# Checking gzip
68+
if [[ "$archive" =~ \.gz$ ]]; then
69+
sudo -u $user gzip "${archive/.gz/}" >/dev/null 2>&1
70+
if [ "$?" -ne 0 ]; then
71+
echo "Error: archive $archive was not gziped"
72+
exit 3
73+
fi
74+
fi
75+
76+
exit

bin/v-add-fs-directory

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
#!/bin/bash
2+
# info: add directory
3+
# options: USER DIRECTORY
4+
#
5+
# The function creates new directory on the file system
6+
7+
user=$1
8+
dst_dir=$2
9+
10+
# Checking arguments
11+
if [ -z "$dst_dir" ]; then
12+
echo "Usage: USER DIRECTORY"
13+
exit 1
14+
fi
15+
16+
# Checking hestia user
17+
if [ ! -d "$HESTIA/data/users/$user" ]; then
18+
echo "Error: hestia user $user doesn't exist"
19+
exit 3
20+
fi
21+
22+
# Checking user homedir
23+
homedir=$(grep "^$user:" /etc/passwd | cut -f 6 -d :)
24+
if [ -z $homedir ]; then
25+
echo "Error: user home directory doesn't exist"
26+
exit 12
27+
fi
28+
29+
# Checking destination path
30+
rpath=$(readlink -f "$dst_dir")
31+
if [ -z "$(echo $rpath |egrep "^/tmp|^$homedir")" ]; then
32+
echo "Error: invalid destination path $dst_dir"
33+
exit 2
34+
fi
35+
36+
# Adding directory
37+
sudo -u $user mkdir -p "$dst_dir" >/dev/null 2>&1
38+
if [ $? -ne 0 ]; then
39+
echo "Error: directory $dst_dir was not created"
40+
exit 3
41+
fi
42+
43+
# Extiging
44+
exit

bin/v-add-fs-file

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
#!/bin/bash
2+
# info: add file
3+
# options: USER FILE
4+
#
5+
# The function creates new files on file system
6+
7+
user=$1
8+
dst_file=$2
9+
10+
# Checking arguments
11+
if [ -z "$dst_file" ]; then
12+
echo "Usage: USER FILE"
13+
exit 1
14+
fi
15+
16+
# Checking hestia user
17+
if [ ! -d "$HESTIA/data/users/$user" ]; then
18+
echo "Error: hestia user $user doesn't exist"
19+
exit 3
20+
fi
21+
22+
# Checking user homedir
23+
homedir=$(grep "^$user:" /etc/passwd | cut -f 6 -d :)
24+
if [ -z $homedir ]; then
25+
echo "Error: user home directory doesn't exist"
26+
exit 12
27+
fi
28+
29+
# Checking destination path
30+
rpath=$(readlink -f "$dst_file")
31+
if [ -z "$(echo $rpath |egrep "^/tmp|^$homedir")" ]; then
32+
echo "Error: invalid destination path $dst_dir"
33+
exit 2
34+
fi
35+
36+
# Creating file
37+
sudo -u $user touch "$dst_file" >/dev/null 2>&1
38+
if [ $? -ne 0 ]; then
39+
echo "Error: file $dst_file was not created"
40+
exit 3
41+
fi
42+
43+
# Exiting
44+
exit

bin/v-change-fs-file-permission

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
#!/bin/bash
2+
# info: change file permission
3+
# options: USER FILE PERMISSIONS
4+
#
5+
# The function changes file access permissions on the file system
6+
7+
user=$1
8+
src_file=$2
9+
permissions=$3
10+
11+
# Checking arguments
12+
if [ -z "$permissions" ]; then
13+
echo "Usage: USER FILE PERMISSIONS"
14+
exit 1
15+
fi
16+
17+
# Checking hestia user
18+
if [ ! -d "$HESTIA/data/users/$user" ]; then
19+
echo "Error: hestia user $user doesn't exist"
20+
exit 3
21+
fi
22+
23+
# Checking user homedir
24+
homedir=$(grep "^$user:" /etc/passwd | cut -f 6 -d :)
25+
if [ -z $homedir ]; then
26+
echo "Error: user home directory doesn't exist"
27+
exit 12
28+
fi
29+
30+
# Checking source file
31+
if [ ! -fe "$src_file" ]; then
32+
echo "Error: source file doesn't exist $src_file"
33+
exit 3
34+
fi
35+
36+
# Checking source path
37+
rpath=$(readlink -f "$src_file")
38+
if [ -z "$(echo $rpath |egrep "^/tmp|^$homedir")" ]; then
39+
echo "Error: invalid source path $src_file"
40+
exit 2
41+
fi
42+
43+
# Changing file permissions
44+
sudo -u $user chmod -R $permissions "$src_file" >/dev/null 2>&1
45+
if [ $? -ne 0 ]; then
46+
echo "Error: access permission on $src_file was not changed"
47+
exit 3
48+
fi
49+
50+
# Exiting
51+
exit

bin/v-check-fs-permission

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
#!/bin/bash
2+
# info: open file
3+
# options: USER FILE
4+
#
5+
# The function opens/reads files on the file system
6+
7+
user=$1
8+
src=$2
9+
10+
# Checking arguments
11+
if [ -z "$src" ]; then
12+
echo "Usage: USER FILE"
13+
exit 1
14+
fi
15+
16+
# Checking hestia user
17+
if [ ! -d "$HESTIA/data/users/$user" ]; then
18+
echo "Error: hestia user $user doesn't exist"
19+
exit 3
20+
fi
21+
22+
# Checking user homedir
23+
homedir=$(grep "^$user:" /etc/passwd | cut -f 6 -d :)
24+
if [ -z $homedir ]; then
25+
echo "Error: user home directory doesn't exist"
26+
exit 12
27+
fi
28+
29+
# Checking path
30+
if [ ! -z "$src" ]; then
31+
rpath=$(readlink -f "$src")
32+
if [ -z "$(echo $rpath |egrep "^/tmp|^$homedir")" ]; then
33+
echo "Error: invalid source path $user $src"
34+
exit 2
35+
fi
36+
fi
37+
38+
# Checking if file has readable permission
39+
sudo -u $user ls "$src" > /dev/null 2>&1
40+
if [ $? -ne 0 ]; then
41+
echo "Error: can't read $src"
42+
exit 1
43+
fi
44+
45+
# Exiting
46+
exit

bin/v-copy-fs-directory

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
#!/bin/bash
2+
# info: copy directory
3+
# options: USER SRC_DIRECTORY DST_DIRECTORY
4+
#
5+
# The function copies directory on the file system
6+
7+
user=$1
8+
src_dir=$2
9+
dst_dir=$3
10+
11+
# Checking arguments
12+
if [ -z "$dst_dir" ]; then
13+
echo "Usage: USER SRC_DIRECTORY DST_DIRECTORY"
14+
exit 1
15+
fi
16+
17+
# Checking hestia user
18+
if [ ! -d "$HESTIA/data/users/$user" ]; then
19+
echo "Error: hestia user $user doesn't exist"
20+
exit 3
21+
fi
22+
23+
# Checking user homedir
24+
homedir=$(grep "^$user:" /etc/passwd | cut -f 6 -d :)
25+
if [ -z $homedir ]; then
26+
echo "Error: user home directory doesn't exist"
27+
exit 12
28+
fi
29+
30+
# Checking source dir
31+
if [ ! -e "$src_dir" ]; then
32+
echo "Error: source directory $src_dir doesn't exist"
33+
exit 3
34+
fi
35+
36+
# Checking source path
37+
rpath=$(readlink -f "$src_dir")
38+
if [ -z "$(echo $rpath |egrep "^/tmp|^$homedir")" ]; then
39+
echo "Error: invalid source path $src_dir"
40+
exit 2
41+
fi
42+
43+
# Checking destination path
44+
rpath=$(readlink -f "$dst_dir")
45+
if [ -z "$(echo $rpath |egrep "^/tmp|^$homedir")" ]; then
46+
echo "Error: invalid destination path $dst_dir"
47+
exit 2
48+
fi
49+
50+
# Copying directory
51+
sudo -u $user cp -r "$src_dir" "$dst_dir" >/dev/null 2>&1
52+
if [ $? -ne 0 ]; then
53+
echo "Error: directory $src_dir was not copied"
54+
exit 3
55+
fi
56+
57+
# Exiting
58+
exit

bin/v-copy-fs-file

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
#!/bin/bash
2+
# info: copy file
3+
# options: USER SRC_FILE DST_FLE
4+
#
5+
# The function copies file on the file system
6+
7+
user=$1
8+
src_file=$2
9+
dst_file=$3
10+
11+
# Checking arguments
12+
if [ -z "$dst_file" ]; then
13+
echo "Usage: USER SRC_FILE DST_FILE"
14+
exit 1
15+
fi
16+
17+
# Checking hestia user
18+
if [ ! -e "$HESTIA/data/users/$user" ]; then
19+
echo "Error: hestia user $user doesn't exist"
20+
exit 3
21+
fi
22+
23+
# Checking user homedir
24+
homedir=$(grep "^$user:" /etc/passwd | cut -f 6 -d :)
25+
if [ -z $homedir ]; then
26+
echo "Error: user home directory doesn't exist"
27+
exit 12
28+
fi
29+
30+
# Checking source file
31+
if [ ! -f "$src_file" ]; then
32+
echo "Error: $src_file doesn't exist"
33+
exit 3
34+
fi
35+
36+
# Checking source path
37+
rpath=$(readlink -f "$src_file")
38+
if [ -z "$(echo $rpath |egrep "^/tmp|^$homedir")" ]; then
39+
echo "Error: invalid source path $src_file"
40+
exit 2
41+
fi
42+
43+
# Checking destination path
44+
rpath=$(readlink -f "$dst_file")
45+
if [ -z "$(echo $rpath |egrep "^/tmp|^$homedir")" ]; then
46+
echo "Error: ivalid destination path $dst_file"
47+
exit 2
48+
fi
49+
50+
# Copying file
51+
sudo -u $user cp "$src_file" "$dst_file" >/dev/null 2>&1
52+
if [ $? -ne 0 ]; then
53+
echo "Error: file $src_file was not copied"
54+
exit 3
55+
fi
56+
57+
# Exiting
58+
exit

0 commit comments

Comments
 (0)