aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Livingston <john.livingston@twosixlabs.com>2017-11-16 14:15:57 -0500
committerJohn Livingston <john.livingston@twosixlabs.com>2017-11-16 14:15:57 -0500
commit4ae91a4fff432922b514b31b7064c0ae73605a2d (patch)
tree2780b920eef29092ab3d15086ff7345f98b48c5b
parent2d7472393e1adcb5b842597dd0478e06eeeb1742 (diff)
macaddrsetup: Create bluetooth file with 640 perms
The bluetooth service runs as bluetooth:bluetooth but the files created by macaddrsetup are 600 system:system by default, so the bluetooth MAC can't be read from /data/misc/bluetooth/bluetooth_bdaddr. This changes the file's permissions to 640; a corresponding rc file change will put the file in the bluetooth group.
-rw-r--r--macaddrsetup.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/macaddrsetup.c b/macaddrsetup.c
index 03703a5..7070af2 100644
--- a/macaddrsetup.c
+++ b/macaddrsetup.c
@@ -6,6 +6,7 @@
#include <string.h>
#include <unistd.h>
#include <sys/stat.h>
+#include <sys/types.h>
#include <cutils/properties.h>
#include <private/android_filesystem_config.h>
@@ -23,6 +24,7 @@ int main(int argc, char **argv)
uint32_t size;
char buf[6];
FILE *fpb, *fpw = NULL;
+ mode_t orig_mask;
int ret, err, bt_addr, wl_addr;
void *ta_handle = NULL;
int (*ta_open)(uint8_t p, uint8_t m, uint8_t c) = NULL;
@@ -54,7 +56,10 @@ int main(int argc, char **argv)
sleep(5);
}
+ // This file needs to be readable by the bluetooth group
+ orig_mask = umask(S_IWGRP | S_IROTH | S_IWOTH);
fpb = fopen(BT_MAC_FILE, "w");
+ umask(orig_mask);
if (!fpb) {
SLOGE("failed to open %s for writing\n", BT_MAC_FILE);
ta_close();