mirror of
https://github.com/serghey-rodin/vesta.git
synced 2025-08-21 13:54:26 -07:00
API backend for Web File Manager
This commit is contained in:
parent
edcd549e4c
commit
75374e264a
11 changed files with 431 additions and 42 deletions
43
bin/v-change-fs-file-permission
Executable file
43
bin/v-change-fs-file-permission
Executable file
|
@ -0,0 +1,43 @@
|
|||
#!/bin/bash
|
||||
# info: change file permission
|
||||
# options: USER FILE PERMISSIONS
|
||||
#
|
||||
# The function changes file access permissions on the file system
|
||||
|
||||
user=$1
|
||||
src_file=$2
|
||||
permissions=$3
|
||||
|
||||
# Checking arguments
|
||||
if [ -z "$permissions" ]; then
|
||||
echo "Usage: USER FILE PERMISSIONS"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Checking vesta user
|
||||
if [ ! -e "$VESTA/data/users/$user" ]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Checking user homedir
|
||||
homedir=$(grep "^$user:" /etc/passwd | cut -f 6 -d :)
|
||||
if [ -z $homedir ]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Checking source file
|
||||
if [ ! -f "$src_file" ]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Checking source path
|
||||
rpath=$(readlink -f "$src_file")
|
||||
if [ -z "$(echo $rpath |egrep "^/tmp|^$homedir")" ]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Changing file permissions
|
||||
sudo -u $user chmod $permisions $src_file >/dev/null 2>&1
|
||||
|
||||
# Exiting
|
||||
exit $?
|
Loading…
Add table
Add a link
Reference in a new issue