From a1336a435a03d23a2ee746febc6cdb4cf895c1cb Mon Sep 17 00:00:00 2001
From: pierre-luc <pierre-luc@aqra.ca>
Date: Fri, 10 Jul 2009 14:03:48 -0400
Subject: [PATCH] [#1792] Creates .sflphone directory with permission 600.
 Also, "chmod 600" after every file saving. Last modification might be too
 much and could be removed later.

---
 sflphone-common/src/config/config.cpp | 17 +++++++++++++---
 sflphone-common/src/config/config.h   |  2 +-
 sflphone-common/src/managerimpl.cpp   | 28 ++-------------------------
 3 files changed, 17 insertions(+), 30 deletions(-)

diff --git a/sflphone-common/src/config/config.cpp b/sflphone-common/src/config/config.cpp
index 9c6bb914ba..4f8c02c8de 100644
--- a/sflphone-common/src/config/config.cpp
+++ b/sflphone-common/src/config/config.cpp
@@ -22,6 +22,9 @@
 #include "../global.h"
 #include <fstream>
 #include <cstdlib>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <errno.h>
 
 namespace Conf
 {
@@ -255,7 +258,11 @@ ConfigTree::saveConfigTree (const std::string& fileName)
     }
 
     file.close();
-
+    
+    if(chmod(fileName.c_str(), S_IRUSR | S_IWUSR)) {
+        _debug("Failed to set permission on configuration file because: %s\n",strerror(errno));
+    }
+    
     return true;
 }
 
@@ -267,7 +274,7 @@ int
 ConfigTree::populateFromFile (const std::string& fileName)
 {
     bool out = false;
-
+    
     if (fileName.empty()) {
         return 0;
     }
@@ -332,7 +339,11 @@ ConfigTree::populateFromFile (const std::string& fileName)
     }
 
     file.close();
-
+    
+    if(chmod(fileName.c_str(), S_IRUSR | S_IWUSR)) {
+        _debug("Failed to set permission on configuration file because: %s\n",strerror(errno));
+    }
+    
     return 1;
 }
 
diff --git a/sflphone-common/src/config/config.h b/sflphone-common/src/config/config.h
index 0872889486..0fa75a24ac 100644
--- a/sflphone-common/src/config/config.h
+++ b/sflphone-common/src/config/config.h
@@ -155,7 +155,7 @@ class ConfigTree
          * List of sections. Each sections has an ItemList as child
          */
         SectionMap _sections;
-
+        
         friend class ConfigTreeIterator;
 
     public:
diff --git a/sflphone-common/src/managerimpl.cpp b/sflphone-common/src/managerimpl.cpp
index 7a49b2c04a..345fb7df66 100644
--- a/sflphone-common/src/managerimpl.cpp
+++ b/sflphone-common/src/managerimpl.cpp
@@ -1293,7 +1293,7 @@ ManagerImpl::createSettingsPath (void)
 {
     _path = std::string (HOMEDIR) + DIR_SEPARATOR_STR + "." + PROGDIR;
 
-    if (mkdir (_path.data(), 0755) != 0) {
+    if (mkdir (_path.data(), 0600) != 0) {
         // If directory	creation failed
         if (errno != EEXIST) {
             _debug ("Cannot create directory: %s\n", strerror (errno));
@@ -1952,31 +1952,7 @@ void ManagerImpl::setAudioManager (const int32_t& api)
 
     switchAudioManager();
     return;
-
-    /*
-        int manager;
-
-        _debug(" ManagerImpl::setAudioManager :: %i \n",api);
-
-        manager = api;
-        if( manager == PULSEAUDIO )
-        {
-            if(app_is_running("pulseaudio") != 0)
-            {
-                // The pulseaudio daemon is not running
-                manager = ALSA;
-                notifyErrClient(PULSEAUDIO_NOT_RUNNING);
-            }
-        }
-
-        if(manager == api)
-        {
-            // it means that we can change the audio manager
-            setConfig( PREFERENCES , CONFIG_AUDIO , api) ;
-            switchAudioManager();
-        }
-    */
-
+    
 }
 
 int32_t
-- 
GitLab