Author

Topic: PermissionError: [Errno 13] Permission denied: .... but only under normal user (Read 225 times)

newbie
Activity: 7
Merit: 0
Hi,

so I installed Electrum as suggested but I really can't get my head around why root can launch this programme and the ordinary user can't. I first thought that this was to do with my normal user having Anaconda installed so I checked my Anaconda environments.

You'll see below that even when Python 2.7 is activated (which is default installed version system wide and therefore the version that would be launching the software with sudo ....), its still complaining about permissions. Any further pointers?

I definitely shoudln't be changing permissions manually, this is not the right way to resolve the problem?

Thanks

[dom giu 03, 12:11 ][user@pc:~]electrum
/usr/bin/python3: can't open file '/usr/local/bin/electrum': [Errno 13] Permission denied

[dom giu 03, 12:11 ][user@pc:~]sudo electrum                              (program runs here)
[dom giu 03, 12:12 ][user@pc:~]sudo python --version
Python 2.7.13
[dom giu 03, 12:13 ][user@pc:~]python --version
Python 3.5.5 :: Anaconda custom (64-bit)
[dom giu 03, 12:14 ][user@pc:~]source activate Python27
(Python27) [dom giu 03, 12:14 ][user@pc:~]python --version
Python 2.7.13 :: Continuum Analytics, Inc.
(Python27) [dom giu 03, 12:14 ][user@pc:~]electrum
/usr/bin/python3: can't open file '/usr/local/bin/electrum': [Errno 13] Permission denied
(Python27) [dom giu 03, 12:15 ][user@pc:~]


legendary
Activity: 3682
Merit: 1580
You have two options. Run this command to set the correct permissions for all files in the directory:

Code:
sudo find /usr/local/lib/python3.5/dist-packages/ -type f -exec chmod 644 {} \;

Or do a `sudo pip3 uninstall electrum` and the install electrum again as a normal user using `pip3 --user install `. This will install electrum under ~/.local/ so to run it do  `~/.local/bin/electrum` . You can also add ~/.local/bin/ to your PATH variable by adding this line in ~/.bashrc:

Code:
export PATH="$PATH:$HOME/.local/bin"

Adding it to your path means you can just run it with `electrum`
HCP
legendary
Activity: 2086
Merit: 4361
Honestly no idea... Either something funky with your setup that has defaulted the permissions to something that is interfering with the way Python likes to load imports or the install process isn't setting it up right... Huh

Honestly, I don't have a lot of experience using the "s" and "S"  setuid/setgid... So it's probably better if someone else chimes in at this point Wink

Also, maybe try raising an issue on the Electrum GitHub? See if the Devs are aware of anything in the install process that might be causing this issue.
newbie
Activity: 7
Merit: 0
mmm, so I tried all that but nbow look what I get below. There seems to be a wider problem. How is it that permissions weren't set properly during the install process?


[mar mag 29, 12:01 ][user@machine:~]electrum
Traceback (most recent call last):
  File "/usr/bin/electrum", line 80, in
    check_imports()
  File "/usr/bin/electrum", line 65, in check_imports
    import google.protobuf
  File "/usr/lib/python3/dist-packages/google/protobuf/__init__.py", line 37, in
    __import__('pkg_resources').declare_namespace(__name__)
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 3019, in
    @_call_aside
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 3003, in _call_aside
    f(*args, **kwargs)
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 3032, in _initialize_master_working_set
    working_set = WorkingSet._build_master()
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 646, in _build_master
    ws = cls()
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 639, in __init__
    self.add_entry(entry)
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 695, in add_entry
    for dist in find_distributions(entry, True):
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 2012, in find_on_path
    if len(os.listdir(fullpath)) == 0:
PermissionError: [Errno 13] Permission denied: '/usr/local/lib/python3.5/dist-packages/qrcode-6.0.dist-info'
HCP
legendary
Activity: 2086
Merit: 4361
Yeah... Looks like the permissions for that pbkdf2.py
(and the other file noted but Abdussamad's) hasn't been set correctly (for whatever reason)... its basically "read and write" for root only??!? Huh

Try setting them as per Abdussamad's post.
legendary
Activity: 3682
Merit: 1580
Try: `sudo chmod 644 sockshandler.py pbkdf2.py`
newbie
Activity: 7
Merit: 0

It seems that for whatever reason, running as a non-root user, you don't have access to read the pbkdf2.py python library... Huh Have you checked the permissions on both the directory (/usr/local/lib/python3.5/dist-packages/) and the file itself?

How did you originally install Python... and the packages? Did you use pip?


Right, so the version that I referred to in my original post was from the Debian Stretch backports, the most recent avaialble in the Debian world. I prefer to stick to the Debian way as using pip3 messes up the python environment with libraries etc that end up conflicting with apt-get.

That said, I also tried the pip3 way as described on the Electrum website with the most recent version. That too failed and was giving me the exact same problems. Yes, I think it is a permissions problem but I thought pip3 install would take care of that? I've just checked permissions and I think they a bit messed up on that folder. See below, does this look alright to you? BTW, my user is member of the staff group. You can see that most of the stuff in that folder was installed yesterday.

lun mag 28, 10:48 ][user@machine:~]ls -al /usr/local/lib/python3.5/dist-packages/
totale 132K
4,0K drwxrwsr-x 20 root staff 4,0K mag 27 04:20 .
4,0K drwxrwsr-x  3 root staff 4,0K ott 14  2017 ..
4,0K drwx--S---  4 root staff 4,0K mag 27 03:22 dns
4,0K drwx--S---  2 root staff 4,0K mag 27 03:22 dnspython-1.15.0.dist-info
4,0K drwx--S---  3 root staff 4,0K mag 27 03:22 ecdsa
4,0K drwx--S---  2 root staff 4,0K mag 27 03:22 ecdsa-0.13.dist-info
4,0K drwx--S---  5 root staff 4,0K mag 27 03:22 electrum
4,0K drwx--S---  2 root staff 4,0K mag 27 03:22 Electrum-3.1.3.dist-info
4,0K drwx--S---  3 root staff 4,0K mag 27 03:22 google
4,0K drwx--S---  3 root staff 4,0K mag 27 03:22 jsonrpclib
4,0K drwx--S---  2 root staff 4,0K mag 27 03:22 jsonrpclib_pelix-0.3.1.dist-info
4,0K drwx--S---  2 root staff 4,0K mag 27 03:22 pbkdf2-1.3.dist-info
 12K -rw-------  1 root staff 9,9K mag 27 03:22 pbkdf2.py
4,0K drwx--S---  2 root staff 4,0K mag 27 03:22 protobuf-3.5.2.post1.dist-info
4,0K -rw-------  1 root staff  539 mag 27 03:22 protobuf-3.5.2.post1-py3.5-nspkg.pth
4,0K drwx--S---  3 root staff 4,0K mag 27 03:22 pyaes
4,0K drwx--S---  2 root staff 4,0K mag 27 03:22 pyaes-1.6.1.dist-info
4,0K drwx--S---  2 root staff 4,0K mag 27 03:22 __pycache__
4,0K drwx--S---  2 root staff 4,0K mag 27 03:22 PySocks-1.6.8.dist-info
4,0K drwx--S---  5 root staff 4,0K mag 27 03:22 qrcode
4,0K drwx--S---  2 root staff 4,0K mag 27 03:22 qrcode-6.0.dist-info
4,0K -rw-------  1 root staff 2,9K mag 27 03:22 sockshandler.py
 32K -rwxr-xr-x  1 root staff  32K mag 27 03:22 socks.py
4,0K drwx--S---  3 root staff 4,0K mag 27 03:22 usr
HCP
legendary
Activity: 2086
Merit: 4361
PermissionError: [Errno 13] Permission denied: '/usr/local/lib/python3.5/dist-packages/pbkdf2.py'
It seems that for whatever reason, running as a non-root user, you don't have access to read the pbkdf2.py python library... Huh Have you checked the permissions on both the directory (/usr/local/lib/python3.5/dist-packages/) and the file itself?

How did you originally install Python... and the packages? Did you use pip?



Just FYI, as far as the off topic stuff around gpg verification goes... the signature file needs to come first Wink
Quote
gpg: no valid OpenPGP data found.
gpg: the signature could not be verified.
Please remember that the signature file (.sig or .asc)
should be the first file given on the command line.


so the command should be:
Code:
gpg --verify Electrum-3.1.3.tar.gz.asc verify Electrum-3.1.3.tar.gz

It's unnecessary though... gpg will assume the file to check is named the same (minus the .sig or .asc)... so bob123's command will work:
Code:
foo@fooPC:~$ gpg --verify Electrum-3.1.3.tar.gz.asc
gpg: assuming signed data in `Electrum-3.1.3.tar.gz'
gpg: Signature made Thu 19 Apr 2018 03:10:44 AM STD using RSA key ID 7F9470E6
gpg: Good signature from "Thomas Voegtlin (https://electrum.org) "
legendary
Activity: 3472
Merit: 10611
And to verify:
Code:
gpg --verify Electrum-3.1.3.tar.gz.asc

i believe this line of code verifies that the signature file (the .asc) file is a signature that was created by that particular key (7F9470E6). but that is not what you want.
what you want to do instead is to check if the file (the .exe or tarball=tar.gz file) is signed with that particular key. for this you have to check the signature and the file.
Code:
gpg --verify Electrum-3.1.3.tar.gz Electrum-3.1.3.tar.gz.asc

p.s. it also isn't necessary to include a keyserver when downloading pubkeys, that is optional.
legendary
Activity: 1624
Merit: 2481
I've downloaded the electrum version 3.0.6'

You should stop using that version and download/install the newest version (3.1.3):

Dependencies:
Code:
sudo apt-get install python3-setuptools python3-pyqt5 python3-pip

Electrum:
Code:
sudo pip3 install https://download.electrum.org/3.1.3/Electrum-3.1.3.tar.gz

Old versions are vulnerable under specific circumstances.


To verify your download:

Code:
gpg --keyserver keyserver.ubuntu.com --recv-keys 7F9470E6
This will download ThomasV's Signing key.


And to verify:
Code:
gpg --verify Electrum-3.1.3.tar.gz.asc
newbie
Activity: 7
Merit: 0
Hi,
I've downloaded the electrum version 3.0.6-1 that is on Debian Stretch backports. There is no way to get it fired up under a normal user. The errors are below. The version of python installed on my system is 3.5.3-1. I find it strange that it fires up is i run "sudo electrum -v" but it doesn't if I don't. It's clearly a question of permissions but can't work out if this is a electrum issue of not. Any pointers?

Thanks

(base) [dom mag 27, 05:58 ][user@system1:~]electrum -v
Traceback (most recent call last):
File "/usr/bin/electrum", line 80, in
check_imports()
File "/usr/bin/electrum", line 64, in check_imports
import pbkdf2
File "", line 969, in _find_and_load
File "", line 958, in _find_and_load_unlocked
File "", line 673, in _load_unlocked
File "", line 669, in exec_module
File "", line 774, in get_code
File "", line 826, in get_data
PermissionError: [Errno 13] Permission denied: '/usr/local/lib/python3.5/dist-packages/pbkdf2.py'
Jump to: