/* Creates a the parent directory of the specified path securely */ int pa_make_secure_parent_dir(const char *fn, mode_t m, uid_t uid, gid_t gid) { int ret = -1; char *dir; if (!(dir = pa_parent_dir(fn))) goto finish; if (pa_make_secure_dir(dir, m, uid, gid) < 0) goto finish; ret = 0; finish: pa_xfree(dir); return ret; }
void pa__done(pa_module*m) { struct userdata *u; pa_assert(m); if (!(u = m->userdata)) return; #if defined(USE_PROTOCOL_SIMPLE) if (u->simple_protocol) { pa_simple_protocol_disconnect(u->simple_protocol, u->module); pa_simple_protocol_unref(u->simple_protocol); } if (u->simple_options) pa_simple_options_unref(u->simple_options); #elif defined(USE_PROTOCOL_CLI) if (u->cli_protocol) { pa_cli_protocol_disconnect(u->cli_protocol, u->module); pa_cli_protocol_unref(u->cli_protocol); } #elif defined(USE_PROTOCOL_HTTP) if (u->http_protocol) { char t[256]; #if defined(USE_TCP_SOCKETS) if (u->socket_server_ipv4) if (pa_socket_server_get_address(u->socket_server_ipv4, t, sizeof(t))) pa_http_protocol_remove_server_string(u->http_protocol, t); #ifdef HAVE_IPV6 if (u->socket_server_ipv6) if (pa_socket_server_get_address(u->socket_server_ipv6, t, sizeof(t))) pa_http_protocol_remove_server_string(u->http_protocol, t); #endif /* HAVE_IPV6 */ #else /* USE_TCP_SOCKETS */ if (u->socket_server_unix) if (pa_socket_server_get_address(u->socket_server_unix, t, sizeof(t))) pa_http_protocol_remove_server_string(u->http_protocol, t); #endif /* USE_PROTOCOL_HTTP */ pa_http_protocol_disconnect(u->http_protocol, u->module); pa_http_protocol_unref(u->http_protocol); } #elif defined(USE_PROTOCOL_NATIVE) if (u->native_protocol) { char t[256]; # if defined(USE_TCP_SOCKETS) if (u->socket_server_ipv4) if (pa_socket_server_get_address(u->socket_server_ipv4, t, sizeof(t))) pa_native_protocol_remove_server_string(u->native_protocol, t); # ifdef HAVE_IPV6 if (u->socket_server_ipv6) if (pa_socket_server_get_address(u->socket_server_ipv6, t, sizeof(t))) pa_native_protocol_remove_server_string(u->native_protocol, t); # endif # else if (u->socket_server_unix) if (pa_socket_server_get_address(u->socket_server_unix, t, sizeof(t))) pa_native_protocol_remove_server_string(u->native_protocol, t); # endif pa_native_protocol_disconnect(u->native_protocol, u->module); pa_native_protocol_unref(u->native_protocol); } if (u->native_options) pa_native_options_unref(u->native_options); #else if (u->esound_protocol) { pa_esound_protocol_disconnect(u->esound_protocol, u->module); pa_esound_protocol_unref(u->esound_protocol); } if (u->esound_options) pa_esound_options_unref(u->esound_options); #endif #if defined(USE_TCP_SOCKETS) if (u->socket_server_ipv4) pa_socket_server_unref(u->socket_server_ipv4); # ifdef HAVE_IPV6 if (u->socket_server_ipv6) pa_socket_server_unref(u->socket_server_ipv6); # endif #else if (u->socket_server_unix) pa_socket_server_unref(u->socket_server_unix); # if defined(USE_PROTOCOL_ESOUND) && !defined(USE_PER_USER_ESOUND_SOCKET) if (u->socket_path) { char *p = pa_parent_dir(u->socket_path); rmdir(p); pa_xfree(p); } # endif pa_xfree(u->socket_path); #endif pa_xfree(u); }