Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

socket_bind creates file in /tmp, but www-data has no permissions to it #28

Closed
fearr1 opened this issue Feb 4, 2021 · 1 comment
Closed

Comments

@fearr1
Copy link

fearr1 commented Feb 4, 2021

Server.php -> openIPCSocket() -> socket_bind -> creates a file in /tmp but www-data has no permissions to use it. This happened when i tried to send IPC data from an action of a website to the WebSocket server. This change did the trick:

FROM
if (socket_bind($this->icpSocket, $ipcSocketPath) === false) {
throw new \RuntimeException('Could not bind to ipc socket.');
}

TO
if (socket_bind($this->icpSocket, $ipcSocketPath) === false) {
throw new \RuntimeException('Could not bind to ipc socket.');
} else {
chown($ipcSocketPath, 'www-data');
}

@nekudo nekudo closed this as completed in 1ca55d1 Feb 7, 2021
@nekudo
Copy link
Collaborator

nekudo commented Feb 7, 2021

I added a fix for this. It is now possible to set user/group and mode for the IPC file:

$server = new \Bloatless\WebSocket\Server('127.0.0.1', 8000, '/tmp/phpwss.sock');
$server->setIPCOwner('foo');
$server->setIPCGroup('www-data');
$server->setIPCMode(0755);

Keep in mind that the user you start the server with needs to be in the desired group for this to work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants