LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 01-12-2020, 06:05 AM   #1
Alphonse
LQ Newbie
 
Registered: May 2017
Posts: 6

Rep: Reputation: Disabled
Question user permission to launch a program? (cec-client, raspbian and openHAB)


Hello everybody!
Quote:
Hardware:Raspberry Pi 4, software: raspbian buster, manually installed openHAB (from apt) and cec-client
Im trying to add my dumb-tv (HDMI-cec-enabled Toshiba) to my openHAB home automation system, to turn the TV on and off via cec-commands.


The command works fine for the default pi user, but the user openhab is unable to execute the command.

The cec-commands in question are: echo "standby 0 | cec-client RPI -s -d 1
and echo "on 0 | cec-client RPI -s -d 1


Ive tryed sudo su -u openhab echo "standby 0 | cec-client RPI -s -d 1
witch resulted in a new line in terminal, with only a ">".
"sudo su -u openhab ls" does show a list of items in the current folder, so it feels like the openhab user is not allowed to execute the cec-client program.


Now, i did find out the list of groups that these users belong to, and i figure that i might solve this issue by adding openhab to one of them, but i havent a clue regarding what specific group could be the important one...

pi@openHABserver:~$ groups pi
pi : pi adm tty dialout cdrom sudo audio video plugdev games users input netdev bluetooth spi i2c gpio openhab
pi@openHABserver:~$ groups openhab
openhab : openhab tty dialout audio bluetooth gpio



Ive searched the web, but im unable to find out how to check what permissions are needed to execute a program in linux..

And unfortunately, i will not be able to run my commands under another user, openHAB runs under openhab user and all commands executed thru openHAB will be executed as openhab, witch is not a member of sudoers, nor should it for security reasons.


So i need a way to fix this but my linux skills are rudimentary at best..
Does anyone have any ideas, hints or suggestions?
 
Old 01-12-2020, 08:07 AM   #2
hazel
LQ Guru
 
Registered: Mar 2016
Location: Harrow, UK
Distribution: LFS, AntiX, Slackware
Posts: 7,611
Blog Entries: 19

Rep: Reputation: 4458Reputation: 4458Reputation: 4458Reputation: 4458Reputation: 4458Reputation: 4458Reputation: 4458Reputation: 4458Reputation: 4458Reputation: 4458Reputation: 4458
I don't think sudo works with redirection. Try launching a shell with sudo and getting that to do the work, something like sudo sh -c echo "standby 0 | cec-client RPI -s -d 1.
 
Old 01-12-2020, 08:25 AM   #3
Alphonse
LQ Newbie
 
Registered: May 2017
Posts: 6

Original Poster
Rep: Reputation: Disabled
im not sure if im really understanding the result correctly, but my command works fine if i type: "sudo su -u pi" before my cec-command.
Im logged in as pi when executing the command above, so im not sure im actually changing the user or if the su-part gets skipped since im aready the pi user..

but i am able to list folder (ls) as openhab with the "sudo su -u openhab ls".


so i think that i will need to allow the user openhab to use the cec-client somehow, but i doubt sudo should be involved..
 
Old 01-12-2020, 09:05 AM   #4
hazel
LQ Guru
 
Registered: Mar 2016
Location: Harrow, UK
Distribution: LFS, AntiX, Slackware
Posts: 7,611
Blog Entries: 19

Rep: Reputation: 4458Reputation: 4458Reputation: 4458Reputation: 4458Reputation: 4458Reputation: 4458Reputation: 4458Reputation: 4458Reputation: 4458Reputation: 4458Reputation: 4458
You could also use su -c, then put the actual command in quotes. But then you would need to use the root password. Or perhaps you could set the suid bit on cec-client so that it ran as root whoever launched it.
 
Old 01-12-2020, 09:22 AM   #5
berndbausch
LQ Addict
 
Registered: Nov 2013
Location: Tokyo
Distribution: Mostly Ubuntu and Centos
Posts: 6,316

Rep: Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002
Quote:
Originally Posted by Alphonse View Post
Ive tryed sudo su -u openhab echo "standby 0 | cec-client RPI -s -d 1
witch resulted in a new line in terminal, with only a ">".
Looks like you forgot the closing double-quote. The ">" prompt is issued when something is missing.
Quote:
Ive searched the web, but im unable to find out how to check what permissions are needed to execute a program in linux..
Linux and UNIX have a simple permissions model. An executable file has separate read, write or execute permissions (or a combination thereof) for three sets of accounts: The file's owner, its group, and anybody else. The comnands ls -l and stat reveal those permissions.
 
1 members found this post helpful.
Old 01-12-2020, 12:09 PM   #6
Alphonse
LQ Newbie
 
Registered: May 2017
Posts: 6

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by berndbausch View Post
Looks like you forgot the closing double-quote. The ">" prompt is issued when something is missing.
sorry, my bad; it was a bad copy/paste; the command is:
echo standby 0 | cec-client -s -d 1


Thank you kindly for illuminating the permissions situation!
I added the openhab user to pi group and now im allowed to execute the command!



thanks everyone for the assist!

Last edited by Alphonse; 01-12-2020 at 04:33 PM.
 
Old 01-13-2020, 06:05 AM   #7
hazel
LQ Guru
 
Registered: Mar 2016
Location: Harrow, UK
Distribution: LFS, AntiX, Slackware
Posts: 7,611
Blog Entries: 19

Rep: Reputation: 4458Reputation: 4458Reputation: 4458Reputation: 4458Reputation: 4458Reputation: 4458Reputation: 4458Reputation: 4458Reputation: 4458Reputation: 4458Reputation: 4458
Please mark it as solved then.
 
  


Reply

Tags
hdmi, permissions, raspberry pi



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: Raspberry Pi: Power On / Off A TV Connected Via HDMI-CEC LXer Syndicated Linux News 0 07-02-2019 11:38 PM
LXer: Raspbian GNU/Linux upgrade from Wheezy to Raspbian Jessie 8 LXer Syndicated Linux News 1 06-09-2016 12:12 PM
LXer: HDMI CEC Fuzzing LXer Syndicated Linux News 0 08-09-2015 06:03 PM
LXer: Linux Support For HDMI CEC Still In Development LXer Syndicated Linux News 0 10-09-2012 04:10 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 11:22 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration