You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mina.apache.org by sp...@apache.org on 2009/12/23 04:39:23 UTC

svn commit: r893393 - /mina/sshd/trunk/sshd-core/src/main/java/org/apache/sshd/agent/AprLibrary.java

Author: spearce
Date: Wed Dec 23 03:39:23 2009
New Revision: 893393

URL: http://svn.apache.org/viewvc?rev=893393&view=rev
Log:
Use tomcat-jni to set permissions on its own socket

MINA SSHD builds against Java 1.5, but setReadable(boolean,boolean)
isn't available until Java 1.6.  Since this code path is only used
when tomcat-jni is loaded and initialized we can use the native
code available within the library to call chmod() on UNIX for us.

This removes our dependency on Java 1.6, putting us back to the
Java 1.5 baseline.

Modified:
    mina/sshd/trunk/sshd-core/src/main/java/org/apache/sshd/agent/AprLibrary.java

Modified: mina/sshd/trunk/sshd-core/src/main/java/org/apache/sshd/agent/AprLibrary.java
URL: http://svn.apache.org/viewvc/mina/sshd/trunk/sshd-core/src/main/java/org/apache/sshd/agent/AprLibrary.java?rev=893393&r1=893392&r2=893393&view=diff
==============================================================================
--- mina/sshd/trunk/sshd-core/src/main/java/org/apache/sshd/agent/AprLibrary.java (original)
+++ mina/sshd/trunk/sshd-core/src/main/java/org/apache/sshd/agent/AprLibrary.java Wed Dec 23 03:39:23 2009
@@ -121,9 +121,9 @@
 
     static void secureLocalSocket(String authSocket, long handle) throws IOException {
         if (OsUtils.isUNIX()) {
-            File file = new File(authSocket);
-            if (!file.setReadable(false, false) || !file.setReadable(true, true)
-                    || !file.setExecutable(false, false) || !file.setExecutable(true, true)) {
+            int perms = org.apache.tomcat.jni.File.APR_FPROT_UREAD
+                      | org.apache.tomcat.jni.File.APR_FPROT_UWRITE;
+            if (org.apache.tomcat.jni.File.permsSet(authSocket, perms) != org.apache.tomcat.jni.Status.APR_SUCCESS) {
                 throw new IOException("Unable to secure local socket");
             }