From a89d15611426fbfa63532b65a53c507994e7b69f Mon Sep 17 00:00:00 2001 From: Bo Date: Sun, 8 Jan 2023 02:08:50 +0000 Subject: [PATCH] use `chmod` before `listen` instead of `fchmod`, related to #136 --- CHANGELOG.md | 3 +++ ext/iodine/fio.c | 5 +++-- lib/iodine/version.rb | 2 +- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f92aa6c..0a9c3fd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,9 @@ Please notice that this change log contains changes for upcoming releases as wel ## Changes: +#### Change log v.0.7.53 (expected: 2023-01-10) + +**Fix**: Fixes Unix socket permission limitations, so unix sockets are not limited to the owner of the process. Credit to Patrik Rak (@raxoft) for opening issue #136. #### Change log v.0.7.52 (2022-12-10) diff --git a/ext/iodine/fio.c b/ext/iodine/fio.c index 74cbe0e..abac437 100644 --- a/ext/iodine/fio.c +++ b/ext/iodine/fio.c @@ -3203,13 +3203,14 @@ static intptr_t fio_unix_socket(const char *address, uint8_t server) { close(fd); return -1; } + /* chmod for foreign connections... if possible */ + if(chmod(addr.sun_path, 0x1FF)) + FIO_LOG_WARNING("chmod failed for %s (%d: %s)", address, errno, strerror(errno)); if (listen(fd, SOMAXCONN) < 0) { // perror("couldn't start listening to unix socket"); close(fd); return -1; } - /* chmod for foreign connections */ - fchmod(fd, 0777); } else { if (connect(fd, (struct sockaddr *)&addr, sizeof(addr)) == -1 && errno != EINPROGRESS) { diff --git a/lib/iodine/version.rb b/lib/iodine/version.rb index f5f21af..2b058bf 100644 --- a/lib/iodine/version.rb +++ b/lib/iodine/version.rb @@ -1,3 +1,3 @@ module Iodine - VERSION = '0.7.52'.freeze + VERSION = '0.7.53'.freeze end