Win a copy of Reactive Streams in Java: Concurrency with RxJava, Reactor, and Akka Streams this week in the Reactive Progamming forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Junilu Lacar
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • Tim Cooke
  • Devaka Cooray
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Ganesh Patekar

obtain root privileges

 
Greenhorn
Posts: 4
  • 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.
 
Bartender
Posts: 9583
13
Mac OS X Linux Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
sudo
 
Ranch Hand
Posts: 3061
  • 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
 
Ranch Hand
Posts: 149
  • 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
  • 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 ]
 
Something must be done about this. Let's start by reading this tiny ad:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!