From cadc337a743e2330877ad55c8cbc4a26d418ca0b Mon Sep 17 00:00:00 2001 From: Marcel Holtmann Date: Sat, 22 Dec 2012 09:14:31 -0800 Subject: [PATCH] core: Store information only accessible for the owner --- src/adapter.c | 22 +++++++++++----------- src/attrib-server.c | 3 +-- src/device.c | 13 +++++-------- src/mgmt.c | 4 ++-- 4 files changed, 19 insertions(+), 23 deletions(-) diff --git a/src/adapter.c b/src/adapter.c index ad977a306..cc8de480c 100644 --- a/src/adapter.c +++ b/src/adapter.c @@ -220,7 +220,7 @@ static void store_adapter_info(struct btd_adapter *adapter) snprintf(filename, PATH_MAX, STORAGEDIR "/%s/settings", address); filename[PATH_MAX] = '\0'; - create_file(filename, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); + create_file(filename, S_IRUSR | S_IWUSR); str = g_key_file_to_data(key_file, &length, NULL); g_file_set_contents(filename, str, length, NULL); @@ -242,7 +242,7 @@ void adapter_store_cached_name(const bdaddr_t *local, const bdaddr_t *peer, ba2str(peer, d_addr); snprintf(filename, PATH_MAX, STORAGEDIR "/%s/cache/%s", s_addr, d_addr); filename[PATH_MAX] = '\0'; - create_file(filename, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); + create_file(filename, S_IRUSR | S_IWUSR); key_file = g_key_file_new(); g_key_file_load_from_file(key_file, filename, 0, NULL); @@ -1963,7 +1963,7 @@ static void convert_entry(char *key, char *value, void *user_data) data = g_key_file_to_data(key_file, &length, NULL); if (length > 0) { - create_file(filename, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); + create_file(filename, S_IRUSR | S_IWUSR); g_file_set_contents(filename, data, length, NULL); } @@ -2069,7 +2069,7 @@ static void store_sdp_record(char *local, char *peer, int handle, char *value) data = g_key_file_to_data(key_file, &length, NULL); if (length > 0) { - create_file(filename, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); + create_file(filename, S_IRUSR | S_IWUSR); g_file_set_contents(filename, data, length, NULL); } @@ -2144,7 +2144,7 @@ static void convert_sdp_entry(char *key, char *value, void *user_data) data = g_key_file_to_data(key_file, &length, NULL); if (length > 0) { - create_file(filename, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); + create_file(filename, S_IRUSR | S_IWUSR); g_file_set_contents(filename, data, length, NULL); } @@ -2211,7 +2211,7 @@ static void convert_primaries_entry(char *key, char *value, void *user_data) if (length == 0) goto end; - create_file(filename, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); + create_file(filename, S_IRUSR | S_IWUSR); g_file_set_contents(filename, data, length, NULL); if (device_type < 0) @@ -2229,7 +2229,7 @@ static void convert_primaries_entry(char *key, char *value, void *user_data) data = g_key_file_to_data(key_file, &length, NULL); if (length > 0) { - create_file(filename, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); + create_file(filename, S_IRUSR | S_IWUSR); g_file_set_contents(filename, data, length, NULL); } @@ -2281,7 +2281,7 @@ static void convert_ccc_entry(char *key, char *value, void *user_data) data = g_key_file_to_data(key_file, &length, NULL); if (length > 0) { - create_file(filename, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); + create_file(filename, S_IRUSR | S_IWUSR); g_file_set_contents(filename, data, length, NULL); } @@ -2331,7 +2331,7 @@ static void convert_gatt_entry(char *key, char *value, void *user_data) data = g_key_file_to_data(key_file, &length, NULL); if (length > 0) { - create_file(filename, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); + create_file(filename, S_IRUSR | S_IWUSR); g_file_set_contents(filename, data, length, NULL); } @@ -2379,7 +2379,7 @@ static void convert_proximity_entry(char *key, char *value, void *user_data) data = g_key_file_to_data(key_file, &length, NULL); if (length > 0) { - create_file(filename, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); + create_file(filename, S_IRUSR | S_IWUSR); g_file_set_contents(filename, data, length, NULL); } @@ -2549,7 +2549,7 @@ static void convert_config(struct btd_adapter *adapter, const char *filename, mode == MODE_DISCOVERABLE); } - create_file(filename, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); + create_file(filename, S_IRUSR | S_IWUSR); data = g_key_file_to_data(key_file, &length, NULL); g_file_set_contents(filename, data, length, NULL); diff --git a/src/attrib-server.c b/src/attrib-server.c index e3715e81f..b847e83cb 100644 --- a/src/attrib-server.c +++ b/src/attrib-server.c @@ -909,8 +909,7 @@ static uint16_t write_value(struct gatt_channel *channel, uint16_t handle, data = g_key_file_to_data(key_file, &length, NULL); if (length > 0) { - create_file(filename, - S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); + create_file(filename, S_IRUSR | S_IWUSR); g_file_set_contents(filename, data, length, NULL); } diff --git a/src/device.c b/src/device.c index 17c6cf7fc..7aa752c94 100644 --- a/src/device.c +++ b/src/device.c @@ -310,7 +310,7 @@ static gboolean store_device_info_cb(gpointer user_data) g_key_file_remove_group(key_file, "DeviceID", NULL); } - create_file(filename, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); + create_file(filename, S_IRUSR | S_IWUSR); str = g_key_file_to_data(key_file, &length, NULL); g_file_set_contents(filename, str, length, NULL); @@ -2234,8 +2234,7 @@ static void device_remove_stored(struct btd_device *device) data = g_key_file_to_data(key_file, &length, NULL); if (length > 0) { - create_file(filename, S_IRUSR | S_IWUSR | - S_IRGRP | S_IROTH); + create_file(filename, S_IRUSR | S_IWUSR); g_file_set_contents(filename, data, length, NULL); } @@ -2695,8 +2694,7 @@ static void update_bredr_services(struct browse_req *req, sdp_list_t *recs) if (sdp_key_file) { data = g_key_file_to_data(sdp_key_file, &length, NULL); if (length > 0) { - create_file(sdp_file, S_IRUSR | S_IWUSR | - S_IRGRP | S_IROTH); + create_file(sdp_file, S_IRUSR | S_IWUSR); g_file_set_contents(sdp_file, data, length, NULL); } @@ -2707,8 +2705,7 @@ static void update_bredr_services(struct browse_req *req, sdp_list_t *recs) if (att_key_file) { data = g_key_file_to_data(att_key_file, &length, NULL); if (length > 0) { - create_file(att_file, S_IRUSR | S_IWUSR | - S_IRGRP | S_IROTH); + create_file(att_file, S_IRUSR | S_IWUSR); g_file_set_contents(att_file, data, length, NULL); } @@ -2966,7 +2963,7 @@ static void store_services(struct btd_device *device) data = g_key_file_to_data(key_file, &length, NULL); if (length > 0) { - create_file(filename, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); + create_file(filename, S_IRUSR | S_IWUSR); g_file_set_contents(filename, data, length, NULL); } diff --git a/src/mgmt.c b/src/mgmt.c index 03ec04984..52441e8be 100644 --- a/src/mgmt.c +++ b/src/mgmt.c @@ -443,7 +443,7 @@ static void store_link_key(struct btd_adapter *adapter, g_key_file_set_integer(key_file, "LinkKey", "Type", type); g_key_file_set_integer(key_file, "LinkKey", "PINLength", pin_length); - create_file(filename, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); + create_file(filename, S_IRUSR | S_IWUSR); str = g_key_file_to_data(key_file, &length, NULL); g_file_set_contents(filename, str, length, NULL); @@ -1989,7 +1989,7 @@ static void store_longtermkey(bdaddr_t *local, bdaddr_t *peer, g_key_file_set_string(key_file, "LongTermKey", "Rand", rand_str); - create_file(filename, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); + create_file(filename, S_IRUSR | S_IWUSR); str = g_key_file_to_data(key_file, &length, NULL); g_file_set_contents(filename, str, length, NULL); -- 2.47.3