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

PHP URL commands not activating visualizations. #2

Open
Codename-11 opened this issue Oct 2, 2019 · 8 comments
Open

PHP URL commands not activating visualizations. #2

Codename-11 opened this issue Oct 2, 2019 · 8 comments

Comments

@Codename-11
Copy link

I was able to successfully implement Scotts original and everything works fine. I stumbled across your fork which solved the issue of controlling the on/off state of the LED strip and visualizations. Thank you kindly for that! Very handy feature. I'm having a problem however with getting the visualization('s) to execute via the URL. Everything works as intended using the command line arguments to change the visualization. I do have Apache2 and PHP installed. I did test a couple simple "hello world" and print date PHP index files to insure that Apache could run PHP scripts, which were successful. The http://ip-address/control.php?on=spectrum returns nothing on the page (expected) but does not start the visualization (unexpected). http://ip-address/control.php?off=1 reutrns sudo: no tty present and no askpass program specifiednada, not sure why... Any suggestions? Thanks!

@naztronaut
Copy link
Owner

That looks like a permissions issue. What's in your /etc/sudoers file? Do you see anything that says tty there? If you do, try disabling it and try again.

@Codename-11
Copy link
Author

I was able to get it to work!
I checked the sudoers file and there's nothing listed pertaining to TTY. I made sure all the files in /var/www/html are owned by the www-data user/group.

I did some googling on the error and it pertaining to Apache and found that I needed to give the user www-data permissions to use python in the sudoers file. For the sake of testing, I used ww-data ALL = NOPASSWD: /usr/bin/python, however I do think it's probably a security flaw to have NOPASSWD, so ether I have to see how to restrict the user's privilege to only execute visualization.py and or add a password for said command to be executed.

Thanks for the help! Prehaps we should add something about this to the README?

naztronaut added a commit that referenced this issue Oct 3, 2019
@naztronaut
Copy link
Owner

It's very strange that you ran into this. You shouldn't have to do that. Did you make sure that www-data owned all the files in /var/www/html (listed in Browser Setup)? If you did and you still got the error, my mind is stuck.

@naztronaut
Copy link
Owner

naztronaut commented Oct 3, 2019

I also added a new troubleshooting section and referenced this issue and the workaround you posted: https://github.com/naztronaut/dancyPi-audio-reactive-led#troubleshooting

Thanks for doing that!

And I'm really glad you got it to work :) congrats!!

@Codename-11
Copy link
Author

The user www-data does own all the files inside of /var/www/html.
Screenshot_20191003_122133
The only file that isn't owned by www-data is the index.php I created which just shows a line of text on the page describing what it's for. I did try removing that and attempting to run the visuals as stated in Browser Setup, but to no avail. I will do a freash install again when I get the chance and work it backwards and see if I can find out a cause since you're saying that I shouldn't need to give www-data Python permissions in the sudoers file. I'll let you know what I come up with.

Unrelated to this issue, but if you're interested I also came up with a solution for controlling the strips visualization and on/off using your repository via Home Assistant. It doesn't use the web server, it uses SSH to remotely run the commands and an automation to run sudo killall python and run off.py in sequence so no conflicts happen. I couldn't have done this without your expansion on Scott's repo, so I really appreciate the work man. I'd love to contribute where I can! Let me know.

@naztronaut
Copy link
Owner

It might work if you have www-data own index.php. Since it's owned by root, www-data doesn't have access unless you allow it through the sudoers list. Good luck with your fresh install! Let me know how that goes.

I'm interested in learning about your home assistant setup! That's actually been on my list todo for a while but I haven't had any time to work on it. Would love to see what you have :) Thanks!

@NickSutton
Copy link

I’m not sure the workaround you added with the sudoers file covers the sudo killall python command in control.php when passing the off=1 URL variable?

@NickSutton
Copy link

For info, changing your trouble shooting to: www-data ALL=(ALL) NOPASSWD: ALL Will allow your php pages to run the sudo killall python command and correctly stop the LEDs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants