diff options
author | Bastien Nocera <hadess@hadess.net> | 2013-11-10 15:24:20 +0100 |
---|---|---|
committer | Luiz Augusto von Dentz <luiz.von.dentz@intel.com> | 2013-11-12 10:55:28 +0200 |
commit | 841896ae172c08c1652af88d0994f0349912ed14 (patch) | |
tree | 89985454d6760473e38449b29487cf52fddb44ec /obexd | |
parent | 4d508d346b99f4970576f0e83f79fee72cdb5b2c (diff) |
obex: Use user's cache dir as a default root
It's per-user, so we won't try to overwrite somebody else's
files in /tmp when that happens. It's also (unless we have a
particularly bizarre setup) on the same partition as the destination
folder which means we can atomically move the file to the destination
with a unique filename.
Diffstat (limited to 'obexd')
-rw-r--r-- | obexd/src/main.c | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/obexd/src/main.c b/obexd/src/main.c index 61a06b207..80645f8df 100644 --- a/obexd/src/main.c +++ b/obexd/src/main.c @@ -50,8 +50,6 @@ #include "obexd.h" #include "server.h" -#define DEFAULT_ROOT_PATH "/tmp" - #define DEFAULT_CAP_FILE CONFIGDIR "/capability.xml" static GMainLoop *main_loop = NULL; @@ -167,7 +165,7 @@ static GOptionEntry options[] = { "Specify root folder location. Both absolute " "and relative can be used, but relative paths " "are assumed to be relative to user $HOME " - "folder", "PATH" }, + "folder. Default $XDG_CACHE_HOME", "PATH" }, { "root-setup", 'S', 0, G_OPTION_ARG_STRING, &option_root_setup, "Root folder setup script", "SCRIPT" }, { "symlinks", 'l', 0, G_OPTION_ARG_NONE, &option_symlinks, @@ -285,8 +283,11 @@ int main(int argc, char *argv[]) exit(EXIT_FAILURE); } - if (option_root == NULL) - option_root = g_strdup(DEFAULT_ROOT_PATH); + if (option_root == NULL) { + option_root = g_build_filename(g_get_user_cache_dir(), "obexd", + NULL); + g_mkdir_with_parents(option_root, 0700); + } if (option_root[0] != '/') { char *old_root = option_root, *home = getenv("HOME"); |