Aug-30-2018, 03:00 PM
I'm trying to use a imported module (pylightning) in a python script that runs using apache under user www-data.
The script gives a permission error when run via apache as user www-data:
Script source:
The script gives a permission error when run via apache as user www-data:
File "/usr/local/lib/python3.4/dist-packages/lightning/lightning.py", line 69, in call sock.connect(self.socket_path) PermissionError: [Errno 13] Permission deniedTo fix this I have intensively searched and found i needed to reinstall the module as www-data user:
sudo pip3 uninstall pylightning sudo -H -u www-data pip3 install pylightningThe script still runs smoothly from the CLI as regular user:
$python3 index.py Content-Type: text/html <html><body> etc...But from apache (through a browser or from the command line as user www-data) still gives the same error:
$sudo -u www-data python3 /var/www/html/index.py Content-Type: text/html <html><body> Traceback (most recent call last): File "/var/www/html/index.py", line 29, in <module> print(rpc_interface.listpeers()) File "/usr/local/lib/python3.4/dist-packages/lightning/lightning.py", line 345, in listpeers return self.call("listpeers", payload) File "/usr/local/lib/python3.4/dist-packages/lightning/lightning.py", line 69, in call sock.connect(self.socket_path) PermissionError: [Errno 13] Permission deniedAnyone has any idea here?
Script source:
#!/usr/bin/env python3 import hashlib from lightning.lightning import LightningRpc rpc_interface = LightningRpc("/home/pi/.lightning/lightning-rpc") print ("Content-Type: text/html\n\n"); print ("</body></html>asd"); print(rpc_interface.listpeers())