fyne-io / fyne

Cross platform GUI toolkit in Go inspired by Material Design
https://fyne.io/
Other
25.08k stars 1.39k forks source link

FileDialog on linux can't handle path elements for which the user has -r+x permissions #4110

Open rowanworth opened 1 year ago

rowanworth commented 1 year ago

Checklist

Describe the bug

The environment I'm testing in has directories setup like along these lines:

HOME=/global/home/rowanworth

PERMISSIONS   OWNER        GROUP   PATH
 drwxr-xr-x   root         staff   /global
 drwx--x---   root         staff   /global/home
 drwx--x---   rowanworth   staff   /global/home/rowanworth

ie. my user rowanworth, who is a member of group staff has full read/write/execute permissions to my home directory /global/home/rowanworth. However I do not have read permissions on the parent /global/home directory, only execute permissions. This means the kernel VFS layer allows me to traverse to sub-directories of /global/home/, but not list its contents.

Within Fyne, this manifests as an inability to navigate the file dialog to files in my home directory. The default view upon opening the file picker shows a blank area where the grid of icons should be, and the path is displayed as:

/   global   home

If I toggle between the list/grid view then the files in my home directory do appear - I can also navigate into subdirectories, but I have to toggle the list/grid view every time I change directories, and the path display never goes deeper than / global home.

How to reproduce

  1. Setup a directory that you have execute but not read permissions for
  2. Try to navigate it in Fyne's file picker

Screenshots

No response

Example code

The environment is the critical component here rather than the code so I haven't tested this snippet but it should be close to working :)

import (
    "fmt"
    "fyne.io/fyne/v2"
    "fyne.io/fyne/v2/app"
    "fyne.io/fyne/v2/container"
    "fyne.io/fyne/v2/dialog"
    "fyne.io/fyne/v2/theme"
    "fyne.io/fyne/v2/widget"
)

func main() {
    a := app.New()
    win := a.NewWindow("Hello file picker")

    fileBrowser := dialog.NewFileOpen(func(u fyne.URIReadCloser, e error) { fmt.Println(u.String()); fmt.Println(e) }, win)
    win.SetContent(widget.NewButtonWithIcon("", theme.FolderOpenIcon(), func() { fileBrowser.Show() } ))

    win.ShowAndRun()
}

Fyne version

v2@v2.3.5

Go compiler version

go version go1.18.1 linux/amd64

Operating system and version

Linux Centos 7.7.1908

Additional Information

I'm very new to Fyne so no clue if this should be filed against the FileDialog or some deeper VFS interface.

andydotxyz commented 1 year ago

Were there no errors listed in your console?

andydotxyz commented 1 year ago

The default view upon opening the file picker shows a blank area where the grid of icons should be, and the path is displayed as:

/   global   home

It sounds like maybe it's not getting your home directory correct perhaps - as it should be in the path... maybe a screenshot would help?

rowanworth commented 1 year ago

This is the only thing I see in the console:

2023/08/02 11:02:54 Fyne error:  Getting favorite locations
2023/08/02 11:02:54   Cause: this computer does not define a VIDEOS folder
2023/08/02 11:02:54   At: /localData/rowanw/go/pkg/mod/fyne.io/fyne/v2@v2.3.5/dialog/file.go:303

However I believe this relates to the "favorite folders" list and is unrelated to painting the current directory/file list (xdg-user-dir VIDEO returns the same path as my home folder, which causes getFavoriteLocation() in dialog/file_xdg.go to return this non-fatal error).

Here's a simple recipe to replicate the scenario in /tmp:

$ mkdir -p /tmp/global/home/rowanworth
$ chmod -r /tmp/global/home
$ export HOME=/tmp/global/home/rowanworth
$ echo hello world >$HOME/README.txt
$ mkdir $HOME/{Downloads,Documents,Music,Pictures,Videos}
$ ./main &

Here's a gif of what browsing that looks like. Note that:

  1. the "current directory" never goes deeper than / tmp global, even though the file picker starts in /tmp/global/rowanworth (ie. $HOME)
  2. no files are ever rendered until I switch between the list/grid view

Peek 2023-08-02 11-03