diff options
-rw-r--r-- | lib/installer-exclude/libjitsi.jar | bin | 1424671 -> 1424923 bytes | |||
-rw-r--r-- | src/net/java/sip/communicator/impl/configuration/ConfigurationActivator.java | 72 | ||||
-rw-r--r-- | src/net/java/sip/communicator/impl/configuration/configuration.manifest.mf | 2 |
3 files changed, 74 insertions, 0 deletions
diff --git a/lib/installer-exclude/libjitsi.jar b/lib/installer-exclude/libjitsi.jar Binary files differindex e319b39..b780e09 100644 --- a/lib/installer-exclude/libjitsi.jar +++ b/lib/installer-exclude/libjitsi.jar diff --git a/src/net/java/sip/communicator/impl/configuration/ConfigurationActivator.java b/src/net/java/sip/communicator/impl/configuration/ConfigurationActivator.java index ce4dcb5..17066eb 100644 --- a/src/net/java/sip/communicator/impl/configuration/ConfigurationActivator.java +++ b/src/net/java/sip/communicator/impl/configuration/ConfigurationActivator.java @@ -6,10 +6,14 @@ */ package net.java.sip.communicator.impl.configuration; +import com.sun.jna.*; import org.jitsi.service.configuration.*; import org.jitsi.service.libjitsi.*; +import org.jitsi.util.*; import org.osgi.framework.*; +import java.io.*; + /** * @author Emil Ivov * @author Lyubomir Marinov @@ -18,6 +22,13 @@ public class ConfigurationActivator implements BundleActivator { /** + * The <tt>Logger</tt> used by the <tt>ConfigurationActivator</tt> class + * for logging output. + */ + private static final Logger logger + = Logger.getLogger(ConfigurationActivator.class); + + /** * The <tt>BundleContext</tt> in which the configuration bundle has been * started and has not been stopped yet. */ @@ -44,6 +55,8 @@ public class ConfigurationActivator ConfigurationService.class.getName(), configurationService, null); + + fixPermissions(configurationService); } } @@ -72,4 +85,63 @@ public class ConfigurationActivator { return bundleContext; } + + /** + * Makes home folder and the configuration file readable and writable + * only to the owner. + * @param configurationService the config service instance to check + * for home folder and name. + */ + private static void fixPermissions( + ConfigurationService configurationService) + { + if(!OSUtils.IS_LINUX && !OSUtils.IS_MAC) + return; + + try + { + // let's check config file and config folder + File homeFolder = new File( + configurationService.getScHomeDirLocation(), + configurationService.getScHomeDirName()); + + CLibrary libc = (CLibrary) Native.loadLibrary("c", CLibrary.class); + libc.chmod(homeFolder.getAbsolutePath(), 0700); + + String fileName = configurationService.getConfigurationFilename(); + + if(fileName != null) + { + File cf = new File(homeFolder, fileName); + if(cf.exists()) + { + libc.chmod(cf.getAbsolutePath(), 0600); + } + } + } + catch(Throwable t) + { + logger.error( + "Error creating c lib instance for fixing file permissions", t); + } + } + + /** + * The jna interface to the c library and the chmod we use + * to fix permissions of user files. + */ + public interface CLibrary + extends Library + { + /** + * Changes file permissions. + * @param path the path to file or folder which permissions we will + * change. + * @param mode the mode operand + * @return 0 shall be returned upon successful completion; + * otherwise, -1 shall be returned. If -1 is returned, + * no change to the file mode occurs. + */ + public int chmod(String path, int mode); + } } diff --git a/src/net/java/sip/communicator/impl/configuration/configuration.manifest.mf b/src/net/java/sip/communicator/impl/configuration/configuration.manifest.mf index ceaba14..4edee12 100644 --- a/src/net/java/sip/communicator/impl/configuration/configuration.manifest.mf +++ b/src/net/java/sip/communicator/impl/configuration/configuration.manifest.mf @@ -6,4 +6,6 @@ Bundle-Version: 0.0.1 System-Bundle: yes Import-Package: org.jitsi.service.configuration, org.jitsi.service.libjitsi, + org.jitsi.util, + com.sun.jna, org.osgi.framework |