Jurgen
thanks your input is noted.
I thought so `setuid()' would be problem, Linux Threads is exactly the problem.
You would have thought `setuid(0)' would make every single Java Thread
root user, but on Linux this, of course, does not work as expected.
I'ill doc this up and put on the web.
--
I used to live a small town "B-a-r-t-e-r-s-e-a",
over the bridge from the royal bluesy Chelsea,
Stamford bridge and all, I grew up, I lived, I worked,
played the lottery, and found it all just so may be,
Still the house price index got me going
---------------------------------------- Message History
----------------------------------------
From: [EMAIL PROTECTED] on 13/10/2000 19:22
To: Peter Pilgrim/DMGIT/DMG UK/DeuBa@DMG UK
cc: [EMAIL PROTECTED]
Subject: Re: [ANNOUNCE] Java Unix API pre 1.0
>>>>> "Peter" == Peter Pilgrim <[EMAIL PROTECTED]> writes:
Peter> `JavaUnix' is a portable extension API
Please note that some of these functions are not that portable -- not
even between JVMs on Linux.
E.g.
Peter> (*) Access to UNIX account identification:
Peter> `getuid()' / `setuid()'
The attached test program gives the following output with 1.3 green
threads:
% java -green UIDTest 1000
Thread[main,5,main] 0
Thread[second,5,main] 0
Setting UID to 1000
Thread[main,5,main] 1000
Thread[second,5,main] 1000
with the classic native threads VM or HotSpot it deadlocks:
% java -client UIDTest 1000
Thread[main,5,main] 0
Thread[second,5,main] 0
Setting UID to 1000
Thread[main,5,main] 1000
# 'second' doesn't wake up
If the test wouldn't hang the last line would be
Thread[second,5,main] 0
because UIDs are per-thread with LinuxThreads.
Juergen
PS: Some stuff I've noticed
* Building only works if "." is in PATH
* jar packaging doesn't work
* "extern pid_t getsid(pid_t pid);" should be "extern "C" ..."
(if you define _GNU_SOURCE you don't need this at all)
import javaunix.*;
public class UIDTest
{
static Object lock = new Object();
static boolean started = false;
static boolean goon = false;
public static void main(String[] args)
throws Throwable
{
System.out.println(Thread.currentThread() +
" " +
UnixSystem.getUid());
Thread t = new Thread(new Runnable() {
public void run()
{
System.out.println(Thread.currentThread() +
" " +
UnixSystem.getUid());
synchronized (lock) {
started = true;
lock.notify();
while (!goon) {
try {
lock.wait();
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
System.out.println(Thread.currentThread() +
" " +
UnixSystem.getUid());
}
}, "second");
t.start();
synchronized (lock) {
while (!started) {
lock.wait();
}
int uid = Integer.parseInt(args[0]);
System.out.println("Setting UID to " + uid);
UnixSystem.setUid(uid);
System.out.println(Thread.currentThread() +
" " +
UnixSystem.getUid());
goon = true;
lock.notify();
}
t.join();
}
}
--
Juergen Kreileder, Blackdown Java-Linux Team
http://www.blackdown.org/java-linux.html
JVM'01: http://www.usenix.org/events/jvm01/
--
This e-mail may contain confidential and/or privileged information. If you are not the
intended recipient (or have received this e-mail in error) please notify the sender
immediately and destroy this e-mail. Any unauthorised copying, disclosure or
distribution of the material in this e-mail is strictly forbidden.
----------------------------------------------------------------------
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]