obex: Use user's cache dir as a default root
PATCH 1/1 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.
--- obexd/src/main.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
obexd/src/main.c +4 -4
@@ -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 ;
@@ -285,8 +283,10 @@ 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" );
Signature · 1 line
1.8.4.2
Luiz Augusto von Dentz
maintainerHi Bastien,
Quoted 37 lines · Bastien Nocera
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.
--- obexd/src/main.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)obexd/src/main.c +4
-5@@ -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 ;@@ -285,8 +283,10 @@ 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" ); --
Quoted 1 line
1.8.4.2
Pushed, thanks.
Signature · 1 line
Luiz Augusto von Dentz