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.
#include <errno.h>
#include <string.h>
#include <sys/inotify.h>
+#include <sys/stat.h>
#include <glib.h>
#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;
{
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;