Lines Matching refs:server
84 VarlinkServer *server; member
154 VarlinkServer *server; member
376 assert(!v->server); in varlink_destroy()
857 assert(v->server); in varlink_dispatch_method()
867 callback = hashmap_get(v->server->methods, method); in varlink_dispatch_method()
1169 if (!v->server) in varlink_detach_server()
1172 if (v->server->by_uid && in varlink_detach_server()
1177 c = PTR_TO_UINT(hashmap_get(v->server->by_uid, UID_TO_PTR(v->ucred.uid))); in varlink_detach_server()
1181 (void) hashmap_remove(v->server->by_uid, UID_TO_PTR(v->ucred.uid)); in varlink_detach_server()
1183 … (void) hashmap_replace(v->server->by_uid, UID_TO_PTR(v->ucred.uid), UINT_TO_PTR(c - 1)); in varlink_detach_server()
1186 assert(v->server->n_connections > 0); in varlink_detach_server()
1187 v->server->n_connections--; in varlink_detach_server()
1193 saved_server = TAKE_PTR(v->server); in varlink_detach_server()
1846 return v->server; in varlink_get_server()
2059 static int validate_connection(VarlinkServer *server, const struct ucred *ucred) { in validate_connection() argument
2062 assert(server); in validate_connection()
2065 if (FLAGS_SET(server->flags, VARLINK_SERVER_ROOT_ONLY)) in validate_connection()
2068 if (FLAGS_SET(server->flags, VARLINK_SERVER_MYSELF_ONLY)) in validate_connection()
2073 varlink_server_log(server, "Unprivileged client attempted connection, refusing."); in validate_connection()
2077 if (server->n_connections >= server->connections_max) { in validate_connection()
2078 … varlink_server_log(server, "Connection limit of %u reached, refusing.", server->connections_max); in validate_connection()
2082 if (FLAGS_SET(server->flags, VARLINK_SERVER_ACCOUNT_UID)) { in validate_connection()
2086 … varlink_server_log(server, "Client with invalid UID attempted connection, refusing."); in validate_connection()
2090 c = PTR_TO_UINT(hashmap_get(server->by_uid, UID_TO_PTR(ucred->uid))); in validate_connection()
2091 if (c >= server->connections_per_uid_max) { in validate_connection()
2092 … varlink_server_log(server, "Per-UID connection limit of %u reached, refusing.", in validate_connection()
2093 server->connections_per_uid_max); in validate_connection()
2101 static int count_connection(VarlinkServer *server, const struct ucred *ucred) { in count_connection() argument
2105 assert(server); in count_connection()
2108 server->n_connections++; in count_connection()
2110 if (FLAGS_SET(server->flags, VARLINK_SERVER_ACCOUNT_UID)) { in count_connection()
2111 r = hashmap_ensure_allocated(&server->by_uid, NULL); in count_connection()
2115 c = PTR_TO_UINT(hashmap_get(server->by_uid, UID_TO_PTR(ucred->uid))); in count_connection()
2117 varlink_server_log(server, "Connections of user " UID_FMT ": %u (of %u max)", in count_connection()
2118 ucred->uid, c, server->connections_per_uid_max); in count_connection()
2120 r = hashmap_replace(server->by_uid, UID_TO_PTR(ucred->uid), UINT_TO_PTR(c + 1)); in count_connection()
2128 int varlink_server_add_connection(VarlinkServer *server, int fd, Varlink **ret) { in varlink_server_add_connection() argument
2134 assert_return(server, -EINVAL); in varlink_server_add_connection()
2137 if ((server->flags & (VARLINK_SERVER_ROOT_ONLY|VARLINK_SERVER_ACCOUNT_UID)) != 0) { in varlink_server_add_connection()
2140 …return varlink_server_log_errno(server, r, "Failed to acquire peer credentials of incoming socket,… in varlink_server_add_connection()
2144 r = validate_connection(server, &ucred); in varlink_server_add_connection()
2154 … return varlink_server_log_errno(server, r, "Failed to allocate connection object: %m"); in varlink_server_add_connection()
2156 r = count_connection(server, &ucred); in varlink_server_add_connection()
2161 if (server->flags & VARLINK_SERVER_INHERIT_USERDATA) in varlink_server_add_connection()
2162 v->userdata = server->userdata; in varlink_server_add_connection()
2170 if (asprintf(&desc, "%s-%i", server->description ?: "varlink", v->fd) >= 0) in varlink_server_add_connection()
2176 v->server = varlink_server_ref(server); in varlink_server_add_connection()
2181 if (server->event) { in varlink_server_add_connection()
2182 r = varlink_attach_event(v, server->event, server->event_priority); in varlink_server_add_connection()
2206 varlink_server_log(ss->server, "New incoming connection."); in connect_callback()
2213 … return varlink_server_log_errno(ss->server, errno, "Failed to accept incoming socket: %m"); in connect_callback()
2216 r = varlink_server_add_connection(ss->server, cfd, &v); in connect_callback()
2222 if (ss->server->connect_callback) { in connect_callback()
2223 r = ss->server->connect_callback(ss->server, v, ss->server->userdata); in connect_callback()
2250 .server = s, in varlink_server_listen_fd()
2329 if (ss->server) in varlink_server_socket_destroy()
2330 LIST_REMOVE(sockets, ss->server->sockets, ss); in varlink_server_socket_destroy()