mirror of https://github.com/oxen-io/oxen-mq.git
allow an IPC socket to set which group it is owned by using SOCKET_GID similar to how STARTUP_UMASK is done.
This commit is contained in:
parent
9467c4682c
commit
0c9eeeea43
|
@ -266,6 +266,10 @@ public:
|
||||||
*/
|
*/
|
||||||
int STARTUP_UMASK = -1;
|
int STARTUP_UMASK = -1;
|
||||||
|
|
||||||
|
/** The gid that owns any sockets when constructed (same as umask)
|
||||||
|
*/
|
||||||
|
int SOCKET_GID = -1;
|
||||||
|
|
||||||
/// A special TaggedThreadID value that always refers to the proxy thread; the main use of this is
|
/// A special TaggedThreadID value that always refers to the proxy thread; the main use of this is
|
||||||
/// to direct very simple batch completion jobs to be executed directly in the proxy thread.
|
/// to direct very simple batch completion jobs to be executed directly in the proxy thread.
|
||||||
inline static constexpr TaggedThreadID run_in_proxy{-1};
|
inline static constexpr TaggedThreadID run_in_proxy{-1};
|
||||||
|
|
|
@ -12,6 +12,8 @@ extern "C" {
|
||||||
#ifndef _WIN32
|
#ifndef _WIN32
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <unistd.h>
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -384,6 +386,18 @@ void LokiMQ::proxy_loop() {
|
||||||
#ifndef _WIN32
|
#ifndef _WIN32
|
||||||
if (saved_umask != -1)
|
if (saved_umask != -1)
|
||||||
umask(saved_umask);
|
umask(saved_umask);
|
||||||
|
|
||||||
|
// set socket gid if it is provided
|
||||||
|
if (SOCKET_GID != -1) {
|
||||||
|
for(size_t i = 0; i < bind.size(); i++) {
|
||||||
|
const address addr(bind[i].first);
|
||||||
|
if(addr.ipc()) {
|
||||||
|
if(chown(addr.socket.c_str(), -1, SOCKET_GID) == -1) {
|
||||||
|
throw std::runtime_error("cannot set group on " + addr.socket + ": " + strerror(errno));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
pollitems_stale = true;
|
pollitems_stale = true;
|
||||||
|
|
Loading…
Reference in New Issue