简体   繁体   中英

Is there a Linux Service

I am writing a program in java for an embedded linux platform. One of the OS features I need has to run as root to get access. The platform I am using is the BeagleBone Black and I want to control the Gpio pins using a memory map. I have access to the memory map and can switch the pins on and off at a very fast rate. The problem is, I don't want my program to have to run as super user, at least it doesn't seem right to implement it that way.

Is there a standard technology in linux that will run as root and let a user program make calls to it?

I know there must be, I just don't know what it is. Any help would be appreciated.

What you want to do is to drop privileges . Instead of having any process running as root for the duration, this allows a process to start as root, open resources, and then change to a different, unprivileged user. You'll still need to start the program as root, which can be done with a setuid script so that you don't need the user to be root already to run it. (This is done with other programs, like sudo .)

You can open the file as root, and then change the uid of the program to an unprivileged user (presumably the user that started the program). Take a look at this answer to see how to drop privileges in Java using JNI, and this answer for more information about a robust way to drop privileges in general.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM