diff options
author | Matthew Johnson <mjj29@hecate.matthew.ath.cx> | 2008-01-10 17:38:53 +0000 |
---|---|---|
committer | Matthew Johnson <mjj29@hecate.matthew.ath.cx> | 2008-01-10 17:38:53 +0000 |
commit | 7129d7575637b58105008466a5e360f06929b71f (patch) | |
tree | 2436fd7ee4833e650860750b4694f1f807a958d2 /org | |
parent | 068dd0e21458075633632708ae318bbbf81a34f2 (diff) |
oeu
Diffstat (limited to 'org')
-rw-r--r-- | org/freedesktop/dbus/AbstractConnection.java | 1 | ||||
-rw-r--r-- | org/freedesktop/dbus/DBusConnection.java | 1 | ||||
-rw-r--r-- | org/freedesktop/dbus/MessageReader.java | 1 | ||||
-rw-r--r-- | org/freedesktop/dbus/MessageWriter.java | 3 | ||||
-rw-r--r-- | org/freedesktop/dbus/Transport.java | 17 | ||||
-rw-r--r-- | org/freedesktop/dbus/bin/DBusDaemon.java | 4 | ||||
-rw-r--r-- | org/freedesktop/dbus/test/test.java | 2 |
7 files changed, 19 insertions, 10 deletions
diff --git a/org/freedesktop/dbus/AbstractConnection.java b/org/freedesktop/dbus/AbstractConnection.java index 2952150..9ea2359 100644 --- a/org/freedesktop/dbus/AbstractConnection.java +++ b/org/freedesktop/dbus/AbstractConnection.java @@ -547,6 +547,7 @@ public abstract class AbstractConnection */ public void disconnect() { + if (Debug.debug) Debug.print(Debug.INFO, "Disconnecting Abstract Connection"); // run all pending tasks. while (runnables.size() > 0) synchronized (runnables) { diff --git a/org/freedesktop/dbus/DBusConnection.java b/org/freedesktop/dbus/DBusConnection.java index ca15a97..3fa5456 100644 --- a/org/freedesktop/dbus/DBusConnection.java +++ b/org/freedesktop/dbus/DBusConnection.java @@ -581,6 +581,7 @@ public class DBusConnection extends AbstractConnection synchronized (conn) { synchronized (_reflock) { if (0 == --_refcount) { + if (Debug.debug) Debug.print(Debug.INFO, "Disconnecting DBusConnection"); // Set all pending messages to have an error. try { Error err = new Error( diff --git a/org/freedesktop/dbus/MessageReader.java b/org/freedesktop/dbus/MessageReader.java index 9a28a2d..2aec172 100644 --- a/org/freedesktop/dbus/MessageReader.java +++ b/org/freedesktop/dbus/MessageReader.java @@ -168,6 +168,7 @@ public class MessageReader } public void close() throws IOException { + if (Debug.debug) Debug.print(Debug.INFO, "Closing Message Reader"); in.close(); } } diff --git a/org/freedesktop/dbus/MessageWriter.java b/org/freedesktop/dbus/MessageWriter.java index 86b54de..cfbcbc8 100644 --- a/org/freedesktop/dbus/MessageWriter.java +++ b/org/freedesktop/dbus/MessageWriter.java @@ -23,7 +23,7 @@ public class MessageWriter private OutputStream out; public MessageWriter(OutputStream out) { - this.out = new BufferedOutputStream(out); + this.out = out; } public void writeMessage(Message m) throws IOException { @@ -53,6 +53,7 @@ public class MessageWriter } public void close() throws IOException { + if (Debug.debug) Debug.print(Debug.INFO, "Closing Message Writer"); out.close(); } } diff --git a/org/freedesktop/dbus/Transport.java b/org/freedesktop/dbus/Transport.java index a80e8ef..393717b 100644 --- a/org/freedesktop/dbus/Transport.java +++ b/org/freedesktop/dbus/Transport.java @@ -372,7 +372,7 @@ public class Transport } public String challenge = ""; public String cookie = ""; - public int do_response(int auth, String Uid, Command c) + public int do_response(int auth, String Uid, String kernelUid, Command c) { MessageDigest md = null; try { @@ -387,7 +387,8 @@ public class Transport case AUTH_ANON: return OK; case AUTH_EXTERNAL: - if (0 == col.compare(Uid, c.getData())) + if (0 == col.compare(Uid, c.getData()) && + (null == kernelUid || 0 == col.compare(Uid, kernelUid))) return OK; else return ERROR; @@ -455,10 +456,11 @@ public class Transport * Returns true if the auth was successful and false if it failed. */ @SuppressWarnings("unchecked") - public boolean auth(int mode, int types, String guid, OutputStream out, InputStream in) throws IOException + public boolean auth(int mode, int types, String guid, OutputStream out, InputStream in, UnixSocket us) throws IOException { String username = System.getProperty("user.name"); String Uid = null; + String kernelUid = null; try { Class c = Class.forName("com.sun.security.auth.module.UnixSystem"); Method m = c.getMethod("getUid"); @@ -593,6 +595,8 @@ public class Transport case INITIAL_STATE: byte[] buf = new byte[1]; in.read(buf); + if (null != us) + kernelUid = stupidlyEncode(""+us.getPeerUID()); if (0 != buf[0]) state = FAILED; else state = WAIT_AUTH; break; @@ -603,7 +607,7 @@ public class Transport if (null == c.getData()) { send(out, COMMAND_REJECTED, getTypes(types)); } else { - switch (do_response(current, Uid, c)) { + switch (do_response(current, Uid, kernelUid, c)) { case CONTINUE: send(out, COMMAND_DATA, c.getResponse()); current = c.getMechs(); @@ -636,7 +640,7 @@ public class Transport c = receive(in); switch (c.getCommand()) { case COMMAND_DATA: - switch (do_response(current, Uid, c)) { + switch (do_response(current, Uid, kernelUid, c)) { case CONTINUE: send(out, COMMAND_DATA, c.getResponse()); state = WAIT_DATA; @@ -778,7 +782,7 @@ public class Transport throw new IOException(_("unknown address type ")+address.getType()); } - if (!(new SASL()).auth(mode, types, address.getParameter("guid"), out, in)) { + if (!(new SASL()).auth(mode, types, address.getParameter("guid"), out, in, us)) { out.close(); throw new IOException(_("Failed to auth")); } @@ -798,6 +802,7 @@ public class Transport } public void disconnect() throws IOException { + if (Debug.debug) Debug.print(Debug.INFO, "Disconnecting Transport"); min.close(); mout.close(); } diff --git a/org/freedesktop/dbus/bin/DBusDaemon.java b/org/freedesktop/dbus/bin/DBusDaemon.java index c5e9891..460f031 100644 --- a/org/freedesktop/dbus/bin/DBusDaemon.java +++ b/org/freedesktop/dbus/bin/DBusDaemon.java @@ -819,7 +819,7 @@ public class DBusDaemon extends Thread // accept new connections while (d._run) { UnixSocket s = uss.accept(); - if ((new Transport.SASL()).auth(Transport.SASL.MODE_SERVER, Transport.SASL.AUTH_EXTERNAL, address.getParameter("guid"), s.getOutputStream(), s.getInputStream())) { + if ((new Transport.SASL()).auth(Transport.SASL.MODE_SERVER, Transport.SASL.AUTH_EXTERNAL, address.getParameter("guid"), s.getOutputStream(), s.getInputStream(), s)) { // s.setBlocking(false); d.addSock(s); } else @@ -839,7 +839,7 @@ public class DBusDaemon extends Thread // accept new connections while (d._run) { Socket s = ss.accept(); - if ((new Transport.SASL()).auth(Transport.SASL.MODE_SERVER, Transport.SASL.AUTH_EXTERNAL, address.getParameter("guid"), s.getOutputStream(), s.getInputStream())) { + if ((new Transport.SASL()).auth(Transport.SASL.MODE_SERVER, Transport.SASL.AUTH_EXTERNAL, address.getParameter("guid"), s.getOutputStream(), s.getInputStream(), null)) { d.addSock(s); } else s.close(); diff --git a/org/freedesktop/dbus/test/test.java b/org/freedesktop/dbus/test/test.java index 43240d8..64a062f 100644 --- a/org/freedesktop/dbus/test/test.java +++ b/org/freedesktop/dbus/test/test.java @@ -95,7 +95,7 @@ class testclass implements TestRemoteInterface, TestRemoteInterface2, TestSignal { System.out.println("Sleeping."); try { - Thread.sleep(5000); + Thread.sleep(1000); } catch (InterruptedException Ie) {} System.out.println("Done sleeping."); } |