0

I have bought https://shop.pimoroni.com/products/pan-tilt-hat , it works fine, but I want to control it through a php webserver, but every time I try, it requires sudo but when I use sudo I get an error in /var/log/apache2/error.log

We trust you have received the usual lecture from the local System
Administrator. It usually boils down to these three things:

    #1) Respect the privacy of others.
    #2) Think before you type.
    #3) With great power comes great responsibility.

sudo: no tty present and no askpass program specified

Another question could be: How do I avoid having to use sudo with the pan tilt hat library

  • Not Pi specific. – joan Jun 15 '18 at 17:13
  • 1
    It is, cause it's the hats python library that won't run without sudo so another question could be how do I avoid having to use sudo with the pan tilt hat library – Harcker Jun 15 '18 at 17:16
  • @Harcker, you only asked one question after your last edit ... your original post had no question – jsotola Jun 16 '18 at 5:25
1

Give the apache user permissions to run sudo commands without password. Assuming the user in question is called www-data, add the following line to your sudoers file:

www-data ALL=(ALL) NOPASSWD:ALL

Once you get that working, you can restrict commands which could be run without password to hat-related only, so if your web server gets hacked, the attacker will not be able to run random commands as root.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.