Unverified Commit 54450110 authored by Kroese's avatar Kroese Committed by GitHub
Browse files

feat: Check if shared folder is writeable (#1531)

parent 122d1ff9
Loading
Loading
Loading
Loading
+10 −3
Original line number Diff line number Diff line
@@ -46,16 +46,23 @@ addShare() {
  local cfg="$5"
  local owner=""

  if [ ! -d "$dir" ]; then
    if ! mkdir -p "$dir"; then
    error "Failed to create directory $dir." && return 1
      error "Failed to create shared folder ($dir)." && return 1
    fi
  fi

  if ! ls -A "$dir" >/dev/null 2>&1; then
    msg="Failed to access directory $dir."
    msg="No permission to access shared folder ($dir)."
    msg+=" If SELinux is active, you need to add the \":Z\" flag to the bind mount."
    error "$msg" && return 1
  fi

  if [ ! -w "$dir" ]; then
    msg="shared folder ($dir) is not writeable!"
    warn "$msg"
  fi

  if [ -z "$(ls -A "$dir")" ]; then
    if ! chmod 2777 "$dir"; then
      error "Failed to set permissions for directory $dir" && return 1