CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Feb 2008
    Posts
    1

    Smile web start program needs root privilege in linux

    I wrote a Java program which uses JNI to call functions in a native library (.so in linux).
    The native library needs root privilege to access /dev/sdb1.
    The program runs fine if we run it with root privilege (sudo ... in ubuntu).
    Otherwise, it fails with no privilege error when opening /dev/sdb1.

    The problem is that the java program is designed to be a Java web start program.
    A non-root user clicks a jnlp link in a web page or double clicks a downloaded jnlp file to start the program. Thus the program fails since no root privilege in linux (ubuntu).
    How to solve this problem ?

    (? like pop up a dialog and ask the user to enter a password and run the program with root privilege)

  2. #2
    Join Date
    May 2006
    Location
    UK
    Posts
    4,473

    Re: web start program needs root privilege in linux

    (? like pop up a dialog and ask the user to enter a password and run the program with root privilege)
    I think you have answered your own question.

    Once you have the root password you should be able to change to root by using java.lang.ProcessBuilder to create a Process to run the su command.

    You will probably have to sign your jar and provide your own security policy to allow the application access to run the process.
    Posting code? Use code tags like this: [code]...Your code here...[/code]
    Click here for examples of Java Code

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured