Blacksmoke16 / oq

A performant, and portable jq wrapper to facilitate the consumption and output of formats other than JSON; using jq filters to transform the data.
https://blacksmoke16.github.io/oq/
MIT License
190 stars 15 forks source link

Allow snap to access home and USB drives #67

Closed devhammed closed 4 years ago

devhammed commented 4 years ago

Currently, the snap binary cannot access the home folder and plugged in USB drives...this pull request adds the support by declaring necessary snap plugs.

Blacksmoke16 commented 4 years ago

@devhammed Out of curiosity, do you get an error or something when trying to use oq in one of those directories?

I installed it via sudo snap install oq, then added a file to one of my external drives, then did oq . /run/media/george/Archive/test.json and it worked fine.

devhammed commented 4 years ago

It does not work here and I am very surprised it is working for you because even in Snapcraft docs, you should not be able to access these file locations if you did not declare those plugs.

Screenshot from 2020-07-09 05-51-13

This confirms that oq isn't connected to any interfaces:

Screenshot from 2020-07-09 05-53-53

Blacksmoke16 commented 4 years ago

@devhammed This is an error within oq. It's trying to open the file you give it, but your current user does not have access to read it. I.e. you can reproduce it like:

echo '{"id":1}' >> test.json
sudo chown root test.json
sudo chmod 600 test.json
oq .id test.json # => oq error: Error opening file with mode 'r': 'test.json': Permission denied
sudo oq .id test.json # => 1

Given this isn't really a snap issue I'm not so sure changing the plugs will have an affect.

devhammed commented 4 years ago

@Blacksmoke16 No, I am the owner of the file and it is in my home folder...If you have worked with PHP, you will know composer.json file.

Look at below screenshot and tell me it is the file permissions issue:

Screenshot from 2020-07-09 14-08-08

Blacksmoke16 commented 4 years ago

@devhammed Huh, interesting. Now I'm really curious as to why I don't run into this problem. In this case I would expect the static binary off the latest Github release would work fine. Could you give that a try just to make sure it doesn't reproduce with that? Assuming it doesn't, this change is 👍 , if it does, then I'm going to be even more curious ha.

devhammed commented 4 years ago

I won 🤣🤣🤣

Screenshot from 2020-07-09 14-58-00

Blacksmoke16 commented 4 years ago

Thanks @devhammed. Still not sure why I didn't run into this. Can you install using --edge and ensure that it works correctly for you now?

devhammed commented 4 years ago

@Blacksmoke16 , Here we are 🥰🥰🥰

Screenshot from 2020-07-10 08-15-19

And it is still surprising it is working there without the home and removable-media plugs.