diff options
author | Matthew Xie <mattx@google.com> | 2012-10-04 15:09:15 -0700 |
---|---|---|
committer | Matthew Xie <mattx@google.com> | 2012-10-04 18:30:51 -0700 |
commit | 7057609dc1f29198b1272b9f0e3fca851573bd4e (patch) | |
tree | 2b4f3f2a752bc54450709b44fc9a3b3699079726 | |
parent | 81211b37366a69a284e05e74f160a0bef1265c47 (diff) | |
download | external_bluetooth_bluedroid-7057609dc1f29198b1272b9f0e3fca851573bd4e.zip external_bluetooth_bluedroid-7057609dc1f29198b1272b9f0e3fca851573bd4e.tar.gz external_bluetooth_bluedroid-7057609dc1f29198b1272b9f0e3fca851573bd4e.tar.bz2 |
Change the file gid to net_bt_stack
So the config file can be shared by Bluetooth apk of multi-users
bug 6925422
Change-Id: Id97061454325ef898eb9413756408cf9d95bca62
-rw-r--r-- | btif/src/btif_config.c | 86 |
1 files changed, 7 insertions, 79 deletions
diff --git a/btif/src/btif_config.c b/btif/src/btif_config.c index 7e486b4..00e40bd 100644 --- a/btif/src/btif_config.c +++ b/btif/src/btif_config.c @@ -39,7 +39,7 @@ #include <sys/stat.h> #include <sys/mman.h> #include <stdlib.h> - +#include <private/android_filesystem_config.h> #define LOG_TAG "btif_config.c" @@ -125,7 +125,9 @@ int btif_config_init() if(!initialized) { initialized = 1; - create_dir(CFG_PATH); + struct stat st; + if(stat(CFG_PATH, &st) != 0) + error("%s does not exist, need provision", CFG_PATH); btsock_thread_init(); init_slot_lock(&slot_lock); lock_slot(&slot_lock); @@ -585,6 +587,8 @@ static int save_cfg() if(btif_config_save_file(file_name_new)) { cached_change = 0; + chown(file_name_new, -1, AID_NET_BT_STACK); + chmod(file_name_new, 0660); rename(file_name, file_name_old); rename(file_name_new, file_name); ret = TRUE; @@ -593,6 +597,7 @@ static int save_cfg() debug("out"); return ret; } + static int load_bluez_cfg() { char adapter_path[256]; @@ -635,83 +640,6 @@ static void cfg_cmd_callback(int cmd_fd, int type, int size, uint32_t user_id) break; } } -#define DIR_MODE 0740 -#define FILE_MODE 0644 -static int mk_dir(const char *path) -{ - struct stat st; - - if (stat(path, &st) == 0) - { - if (!S_ISDIR(st.st_mode)) - { - /* path is not a directory */ - error("directory path %s is not a directory (%s)", path, strerror(errno)); - return -1; - } - - /* already exist */ - return 0; - } - - /* no existing dir path, try creating it */ - if (mkdir(path, DIR_MODE) != 0) - { - error("failed to create dir [%s] (%s)", path, strerror(errno)); - return -1; - } - return 0; -} -static int create_dir(const char *path) -{ - int status = 0; - char tmpbuf[128]; - char *p_copy; - char *p; - - //debug("path: %s", path); - - - /* assumes absolute paths */ - if (strncmp(path, "./", 2) == 0) - { - error("%s not an absolute path", path); - return -1; - } - - /* try creating dir directly */ - if (mk_dir(path) == 0) - return 0; - - /* directory does not exit, create it */ - - /* first make sure we won't overflow the path buffer */ - if ((strlen(path)+1) > sizeof(tmpbuf)) - return -1; - - /* setup scratch buffer, make sure path is ended with / */ - sprintf(tmpbuf, "%s/", path); - - p_copy = tmpbuf; - - p = strchr(p_copy+1, '/'); /* skip root */ - - while ((status == 0) && p) - { - /* - * temporarily null terminate to allow creating - * directories up to this point - */ - *p= '\0'; - status = mk_dir(p_copy); - *p= '/'; - - /* find next */ - p = strchr(++p, '/'); - } - - return status; -} #ifdef UNIT_TEST static void cfg_test_load() { |