0

I installed psensor on my server which I access with RDP.

The problem is psensor requires permissions to read SMART status of hard drives, and I have about 10 installed.

To avoid typing my root password 10 times I ran with sudo, but this does not work because Xlib cannot open the display.

How can I permit psensor to run with higher level privilages as a non sudo-user?

#Update:

This is for example

/dev/sda: brw-rw---- 1 root disk 8, 0 Sep 28 20:35 /dev/sda

(see comments)

3
  • 1
    What are the permissions and ownerships of the /dev/ entries of the disks? If they allow group access, could adding yourself to the group help? Is it worth the risk to make pfsensor setuid? Also read man -a capability. Capabilities are a newer way of permitting things.
    – waltinator
    Sep 29 '20 at 18:38
  • @waltinator This is for example /dev/sda: brw-rw---- 1 root disk 8, 0 Sep 28 20:35 /dev/sda. Does that answer your question? Sep 29 '20 at 19:40
  • Please edit your post to add new information, properly formatted. Information added via comments is hard for you to format, hard for us to read, ignored by AskUbuntu's indexing system, and ignored by future readers. Please click edit and add that vital information to your question so all the facts we need are in the question. Please don't use Add Comment, since that's our uplink to you. All facts about your system should go in the Question with edit
    – waltinator
    Sep 30 '20 at 1:00
0

You just need to follow through with the appropriate authentication. By default sudo removes all non-essential variables from the environment and sets HOME to the target user, but in this case you need to revert one or two of them back:

sudo HOME="$HOME" psensor …

If that's insufficient, try this

sudo HOME="$HOME" DISPLAY="$DISPLAY" psensor …

Note that this will enable root to write to your home directory as if it is its own. Occasionally that will result in root-owned files (or worse, directories) in your own directory that you cannot directly access or delete. If that's not acceptable, try one of these more long-winded alternatives

sudo bash -c "cp -p $HOME/.Xauthority ~ && psensor …"
sudo DISPLAY="$DISPLAY" bash -c "cp -p $HOME/.Xauthority ~ && psensor …"

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.