Name: dk106046 Date: 08/19/2004
OPERATING SYSTEM(S):
LinuxIA32, All RH
FULL JDK VERSION(S):
java version "1.4.2-beta"
Java(TM) 2 Runtime Enviornment , Standard Edition (build 1.4.2-beta-b06)
Java HotSpot(TM) Client VM (build 1.4.2-beta-b06, mixed mode)
Exact steps to reproduce:
1)Create two users belonging to same primary group and secondary group
for e.g
uid=501(ben) gid=100(users) groups=100(users),101(maxwell)
uid=500(richard) gid=100(users) groups=100(users),101(maxwell)
2)Build the hello.c file and Wrapper.java file for one user.
for e.g
-rwxr-xr-x 1 richard users 8345 2004-08-02 23:34 hello
3)As root, change the permissions and ownership of the "C" program
to another user
for e.g.
-r-xr-x--- ben:maxwell hello
4) As "richard", the program can still be run
i.e.
[janet:/home/richard/test]hello
o/p--> HelloWorld
But the Java wrapper fails to find the program
[janet:/home/richard/test]java Wrapper
o/p --->
java.io.IOException: java.io.IOException: ./hello: cannot execute
at java.lang.UNIXProcess.<init>(UNIXProcess.java:143)
at java.lang.Runtime.execInternal(Native Method)
at java.lang.Runtime.exec(Runtime.java:566)
at java.lang.Runtime.exec(Runtime.java:428)
at java.lang.Runtime.exec(Runtime.java:364)
at java.lang.Runtime.exec(Runtime.java:326)
at Wrapper.main(Wrapper.java:16)
Source code that demonstrates the problem:-
-----------------------------------------------------------------------
hello.c:
#include <stdio.h>
#include <stdlib.h>
#include <stddef.h>
int main( void )
{
printf( "HelloWorld\n" );
system( "id -a > out.txt" );
return 66;
}
Wrapper.java:
import java.io.IOException;
public class Wrapper {
public static void main(String[] args) {
String program = "./hello";
if (args.length > 0)
{
program = args[0];
}
Runtime r = Runtime.getRuntime();
try {
Process p = r.exec( program );
p.waitFor();
System.out.println( p.exitValue() );
}
catch (IOException e)
{
e.printStackTrace();
}
catch (InterruptedException e)
{
e.printStackTrace();
}
}
}
======================================================================