Skip to contentSkip to conversation

obex: Use XDG_RUNTIME_DIR as a default root

PATCH In review Bastien Nocera 2 participants 5 messages Nov 9, 2013 – Nov 11, 2013 Bluetooth drivers

lore
Share & tools
lore
#0 lore raw

PATCH 3/3 obex: Use XDG_RUNTIME_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.

---
 obexd/src/main.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
obexd/src/main.c +1 -3
index 61a06b2..15777f5 100644
@@ -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;
@@ -286,7 +284,7 @@ int main(int argc, char *argv[])
 	}
 
 	if (option_root == NULL)
-		option_root = g_strdup(DEFAULT_ROOT_PATH);
+		option_root = g_build_filename (g_get_user_runtime_dir (), "obexd", NULL);
 
 	if (option_root[0] != '/') {
 		char *old_root = option_root, *home = getenv("HOME");
Signature · 1 line
1.8.4.2
#1 lore raw
Quoted 2 lines · Bastien Nocera

It's per-user, so we won't try to overwrite somebody else's files in /tmp when that happens.

There might be another useful directory instead. We could use g_get_user_cache_dir() instead of the run-time dir. This would save cross-partition moves by default, making the move to the Downloads dir atomic (a single rename, which can fail, iterate until we find a "free" filename).

Is that better for you?

Quoted 26 lines
---
 obexd/src/main.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
obexd/src/main.c +1 -3
index 61a06b2..15777f5 100644
@@ -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;
@@ -286,7 +284,7 @@ int main(int argc, char *argv[])
 	}
 
 	if (option_root == NULL)
-		option_root = g_strdup(DEFAULT_ROOT_PATH);
+		option_root = g_build_filename (g_get_user_runtime_dir (), "obexd", NULL);
 
 	if (option_root[0] != '/') {
 		char *old_root = option_root, *home = getenv("HOME");
#2 lore raw

Hi Bastien,

Quoted 11 lines · Bastien Nocera
Quoted 2 lines · Bastien Nocera

It's per-user, so we won't try to overwrite somebody else's files in /tmp when that happens.

There might be another useful directory instead. We could use g_get_user_cache_dir() instead of the run-time dir. This would save cross-partition moves by default, making the move to the Downloads dir atomic (a single rename, which can fail, iterate until we find a "free" filename).

Is that better for you?

Yep, it sounds better. Regarding renaming that is up the agent, if you really want to do that its probably fine but Im still not convinced this is absolutely necessary if obexd is running with the same user as the agent can just create the file while authorizing so you wouldn't need to move after completed, but again this is completely up to the agent to decide where the files should go.

Btw, what about fd passing? In theory we can create a different version of the agent interface to enable passing fd directly, and in fact we were thinking about this already as for some services you wanted them to be dynamic so we were thinking on having this set by the agent when it registers.

Signature · 1 line
Luiz Augusto von Dentz
#3 lore raw
Quoted 13 lines · Luiz Augusto von Dentz

Hi Bastien,

Quoted 10 lines · Bastien Nocera
Quoted 2 lines · Bastien Nocera

It's per-user, so we won't try to overwrite somebody else's files in /tmp when that happens.

There might be another useful directory instead. We could use g_get_user_cache_dir() instead of the run-time dir. This would save cross-partition moves by default, making the move to the Downloads dir atomic (a single rename, which can fail, iterate until we find a "free" filename).

Quoted 8 lines
Quoted 1 line

Is that better for you?

Yep, it sounds better. Regarding renaming that is up the agent, if you really want to do that its probably fine but Im still not convinced this is absolutely necessary if obexd is running with the same user as the agent can just create the file while authorizing so you wouldn't need to move after completed, but again this is completely up to the agent to decide where the files should go.

You seem to think that all the application/services running under one user would have the same rights. That's currently the case, but won't be in the future.

Quoted 5 lines

Btw, what about fd passing? In theory we can create a different version of the agent interface to enable passing fd directly, and in fact we were thinking about this already as for some services you wanted them to be dynamic so we were thinking on having this set by the agent when it registers.

I'm fine with a file descriptor as well, but obex push server is currently broken in GNOME 3.10. I'm happy doing the changes in GNOME 3.12 (due in 6 months).

Can we get the cache dir change in, and make the API change later on?

Cheers

#4 lore raw

Hi Bastien,

Quoted 23 lines · Bastien Nocera
Quoted 13 lines · Luiz Augusto von Dentz

Hi Bastien,

Quoted 10 lines · Bastien Nocera
Quoted 2 lines · Bastien Nocera

It's per-user, so we won't try to overwrite somebody else's files in /tmp when that happens.

There might be another useful directory instead. We could use g_get_user_cache_dir() instead of the run-time dir. This would save cross-partition moves by default, making the move to the Downloads dir atomic (a single rename, which can fail, iterate until we find a "free" filename).

Quoted 8 lines
Quoted 1 line

Is that better for you?

Yep, it sounds better. Regarding renaming that is up the agent, if you really want to do that its probably fine but Im still not convinced this is absolutely necessary if obexd is running with the same user as the agent can just create the file while authorizing so you wouldn't need to move after completed, but again this is completely up to the agent to decide where the files should go.

Quoted 3 lines

You seem to think that all the application/services running under one user would have the same rights. That's currently the case, but won't be in the future.

Interesting that would cause some problems for sure...

Quoted 11 lines
Quoted 5 lines

Btw, what about fd passing? In theory we can create a different version of the agent interface to enable passing fd directly, and in fact we were thinking about this already as for some services you wanted them to be dynamic so we were thinking on having this set by the agent when it registers.

I'm fine with a file descriptor as well, but obex push server is currently broken in GNOME 3.10. I'm happy doing the changes in GNOME 3.12 (due in 6 months).

Can we get the cache dir change in, and make the API change later on?

Yep, lets use the cache dir and then think about the API change.

Signature · 1 line
Luiz Augusto von Dentz