Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Snap installed trippy on Ubuntu get permission denied while accessing config file #1058

Closed
helixzz opened this issue Mar 21, 2024 · 10 comments · Fixed by #1059
Closed

Snap installed trippy on Ubuntu get permission denied while accessing config file #1058

helixzz opened this issue Mar 21, 2024 · 10 comments · Fixed by #1059
Labels
bug Something isn't working package
Milestone

Comments

@helixzz
Copy link

helixzz commented Mar 21, 2024

Describe the bug
Just installed trippy from snap store using command snap install trippy. It works fine with default config. If I want to customize anything (for default behavior) it seems the only way is to create a config file (e.g. trippy.toml). However, with the snap installed version of trippy, the trippy binary seems can't read the config file under my $HOME directory, even if the dir and file permissions are set to 777.

To Reproduce

snap install trippy
trip --print-config-template > ~/.config/trippy.toml
jqadmin@xxx:~$ trippy connect.helixzz.com
Error: config file not found: "/home/xxx/.config/trippy.toml"

Caused by:
    Permission denied (os error 13)

Expected behavior
trippy reads the config file and perform its configuration correctly.

Environment Info

  • OS: Ubuntu 22.04.2 LTS
  • Trippy version: trip 0.9.0
  • Installation method: snap
  • Terminal / Console: SSH session connected to my host with Tabby
@helixzz helixzz added the triage label Mar 21, 2024
@fujiapple852
Copy link
Owner

Thanks for the report @helixzz.

I suspect trippy needs to connect to the home interface to allow this.

if you connect it manually (as described in https://snapcraft.io/docs/home-interface) does that fix the issue?

if so I will ask for that interface to be added to the snap for the nest version.

@fujiapple852 fujiapple852 added bug Something isn't working and removed triage labels Mar 21, 2024
@fujiapple852 fujiapple852 self-assigned this Mar 21, 2024
@helixzz
Copy link
Author

helixzz commented Mar 21, 2024

Thanks for the report @helixzz.

I suspect trippy needs to connect to the home interface to allow this.

if you connect it manually (as described in https://snapcraft.io/docs/home-interface) does that fix the issue?

if so I will ask for that interface to be added to the snap for the nest version.

Thanks for your reply!

I've tried sudo snap connect trippy:home :home and it seems produces an error: error: snap "trippy" has no plug named "home". Maybe I haven't get the correct command line?

@fujiapple852
Copy link
Owner

fujiapple852 commented Mar 21, 2024

@helixzz thanks for trying. I guess I need to add it to here first and release it:

plugs:
- network-bind
- network
- network-observe

I also need to request auto-connect permission for this plug on the snapcraft forum.

Leave it with me and I’ll figure out what is needed.

@fujiapple852
Copy link
Owner

fujiapple852 commented Mar 21, 2024

I am able to reproduce the issue on a ubuntu instance.

I added the home interface to trippy (in #1059) and this was built and released to the edge channel (revision 2643 for amd64).

I switched to the edge channel and refreshed:

snap-id:      MuyJc7aas4HVkKbWZclsIhu0R9WAjX50
tracking:     latest/edge
refresh-date: today at 13:00 UTC
channels:
  latest/stable:    0.9.0 2023-11-30 (1943) 3MB -
  latest/candidate: ↑
  latest/beta:      ↑
  latest/edge:      0.9.0 2024-03-21 (2643) 3MB -
installed:          0.9.0            (2643) 3MB -

I connected the (now available) home interface:

fuji@trippy-dev:~$ sudo snap connections trippy
Interface        Plug                    Slot              Notes
home             trippy:home             :home             -
network          trippy:network          :network          -
network-bind     trippy:network-bind     :network-bind     -
network-observe  trippy:network-observe  :network-observe  -

But it still does not work:

fuji@trippy-dev:~$ sudo trip 1.1.1.1 --config-file /home/fuji/trippy.toml
Error: config file not found: "/home/fuji/trippy.toml"

Caused by:
    Permission denied (os error 13)

The same message is given for files that do not exist:

fuji@trippy-dev:~$ sudo trip 1.1.1.1 --config-file /home/fuji/doesnotexist.toml
Error: config file not found: "/home/fuji/doesnotexist.toml"

Caused by:
    Permission denied (os error 13)

I tried from /tmp as well but that does not work either (which seems expected), however it fails with a different error (the files does exist in this case):

fuji@trippy-dev:~$ sudo trip 1.1.1.1 --config-file /tmp/trippy.toml
Error: config file not found: "/tmp/trippy.toml"

Caused by:
    No such file or directory (os error 2)

Aside, note that I used a non-hidden file and dirs above as the home interface only claims to allow access to non-hidden files. For hidden files it seems another interface, personal-files is needed. However I haven't tried this since I have not even been able to get the non-hidden files to work so far. There is also a removal-media interface which may be needed.

I'll post a question on the snapcraft forum as i'm not a regular snap user or expert and the solution is not obvious.

@fujiapple852
Copy link
Owner

@fujiapple852
Copy link
Owner

fujiapple852 commented Mar 23, 2024

Added #1062 to allow running via snap without requiring sudo such that the home and personal-files interfaces will allow access to configuration files in the /home of the original user rather than the home of the root user.

Edit: this does not help, snap requires elevated privileges even when the network-observe interface is connected.

@fujiapple852
Copy link
Owner

fujiapple852 commented Mar 27, 2024

@helixzz if you are following the thread on the snapcraft forum, there is a solution to allow trippy (or any snap really) to read files from $HOME (that is blocked by default). The catch is it doesn't support hidden files or directories and so you'd need to place your trippy.toml file in your $HOME directory. Not a perfect solution but that appears to be the best we can do within the constraints of snap.

The snap config change to allow this will be included in 0.10.0 release of Trippy (due very soon).

@c-git
Copy link
Collaborator

c-git commented Mar 29, 2024

Sorry was travelling I knew about this limitation of not being able to access files in folders that start with a dot because Firefox which is installed via Snap by default now on Ubuntu also has the same issue.

@fujiapple852
Copy link
Owner

I'm awaiting the change to be approved by the snap folk and without that the 0.10.0 release will not be available in the snap store. Rather than block the whole Trippy release (which I'm planning to do today) i'm going to go ahead and close this issue and add it to the 0.10.0 release note as completed. Once the approval happens I can release 0.10.0 to the snap store.

@fujiapple852
Copy link
Owner

@helixzz Trippy 0.10.0 has finally been released on snap and supports the ability to read (non-hidden) configuration files.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working package
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants