I have some code which uses
sched_param sched; sched.sched_priority = 70; sched_setscheduler(getpid(), SCHED_FIFO, &sched);
However, this function will fail unless I run the application with
sudo. I'd rather not run the application with
Is there a way for me to grant a user or process access to this function without granting full root permissions?
-- Edit --
derobert gave a great answer about using capabilities. In
postinst, I simply add:
setcap cap_sys_nice+ep /path/to/myapp
The problem here is:
bin$ ./myapp ./myapp error while loading shared libraries: libmylib.so: cannot open shared object file: No such file or directory
The program loses the ability to dynamically load libraries from
$LD_LIBRARY_PATH or (in my case) other libraries pointed by
rpath. This appears to be intended behaviour. Is there a way around this?
setcap cap_setpcap+ep myapp then using
prctl(PR_CAPBSET_DROP, CAP_SETPCAP); before I do any of the dynamic loading, but that doesn't seem to help.