I'm new to programming JAVA 5 on MAC OS X 10.4 and now i would like to make a class where a process is started that needs to have root priviledges. I've searched for several hours and can't find a clue on how to do this.
Can anyone help me with this one or direct me to information regarding this?
What does it need root priveleges for? One posibility is to write your program assuming that it will be run with root priveleges. Then you can run it as root or using sudo. There might be other sophisticated ways to do this as well using third-party security APIs. I'm not familiar with any of these APIs, so I don't have any suggestions there. I still think it will help to answer the first question since it may determine what APIs you should use.
If you run the application from the shell, the permissions are determined by the user that is logged in.
So, if you want to tun something with root privileges, you need to be logged in as root or as someone with rights equal to root.
Marc Verschueren
Greenhorn
Joined: Jul 24, 2005
Posts: 4
posted
0
Thx all very much for replying!
Pointing me to sudo plus other information elsewhere solved my problem.
I needed to be root in the program to be able to start and stop a postgresql server, while logged in as another user, f.i. "marc". To do this one must be logged in as the "postgres" user, so, finally, in my java program i did:
Process proc = new ProcessBuilder("sudo", "su", "postgres", "start").start();
Where "start" is the cmd file which starts the progresql server, and it works just fine (asks the root's password first).
Thx to you all!
Marc. [ August 03, 2005: Message edited by: Marc Verschueren ]