Story: My kids wanted to start steam and play games on my laptop without starting bumblebee, entering password for sudo, etc. I was looking for a way for how to improve this and one of a sudden I came across nvidia-xrun, which is the way I wanted to run graphical programs on my asus rog laptop, with optimus card. I have begun using nvidia-xrun, which runs perfectly. However, starting it requires sudo operation. Therefore it would be nicer to have setuid kind of alternative to start the script. Also, typically no one invokes sudo during login, even though privileged apps run in the background.
I think setuid is a good fit and it is ok for me to compile a binary, setuid it and start the nvidia-xrun session using the binary. It will help my kid to enter only the following:
nvidia-xrun-setuid-root startxfce4
nvidia-xrun-setuid-root.c:
#include <stdio.h>
#include <unistd.h>
#include <sys/types.h>
#include <string.h>
int main(int argc, char *argv[]) {
char buf[256];
setuid(geteuid());
snprintf(buf, sizeof buf, "nvidia-xrun %s", argv[1]);
printf("Executing as root: %s\n", buf);
system(buf);
}
Just an idea, in case anyone needs it, or you may improve and enhance your product!
Story: My kids wanted to start steam and play games on my laptop without starting bumblebee, entering password for sudo, etc. I was looking for a way for how to improve this and one of a sudden I came across nvidia-xrun, which is the way I wanted to run graphical programs on my asus rog laptop, with optimus card. I have begun using nvidia-xrun, which runs perfectly. However, starting it requires
sudooperation. Therefore it would be nicer to have setuid kind of alternative to start the script. Also, typically no one invokes sudo during login, even though privileged apps run in the background.I think setuid is a good fit and it is ok for me to compile a binary, setuid it and start the
nvidia-xrunsession using the binary. It will help my kid to enter only the following:nvidia-xrun-setuid-root.c:
Just an idea, in case anyone needs it, or you may improve and enhance your product!