Forums Register Login

obtain root privileges

+Pie Number of slices to send: Send
Hi,

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?

Thx!!

Marc.
+Pie Number of slices to send: Send
+Pie Number of slices to send: Send
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.

HTH

Layne
+Pie Number of slices to send: Send
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.
+Pie Number of slices to send: Send
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 ]
These are not the droids you are looking for. Perhaps I can interest you in a tiny ad?
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 2289 times.
Similar Threads
Why is there still interest in (and lots of questions about) applets?
JNDI - can't lookup an object
About Java Tiger
Search FIle System for Pattern Match
Help fixing crash on Mac OS 10.3.9
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 29, 2024 05:17:56.