mirror of https://github.com/oxen-io/oxen-mq.git
allow changing uid as root
This commit is contained in:
parent
0c9eeeea43
commit
0938e1fc53
|
@ -269,6 +269,9 @@ public:
|
|||
/** The gid that owns any sockets when constructed (same as umask)
|
||||
*/
|
||||
int SOCKET_GID = -1;
|
||||
/** The uid that owns any sockets when constructed (same as umask but requires root)
|
||||
*/
|
||||
int SOCKET_UID = -1;
|
||||
|
||||
/// 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.
|
||||
|
|
|
@ -387,12 +387,12 @@ void LokiMQ::proxy_loop() {
|
|||
if (saved_umask != -1)
|
||||
umask(saved_umask);
|
||||
|
||||
// set socket gid if it is provided
|
||||
if (SOCKET_GID != -1) {
|
||||
// set socket gid / uid if it is provided
|
||||
if (SOCKET_GID != -1 or SOCKET_UID != -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) {
|
||||
if(chown(addr.socket.c_str(), SOCKET_UID, SOCKET_GID) == -1) {
|
||||
throw std::runtime_error("cannot set group on " + addr.socket + ": " + strerror(errno));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue