sebshady
sebshady

Reputation: 141

Gettin key release events in ncurses

Is it possible to detect when keys are released in ncurses?

I managed to get the functionality I want by following the instructions in this answer. However, it requires sudo to work properly, which is not ideal for my use case.

Upvotes: 3

Views: 2090

Answers (1)

Stas Badzi
Stas Badzi

Reputation: 748

If you're problem is that sudo is requiered to run the program, you can give the file permissions to be run as root from any user:

sudo chown root ./prog
sudo chmod u+s ./prog

The chmod u+s makes the program execute form any user as the owner of the file and chown root changes the owner to root. That's actually how sudo elevates permissions - if you check it's permissions (ls -l /usr/bin/sudo) it begins with -rws instread of -rwx like most programs

But remember that if your program allows a user to execute a custom shell command or run a local program that can be edited by the user it creates a serous security issue as then, any user can run commands as root

To avoid this you can have the part of your program that takes input in a seperate binary file or somehow drop priviliges when executing an external program

Upvotes: 0

Related Questions