瀏覽代碼

Fixing directory permission check

Vinicius Teshima 10 月之前
父節點
當前提交
93838b75a9
共有 1 個文件被更改,包括 3 次插入3 次删除
  1. 3 3
      luks.sh

+ 3 - 3
luks.sh

@@ -18,6 +18,8 @@ TRY_AND_RETRY () {
 }
 
 sudo_prog='sudo --prompt=Sudo_Password:'
+cur_uid="$(id -u)"
+cur_gid="$(id -g)"
 
 _MOUNT () {
 	echo "Mounting ${1} into ${2}"
@@ -34,7 +36,7 @@ _LUKS_OPEN () {
 _CHECK_DIR_PERM () {
 	dir_perm="$(stat -c '%u:%g' "${1}")"
 	cur_perm="${cur_uid}:${cur_gid}"
-	test "$dir_perm" = "$cur_perm" || return 0
+	test "$dir_perm" = "$cur_perm" && return 0
 	echo -n "Directory ${1} is not owned by current user. Want to change direcory owner? (Y/n) "
 	read choose
 	case "$choose" in
@@ -51,8 +53,6 @@ name="$(echo "$file" | cut -d. -f1)"
 _name="__${name}__"
 ext="$(echo "$file" | cut -d. -f2)"
 block_dev="/dev/mapper/${_name}"
-cur_uid="$(id -u)"
-cur_gid="$(id -g)"
 
 test "$ext" = 'luks' || ERR "File $file_path does not have extencion .luks." 1