File tree Expand file tree Collapse file tree 1 file changed +9
-17
lines changed
Expand file tree Collapse file tree 1 file changed +9
-17
lines changed Original file line number Diff line number Diff line change 55# The function opens/reads files on the file system
66
77user=$1
8- src_file =$2
8+ src =$2
99
1010# Checking arguments
11- if [ -z " $src_file " ]; then
11+ if [ -z " $src " ]; then
1212 echo " Usage: USER FILE"
1313 exit 1
1414fi
@@ -27,27 +27,19 @@ if [ -z $homedir ]; then
2727fi
2828
2929# Checking path
30- if [ ! -z " $src_file " ]; then
31- rpath=$( readlink -f " $src_file " )
30+ if [ ! -z " $src " ]; then
31+ rpath=$( readlink -f " $src " )
3232 if [ -z " $( echo $rpath | egrep " ^/tmp|^$homedir " ) " ]; then
33- echo " Error: invalid source path $src_file "
33+ echo " Error: invalid source path $user $src "
3434 exit 2
3535 fi
3636fi
3737
38- # Reading file
39- # sudo -u $user cat "$src_file" 2>/dev/null
40- # if [ $? -ne 0 ]; then
41- # echo "Error: file $src_file was not opened"
42- # exit 3
43- # fi
44-
4538# Checking if file has readable permission
46- if [[ ! -r $src_file ]]
47- then
48- # echo "File is readable"
49- # else
50- echo " Cannot read file"
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
5143fi
5244
5345# Exiting
You can’t perform that action at this time.
0 commit comments