my dog learned polymorphism*
The moose likes Java in General and the fly likes java and root access Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "java and root access" Watch "java and root access" New topic
Author

java and root access

alexandros mouzakidis
Greenhorn

Joined: Jul 09, 2005
Posts: 13
Well i am working on a packaga manager for a new greek linux distro so i want my program to be run only by users that knows the root passward.Have you got any idea haw can i check the password;And how can i write a java program that runs with super user privilleges;
If i will not find the answers for this problems i have to write the program with c++ and i will have to studt about one weak libraries about making gui so any help i precious


Once upon a time i was on the moon but it was so sad that made me to come back to earth
Michael Ernest
High Plains Drifter
Sheriff

Joined: Oct 25, 2000
Posts: 7292

How do you intend the challenge the user for the root password?


Make visible what, without you, might perhaps never have been seen.
- Robert Bresson
alexandros mouzakidis
Greenhorn

Joined: Jul 09, 2005
Posts: 13
i am thinking about something like yast with an input box that will type the password and the validate this via encryption and check the shadow file
Michael Ernest
High Plains Drifter
Sheriff

Joined: Oct 25, 2000
Posts: 7292

Sooo, you could receive the password, encrypt it the way your system does, and compare it to the shadow entry, yes? If they match, voila.

Your distro I am sure has a command-line utility to delegate the authorization check to.

As to code specifics, there's got to be a Java package out there that has already covered this. C++ doesn't give you anything here except perhaps a more well-known set of tools.
Mr. C Lamont Gilbert
Ranch Hand

Joined: Oct 05, 2001
Posts: 1170

I would expect this to be a facility of the OS. You are going to need to use jni probably since most of linux is c. You can probalby open a shell within your program to execute commands from. it can be hidden from the user. You can change to super user in that shell and should be able to check from that shell if you have the super user as well.
Stefan Wagner
Ranch Hand

Joined: Jun 02, 2003
Posts: 1923

Can't you ask the user to run the entire program as root, via (gk)sudo?

Then you may check by:

whether the user is root or not.


http://home.arcor.de/hirnstrom/bewerbung
alexandros mouzakidis
Greenhorn

Joined: Jul 09, 2005
Posts: 13
Yes this is probably the best solution tank you for your respond
Stefan Wagner
Ranch Hand

Joined: Jun 02, 2003
Posts: 1923

Hmmm. I'm not that sure...



...and made a test.

Can you enforce the programm to be installed by root (perhaps by social practise - not technically) and make it executable-by-root only?

(since jars aren't native executable - (mhmm - sometimes they are) the read-access is critical here, not execute-access.
btw: you're invited to the linux-forum.
alexandros mouzakidis
Greenhorn

Joined: Jul 09, 2005
Posts: 13
I did not get any invitation mail but its ok i made an acount in www.linuxforum.com unless you ment something else.
We r gonna made an application like yast of suse, so the platforma is gonna run only by root and so the jar files r gonna be read only by root and users that have root access. Probably i should try check suse to see thay did it with yast. Thanks again for your respond!!
Stefan Wagner
Ranch Hand

Joined: Jun 02, 2003
Posts: 1923

Well - I meant something else.

In the section 'Engineering' there is a subsection 'Linux/ Unix':

http://www.coderanch.com/forums/f-13/Linux-UNIX

Though it isn't meant for Java-on-Linux-questions only, you will find many topics related to both themes - in contrast to a linux-centric forum.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: java and root access
 
Similar Threads
obtain root privileges
Servlet Web Hosting Rediculous.
setting up enviro parameters?
Convert Video into SWF and FLV format
Convertion of video formats to flash player format