• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Executing java process as some other user

 
veerabahu Subramanian
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I need to run a perl code from java code in solaris. I used . I am running the java code as root user. The perl executable has different ownership permission. Moreover the root user doesn't have permission to execute the perl executable. In short its like this
-rwxr-x--- 1 myownuser:myowngroup 10816 Aug 10 05:56 perl
root user is not part of myowngroup. So when i execute the java program i am getting the following exception


  • [list]How can i solve the above issue. One thing i can think of is changing the permission of the executable (even with in java code) before actually running perl script. But i wont be able to do this because of certain constraints.
  • When i run perl test.pl i am able to get the output. Here too i should get some exception rite, because the command is getting executed as a root.
  •  
    Jeanne Boyarsky
    author & internet detective
    Marshal
    Posts: 34225
    341
    Eclipse IDE Java VI Editor
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    The root user has permission to do anything regardless of the permission bits.

    Does "perl test.pl" work if you run it through the command line rather than through Java?
     
    veerabahu Subramanian
    Greenhorn
    Posts: 17
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Yes, i am able to run through command line. Hmm..if root user has everything to do then whats might be the other reasons for this error.
     
    veerabahu Subramanian
    Greenhorn
    Posts: 17
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Adding to this when i give execute permission for the other user of perl executable i am able to run everything. I dont get any exceptions. In short

    -rwxr-x--x 1 myownuser myowngroup 10816 Jun 9 20:30 perl

    Works fine.
     
    Jeanne Boyarsky
    author & internet detective
    Marshal
    Posts: 34225
    341
    Eclipse IDE Java VI Editor
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    It sounds like Java is running as a user with less permissions than root. Maybe some kind of "run as" is in play?
     
    veerabahu Subramanian
    Greenhorn
    Posts: 17
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Jeanne, Java is running as a root user, confirmed the same using ps -ef. My question is exactly how to set that "run as" pro grammatically in java.
     
    Stefan Wagner
    Ranch Hand
    Posts: 1923
    Linux Postgres Database Scala
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Sounds like a topic we had before:

    http://www.coderanch.com/t/110810/Linux-UNIX/Super-user-unix-not-honoured

    Ernest Friedmann-Hill had a look at the source code, and found out, that Java is checking permissions (user, group, other) without checking whether the user is root, and therefore bypassing the normal permissions.

    Perhaps the suggested bugreport was never made.
     
    veerabahu Subramanian
    Greenhorn
    Posts: 17
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Thanks Stefan, its exactly the same.
     
    • Post Reply
    • Bookmark Topic Watch Topic
    • New Topic