aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIngo Bauersachs <ingo@jitsi.org>2017-01-14 17:12:15 +0100
committerIngo Bauersachs <ingo@jitsi.org>2017-01-14 17:12:15 +0100
commitc7bdaa5539e796e6507b08ff0f87e5c955fb451f (patch)
treef31308379b983d7308679dd40199f9e0438e0e5a
parent4ad81d511ab6f77883e40dbbd7515a08950a9b29 (diff)
downloadjitsi-c7bdaa5539e796e6507b08ff0f87e5c955fb451f.zip
jitsi-c7bdaa5539e796e6507b08ff0f87e5c955fb451f.tar.gz
jitsi-c7bdaa5539e796e6507b08ff0f87e5c955fb451f.tar.bz2
Use Java 7 instead of JNA to update home dir permissions
-rw-r--r--src/net/java/sip/communicator/impl/configuration/ConfigurationActivator.java46
1 files changed, 21 insertions, 25 deletions
diff --git a/src/net/java/sip/communicator/impl/configuration/ConfigurationActivator.java b/src/net/java/sip/communicator/impl/configuration/ConfigurationActivator.java
index a019c13..a77b2f5 100644
--- a/src/net/java/sip/communicator/impl/configuration/ConfigurationActivator.java
+++ b/src/net/java/sip/communicator/impl/configuration/ConfigurationActivator.java
@@ -28,6 +28,9 @@ import org.jitsi.util.*;
import org.osgi.framework.*;
import java.io.*;
+import java.nio.file.*;
+import java.nio.file.attribute.*;
+import java.util.*;
/**
*
@@ -138,17 +141,30 @@ public class ConfigurationActivator
// let's check config file and config folder
File homeFolder
= new File(cs.getScHomeDirLocation(), cs.getScHomeDirName());
- CLibrary libc = (CLibrary) Native.loadLibrary("c", CLibrary.class);
-
- libc.chmod(homeFolder.getAbsolutePath(), 0700);
+ Set<PosixFilePermission> perms =
+ new HashSet<PosixFilePermission>()
+ {{
+ add(PosixFilePermission.OWNER_READ);
+ add(PosixFilePermission.OWNER_WRITE);
+ add(PosixFilePermission.OWNER_EXECUTE);
+ }};
+ Files.setPosixFilePermissions(
+ Paths.get(homeFolder.getAbsolutePath()), perms);
String fileName = cs.getConfigurationFilename();
-
if(fileName != null)
{
File cf = new File(homeFolder, fileName);
if(cf.exists())
- libc.chmod(cf.getAbsolutePath(), 0600);
+ {
+ perms = new HashSet<PosixFilePermission>()
+ {{
+ add(PosixFilePermission.OWNER_READ);
+ add(PosixFilePermission.OWNER_WRITE);
+ }};
+ Files.setPosixFilePermissions(
+ Paths.get(cf.getAbsolutePath()), perms);
+ }
}
}
catch(Throwable t)
@@ -163,24 +179,4 @@ public class ConfigurationActivator
throw (ThreadDeath) t;
}
}
-
- /**
- * The JNA interface to the <tt>c</tt> library and the <tt>chmod</tt>
- * function we use to fix permissions of user files and folders.
- */
- public interface CLibrary
- extends Library
- {
- /**
- * Changes file permissions.
- *
- * @param path the path to the file or folder the permissions of which
- * are to be changed.
- * @param mode the mode operand
- * @return <tt>0</tt> upon successful completion; otherwise,
- * <tt>-1</tt>. If <tt>-1</tt> is returned, no change to the file mode
- * occurs.
- */
- public int chmod(String path, int mode);
- }
}