0

My goal here is to run the cmatrix script and lock the desktop simultaneously, so that cmatrix will be shown as a screensaver until I come back and unlock the computer.

My script looks like this:

gnome-screensaver-command -l & sudo openvt -ws cmatrix

Now I wanted to make the script be able to run without the need to input the sudo password everytime, so I changed the sudoers file (like this). It is working if I run it in the terminal, so far so good.

Then I added it to the PATH, because I wanted to bind it to the global shortcut Ctrl+Alt+L, but it doesn't work if I invoke it via the shortcut. The desktop just flashes for a split second, like it wanted to show cmatrix, but then it goes straight to the unlock screen.

I figured out that the part with openvt isn't working like it should, even if it is the only thing in the script.

Any ideas how to accomplish what I want?


EDIT: In the split second when the desktop flashes, I managed to read this on the screen:

Error opening terminal: unknown

2 Answers 2

2

Actually now I found the solution myself - the problem and the solution are the same as in this question. I just had to add this line into my script:

export TERM=xterm
0

Take look at this thread: https://unix.stackexchange.com/questions/91541/why-is-path-reset-in-a-sudo-command
Your PATH is being reset when you issue a sudo command, so evil hacker could not change and point it to malicious cmatrix script. So modify your secure path or append exact location of your cmatrix program to the sudo command.

5
  • I don't think this is the problem, since the script works even if I run sudo su before it, so everything is on the PATH of the root user.
    – lmazgon
    Jan 20, 2016 at 13:20
  • @lmazgon: Script works after sudo su because you gain root privileges with su and then run it as 'regular' command from root account. sudo won't let you run commands located outside 'secure' path without providing full path to them. E.g. if you put your script on /unsecure/path/script and then do export PATH=/unsecure/path; sudo script it won't run, but sudo /unsecure/path/script will.
    – nsilent22
    Jan 20, 2016 at 16:21
  • I get your point. Still, everything I am executing is on a secure path, i.e. /usr/bin or /bin. Anyway, I found the solution, thanks for your input!
    – lmazgon
    Jan 20, 2016 at 18:16
  • @lmazgon: If you've found the solution then share it, so you can help others with similar problems.
    – nsilent22
    Jan 20, 2016 at 19:23
  • It is right above yours, I just can't accept the answer yet, because it is my own. I'll do it tomorrow ;)
    – lmazgon
    Jan 20, 2016 at 19:27

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .