From 4197cfdbd36d9f7f213df11b6fee795f22c867fd Mon Sep 17 00:00:00 2001 From: Pavlin Radoslavov Date: Fri, 19 Jun 2015 19:21:47 -0700 Subject: [PATCH] Fix the file permissions of /data/misc/bluedroid/bt_config.conf Fix the file access permissions and group ownership of "/data/misc/bluedroid/bt_config.conf" so the file can be reused when switching users on the device. For that purpose, we need to do the following: 1. Set the set-group-ID (bit 02000) flag for directory "/data/misc/bluedroid" so the files created in that directory will have group-id of "net_bt_stack" . 2. Change the file's permissions of file "/data/misc/bluedroid/bt_config.conf" to Read/Write by User and Group. Bug: 21493919 Change-Id: I48b73711789734b5221231729f8cd9ff9bb94be7 --- osi/src/config.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/osi/src/config.c b/osi/src/config.c index a98faa2e8..11a5baf72 100644 --- a/osi/src/config.c +++ b/osi/src/config.c @@ -24,6 +24,7 @@ #include #include #include +#include #include "osi/include/allocator.h" #include "osi/include/config.h" @@ -282,6 +283,12 @@ bool config_save(const config_t *config, const char *filename) { fflush(fp); fclose(fp); + // Change the file's permissions to Read/Write by User and Group + if (chmod(temp_filename, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP) == -1) { + LOG_ERROR("%s unable to change file permissions '%s': %s", __func__, filename, strerror(errno)); + goto error; + } + if (rename(temp_filename, filename) == -1) { LOG_ERROR("%s unable to commit file '%s': %s", __func__, filename, strerror(errno)); goto error; -- 2.11.0