localsock: check for file permissions

This commit is contained in:
Matheus
2024-08-25 11:29:55 -03:00
parent 4d3e2b7494
commit 914e075397
3 changed files with 8 additions and 3 deletions
+6 -1
View File
@@ -384,7 +384,7 @@ static int localsock_accept(socket_t *_server, socket_t *_clientconnection, sock
return error;
}
static int localsock_connect(socket_t *socket, sockaddr_t *addr, uintmax_t flags) {
static int localsock_connect(socket_t *socket, sockaddr_t *addr, uintmax_t flags, cred_t *cred) {
localsocket_t *localsocket = (localsocket_t *)socket;
int error;
vnode_t *refnode = NULL;
@@ -416,6 +416,11 @@ static int localsock_connect(socket_t *socket, sockaddr_t *addr, uintmax_t flags
goto leave;
}
// and we have write access
error = VOP_ACCESS(result, V_ACCESS_WRITE, cred);
if (error)
goto leave;
// and if it has a valid binding
binding = result->socketbinding;
if (binding == NULL) {