summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authorDaniel Wagner <daniel.wagner@bmw-carit.de>2012-12-06 08:37:11 +0100
committerPatrik Flykt <patrik.flykt@linux.intel.com>2012-12-10 13:01:05 +0200
commit93bce67bb7abbad07161280e1491cb5faaabf602 (patch)
tree378ef9e8c930725dd9e98ef30cf4deb394471d5f /plugins
parent7fbdf15b2545bd9e9d1cb0376544e4f4095d2bd2 (diff)
downloadconnman-93bce67bb7abbad07161280e1491cb5faaabf602.tar.gz
connman-93bce67bb7abbad07161280e1491cb5faaabf602.tar.bz2
connman-93bce67bb7abbad07161280e1491cb5faaabf602.zip
session_policy_local: Create policy directory if necessary
Create the policy directory as first thing. If we don't do this adding a watch on the non existing directory will fail and the whole plugin is not loaded. We need to figure out later how permissive the MODE of the directory should be. Currently, we play safe and have it tied down.
Diffstat (limited to 'plugins')
-rw-r--r--plugins/session_policy_local.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/plugins/session_policy_local.c b/plugins/session_policy_local.c
index 7fa3166a..11b16652 100644
--- a/plugins/session_policy_local.c
+++ b/plugins/session_policy_local.c
@@ -26,6 +26,7 @@
#include <errno.h>
#include <string.h>
#include <sys/inotify.h>
+#include <sys/stat.h>
#include <glib.h>
@@ -40,6 +41,9 @@
#define POLICYDIR STORAGEDIR "/session_policy_local"
+#define MODE (S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | \
+ S_IXGRP | S_IROTH | S_IXOTH)
+
static DBusConnection *connection;
static GHashTable *policy_hash;
@@ -464,6 +468,14 @@ static int session_policy_local_init(void)
{
int err;
+ /* If the dir doesn't exist, create it */
+ if (g_file_test(POLICYDIR, G_FILE_TEST_IS_DIR) == FALSE) {
+ if (mkdir(POLICYDIR, MODE) < 0) {
+ if (errno != EEXIST)
+ return -errno;
+ }
+ }
+
connection = connman_dbus_get_connection();
if (connection == NULL)
return -EIO;