summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarcel Holtmann <marcel@holtmann.org>2005-04-16 16:02:18 +0000
committerMarcel Holtmann <marcel@holtmann.org>2005-04-16 16:02:18 +0000
commitd5c864c1c4828b8a7fedca819ef6b2cb4f20a24d (patch)
tree3ff481a549faf2a1d64bc71cb1cba13973cc75c5
parentbbf5eef59916cd1230ef71dc7b9be055397b0074 (diff)
Create the linkkey file
-rw-r--r--hcid/storage.c24
1 files changed, 18 insertions, 6 deletions
diff --git a/hcid/storage.c b/hcid/storage.c
index d38e6aef..aeb98480 100644
--- a/hcid/storage.c
+++ b/hcid/storage.c
@@ -146,10 +146,7 @@ static int create_dirs(const char *filename, mode_t mode)
int write_device_name(const bdaddr_t *local, const bdaddr_t *peer, const char *name)
{
struct name_list *temp, *list = NULL;
- mode_t mode = S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH;
- mode_t mask = S_IWGRP | S_IWOTH;
- char filename[PATH_MAX + 1];
- char addr[18], str[249], *buf, *ptr;
+ char filename[PATH_MAX + 1], addr[18], str[249], *buf, *ptr;
bdaddr_t bdaddr;
struct stat st;
int fd, pos, err = 0;
@@ -157,8 +154,8 @@ int write_device_name(const bdaddr_t *local, const bdaddr_t *peer, const char *n
ba2str(local, addr);
snprintf(filename, PATH_MAX, "%s/%s/names", DEVPATH, addr);
- umask(mask);
- create_dirs(filename, mode);
+ umask(S_IWGRP | S_IWOTH);
+ create_dirs(filename, S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH);
fd = open(filename, O_RDWR | O_CREAT, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
if (fd < 0)
@@ -218,6 +215,21 @@ close:
int write_link_key(const bdaddr_t *local, const bdaddr_t *peer, const unsigned char *key, const int type)
{
+ char filename[PATH_MAX + 1], addr[18];
+ int fd;
+
+ ba2str(local, addr);
+ snprintf(filename, PATH_MAX, "%s/%s/linkkeys", DEVPATH, addr);
+
+ umask(S_IWGRP | S_IWOTH);
+ create_dirs(filename, S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH);
+
+ fd = open(filename, O_RDWR | O_CREAT, S_IRUSR | S_IWUSR);
+ if (fd < 0)
+ return -errno;
+
+ close(fd);
+
return 0;
}