• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

obtain root privileges

 
Marc Verschueren
Greenhorn
Posts: 4
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Joe Ess
Bartender
Posts: 9214
9
Linux Mac OS X Windows
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
sudo
 
Layne Lund
Ranch Hand
Posts: 3061
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Jeffrey Spaulding
Ranch Hand
Posts: 149
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 4
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic