Hi all,
I’m trying to write a packaging script in perl on a Suse 11.0 system – basically, it checks out java files from our cvs system, compiles them with javac and creates a bundle. Since the files must be assigned to a special user, I sudo the script and switch the user/group by changing $> and $).
The whole script works basically, however I’ve noticed a very weird problem: although all folders created and files checked out from the cvs do have the right owner/group, the folder/files generated by javac still belong to root:root!
I’ve been able to reproduce the problem in a very short script:
#!/usr/bin/perl
use strict;
$) = 8; # group 'www'
$> = 1357; # user 'docu-user'
mkdir "test";
my $command = "/usr/bin/javac -cp \"\" -d test test.java";
system $command;
Note 1: you’ll notice the empty classpath in the javac call. If I don’t add that, then I get an error message:
/usr/bin/javac: error while loading shared libraries: libjli.so: cannot open shared object file: No such file or directory
I have absolutely no idea why not setting the classpath (especially to empty) prevents javac from finding its library, but well.
Note 2: test.java contains a very basic HelloWorld program declared in package pack.test.
Now if I run this script with sudo, everything works fine, however directory test contains the following:
> sudo perl test2.pl
> ls -alR test
test:
total 3
drwxr-xr-x 3 docu-user www 512 2009-11-24 15:54 .
drwxrwxrwx 4 pagod users 512 2009-11-24 15:54 ..
drwxr-xr-x 3 root root 512 2009-11-24 15:54 pack
test/pack:
total 3
drwxr-xr-x 3 root root 512 2009-11-24 15:54 .
drwxr-xr-x 3 docu-user www 512 2009-11-24 15:54 ..
drwxr-xr-x 2 root root 512 2009-11-24 15:54 test
test/pack/test:
total 3
drwxr-xr-x 2 root root 512 2009-11-24 15:54 .
drwxr-xr-x 3 root root 512 2009-11-24 15:54 ..
-rw-r--r-- 1 root root 424 2009-11-24 15:54 Test.class
Does anyone have any idea why this happens? As I said before, this doesn’t happen when I’m calling cvs or creating other files/folders. How can javac create files as root although it’s supposedly not the active user?? I’ve tried in several different shells, with different users, the result is always the same
Thx a lot for any help anyone can provide!
Pagod