Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • andika/pulseaudio
  • huwei-eaco/pulseaudio
  • zero2165/pulseaudio
  • to1ne/pulseaudio
  • paravoid/pulseaudio
  • nazar-pc/pulseaudio
  • chengyi/pulseaudio
  • lordee/pulseaudio
  • flyingOwl/pulseaudio
  • lnicola/pulseaudio
  • tuxist/pulseaudio
  • pseyfert/pulseaudio
  • hstefan/pulseaudio
  • dengbo/pulseaudio
  • zenbooster/pulseaudio
  • jejb/pulseaudio
  • Ganjing0224/pulseaudio
  • jnqnfe/pulseaudio
  • chewi/pulseaudio
  • m.shakthi.prashanth/pulseaudio
  • Redcroft/pulseaudio
  • shdown/pulseaudio
  • takaswie/pulseaudio
  • Mathy/pulseaudio
  • Mr-Tao/pulseaudio
  • ckdo/pulseaudio
  • rhkdtlr0/pulseaudio
  • mrdengbo/pulseaudio
  • c33howard/pulseaudio
  • jusa/pulseaudio
  • mlink/pulseaudio
  • bert/pulseaudio
  • leio/pulseaudio
  • manschwetus/pulseaudio
  • antoinegirardvallee/pulseaudio
  • roshal/pulseaudio
  • wegank/pulseaudio
  • Twitch0125/pulseaudio
  • heitbaum/pulseaudio
  • juimonen/pulseaudio
  • Isopod/pulseaudio
  • olani/pulseaudio
  • sthibaul/pulseaudio
  • kode54/pulseaudio
  • pgaskin/pulseaudio
  • t-8ch/pulseaudio
  • pan93412/pulseaudio
  • jpalus/pulseaudio
  • alldarrenamee007/pulseaudio
  • libinyang/pulseaudio
  • jprvita/pulseaudio
  • zootboy/pulseaudio
  • mikhailnov/pulseaudio
  • wtaymans/pulseaudio
  • carlosg/pulseaudio
  • rogierreerink/pulseaudio
  • renuac/pulseaudio
  • iamdrq/pulseaudio
  • gioele/pulseaudio
  • mohd-akram/pulseaudio
  • acheronfail/pulseaudio
  • nbrownus/pulseaudio
  • MarijnS95/pulseaudio
  • nostrad/pulseaudio
  • a-wai/pulseaudio
  • nick.moriarty/pulseaudio
  • imaami/pulseaudio
  • ranolfi/pulseaudio
  • dlahoti/pulseaudio
  • aspotashev/pulseaudio
  • dannyob/pulseaudio
  • SpotlightKid/pulseaudio
  • jcsing.lee/pulseaudio
  • welaq/pulseaudio
  • guest271314/pulseaudio
  • chutz/pulseaudio
  • codedninja/pulseaudio
  • kovdan01/pulseaudio
  • jorisc90/pulseaudio
  • mr-sour/pulseaudio
  • ueni/pulseaudio
  • zdave/pulseaudio
  • gebner/pulseaudio
  • lynxeye/pulseaudio
  • arp242/pulseaudio
  • kkang/pulseaudio
  • venam/pulseaudio
  • morrishoresh/pulseaudio
  • beniamin.kalinowski/pulseaudio
  • arun/pulseaudio
  • plevine457/pulseaudio
  • dongsibo/pulseaudio
  • tryone144/pulseaudio
  • tensorknower69/pulseaudio
  • philipp-s/pulseaudio
  • marcin.iwaniak/pulseaudio
  • evanmiller/pulseaudio
  • mfilion/pulseaudio
  • smesgr/pulseaudio
  • ammgws/pulseaudio
  • alesliehughes/pulseaudio-alh
  • hubenchang0515/pulseaudio
  • rebemlix/pulseaudio
  • sunyuechi/pulseaudio
  • kapiwko/pulseaudio
  • JulianoSC/pulseaudio
  • felixonmars/pulseaudio
  • torotil/pulseaudio
  • perexg/pulseaudio
  • acinonyx/pulseaudio
  • bobokjan77/pulseaudio
  • Leihognlun/pulseaudio
  • rytone/pulseaudio
  • nilninull/pulseaudio
  • SimonPilkington/pulseaudio
  • diegoakechi/pulseaudio
  • topimiettinen/pulseaudio
  • time-river/pulseaudio
  • l631197874/pulseaudio
  • SanchayanMaity/pulseaudio
  • hutsts/pulseaudio
  • jibecfed/pulseaudio
  • agowa338/pulseaudio
  • cgestes/pulseaudio
  • upsuper/pulseaudio
  • nicolasfella/pulseaudio
  • piotrdrag/pulseaudio
  • mwilck/pulseaudio
  • shlevy/pulseaudio
  • thanghn90/pulseaudio
  • ZakharyH/pulseaudio
  • BtbN/pulseaudio
  • georgyo1/pulseaudio
  • pwithnall/pulseaudio
  • unusual-thoughts/pulseaudio
  • e45lee/pulseaudio
  • kekek/pulseaudio
  • Hawk777/pulseaudio
  • SergioJun/pulseaudio
  • igor.v.kovalenko/pulseaudio
  • hanklank/pulseaudio
  • vanschelven/pulseaudio
  • sparkyb/pulseaudio
  • rafaelff/pulseaudio
  • sascha_silbe/pulseaudio
  • ricotz/pulseaudio
  • Marzal/pulseaudio
  • wwmm/pulseaudio
  • somdoron/pulseaudio
  • seb128/pulseaudio
  • smarter/pulseaudio
  • QuestofIranon/pulseaudio
  • dylanvanassche/pulseaudio
  • ssahb05/pulseaudio
  • skierpage/pulseaudio
  • mathieutournier/pulseaudio
  • andrey.semashev/pulseaudio
  • vest.niklas/pulseaudio
  • alanc/pulseaudio
  • eenurkka/pulseaudio
  • fsateler/pulseaudio
  • chiluk/pulseaudio
  • elijahflowers/pulseaudio
  • yurchor/pulseaudio
  • ogayot/pulseaudio
  • ra1nst0rm3d/pulseaudio
  • fran.dieguez/pulseaudio
  • tomty89/pulseaudio
  • paulyc/pulseaudio
  • kraj/pulseaudio
  • yu-re-ka/pulseaudio
  • liaohanqin/pulseaudio
  • alpernebbi/pulseaudio
  • matoro1/pulseaudio
  • peat-psuwit/pulseaudio
  • grafi-tt/pulseaudio
  • benpicco/pulseaudio
  • gchini/pulseaudio
  • Marv-CZ/pulseaudio
  • peterh/pulseaudio
  • hongphongn884/pulseaudio
  • pmeerw/pulseaudio
  • rtreleaven/pulseaudio
  • marcan/pulseaudio
  • niveditharau/pulseaudio
  • jordimas/pulseaudio
  • intelfx/pulseaudio
  • khfeng/pulseaudio
  • imposeren/pulseaudio
  • nelhage/pulseaudio
  • tanuk/pulseaudio
  • felixdoerre/pulseaudio
  • worldofpeace/pulseaudio
  • valpackett/pulseaudio
  • djoooooe/pulseaudio
  • dos/pulseaudio
  • MacTavishAO/pulseaudio
  • rmader/pulseaudio
  • scootergrisen/pulseaudio
  • Cogitri/pulseaudio
  • aerostitch/pulseaudio
  • heftig/pulseaudio
  • qyliss/pulseaudio
  • caitao-/pulseaudio
  • StefanBruens/pulseaudio
  • bigon/pulseaudio
  • dh/pulseaudio
  • taahm/pulseaudio
  • johanneswolf/pulseaudio
  • jan.staffel/pulseaudio
  • weblate/pulseaudio
  • fwolfff/pulseaudio
  • Hyperion/pulseaudio
  • vudentz/pulseaudio
  • jarnos/pulseaudio
  • qarmin/pulseaudio
  • rseichter/pulseaudio
  • hashitaku/pulseaudio
  • sangchul1011/pulseaudio
  • tart/pulseaudio
  • mangix/pulseaudio
  • pvir/pulseaudio
  • neochapay/pulseaudio
  • MiloCasagrande/pulseaudio
  • baurzhanm/pulseaudio
  • akostadinov/pulseaudio
  • yarikoptic/pulseaudio
  • speidy/pulseaudio
  • ahlinc/pulseaudio
  • jason77wang/pulseaudio
  • muzena/pulseaudio
  • pulseaudio/pulseaudio
  • NicoHood/pulseaudio
  • wengyingjie/pulseaudio
  • Tormen/pulseaudio
  • jwrdegoede/pulseaudio
  • cavallar/pulseaudio
  • chuck/pulseaudio
  • X1aomu/pulseaudio
  • wjt/pulseaudio
  • WhyNotHugo/pulseaudio
  • opoplawski/pulseaudio
  • peijiankang/pulseaudio
  • redfast00/pulseaudio
  • Am1GO/pulseaudio
  • kwg/pulseaudio
  • Shinigami072/pulseaudio
  • iljavs/pulseaudio
  • ktosiek/pulseaudio
249 results
Show changes
Commits on Source (2)
......@@ -60,6 +60,12 @@
#include <systemd/sd-daemon.h>
#endif
#ifdef HAVE_WINDOWS_H
#include <windows.h>
#include <aclapi.h>
#include <sddl.h>
#endif
#include <pulse/client-conf.h>
#include <pulse/mainloop.h>
#include <pulse/mainloop-signal.h>
......@@ -156,7 +162,95 @@ static void signal_callback(pa_mainloop_api* m, pa_signal_event *e, int sig, voi
}
}
#if defined(HAVE_PWD_H) && defined(HAVE_GRP_H)
#if defined(OS_IS_WIN32)
static int change_user(void) {
pa_log_info("Overriding system runtime/config base dir to '%s'.", pa_win32_get_system_appdata());
/* On other platforms, these paths are compiled into PulseAudio. This isn't
* suitable on Windows. Firstly, Windows doesn't follow the FHS or use Unix
* paths and the build system can't handle Windows-style paths properly.
* Secondly, the idiomatic location for a service's state and shared data is
* ProgramData, and the location of special folders is dynamic on Windows.
* Also, this method of handling paths is consistent with how they are
* handled on Windows in other parts of PA. Note that this is only needed
* in system-wide mode since paths in user instances are already handled
* properly.
*/
char *run_path = pa_sprintf_malloc("%s" PA_PATH_SEP "run", pa_win32_get_system_appdata());
char *lib_path = pa_sprintf_malloc("%s" PA_PATH_SEP "lib", pa_win32_get_system_appdata());
/* https://docs.microsoft.com/en-us/windows/win32/secauthz/ace-strings */
/* https://docs.microsoft.com/en-us/windows/win32/secauthz/modifying-the-acls-of-an-object-in-c-- */
/* https://docs.microsoft.com/en-us/windows/win32/api/sddl/nf-sddl-convertstringsecuritydescriptortosecuritydescriptora */
{
mkdir(run_path);
PSECURITY_DESCRIPTOR sd;
if (ConvertStringSecurityDescriptorToSecurityDescriptorA(
"D:PAI" /* DACL, disable inheritance from parent, enable propagation to children */
"(A;OICI;FA;;;SY)" /* give system full access */
"(A;OICI;FA;;;CO)" /* give owner full access */
"(A;OICI;FA;;;BA)" /* give administrators full access */
"(A;OICI;0x1200a9;;;WD)", /* give everyone read/write/execute access */
SDDL_REVISION_1, &sd, NULL
)) {
PACL acl;
BOOL acl_present, acl_default;
if (GetSecurityDescriptorDacl(sd, &acl_present, &acl, &acl_default)) {
if (SetNamedSecurityInfo(run_path, SE_FILE_OBJECT, DACL_SECURITY_INFORMATION | PROTECTED_DACL_SECURITY_INFORMATION, NULL, NULL, acl, NULL) != ERROR_SUCCESS) {
pa_log_warn("Failed to set DACL for runtime dir: failed to apply DACL: error %lu.", GetLastError());
}
LocalFree(acl);
} else {
pa_log_warn("Failed to set DACL for runtime dir: failed to get security descriptor DACL: error %lu.", GetLastError());
}
} else {
pa_log_warn("Failed to set DACL for runtime dir: failed to parse security descriptor: error %lu.", GetLastError());
}
}
{
mkdir(lib_path);
PSECURITY_DESCRIPTOR sd;
if (ConvertStringSecurityDescriptorToSecurityDescriptorA(
"D:PAI" /* DACL, disable inheritance from parent, enable propagation to children */
"(A;OICI;FA;;;SY)" /* give system full access */
"(A;OICI;FA;;;CO)" /* give owner full access */
"(A;OICI;FA;;;BA)", /* give administrators full access */
SDDL_REVISION_1, &sd, NULL
)) {
PACL acl;
BOOL acl_present, acl_default;
if (GetSecurityDescriptorDacl(sd, &acl_present, &acl, &acl_default)) {
if (SetNamedSecurityInfo(lib_path, SE_FILE_OBJECT, DACL_SECURITY_INFORMATION | PROTECTED_DACL_SECURITY_INFORMATION, NULL, NULL, acl, NULL) != ERROR_SUCCESS) {
pa_log_warn("Failed to set DACL for lib dir: failed to apply DACL: error %lu.", GetLastError());
}
LocalFree(acl);
} else {
pa_log_warn("Failed to set DACL for lib dir: failed to get security descriptor DACL: error %lu.", GetLastError());
}
} else {
pa_log_warn("Failed to set DACL for lib dir: failed to parse security descriptor: error %lu.", GetLastError());
}
}
pa_set_env("HOME", run_path);
if (!getenv("PULSE_RUNTIME_PATH"))
pa_set_env("PULSE_RUNTIME_PATH", run_path);
if (!getenv("PULSE_CONFIG_PATH"))
pa_set_env("PULSE_CONFIG_PATH", lib_path);
if (!getenv("PULSE_STATE_PATH"))
pa_set_env("PULSE_STATE_PATH", lib_path);
pa_xfree(run_path);
pa_xfree(lib_path);
pa_log_info("Not changing user for system instance on Windows.");
return 0;
}
#elif defined(HAVE_PWD_H) && defined(HAVE_GRP_H)
static int change_user(void) {
struct passwd *pw;
......@@ -377,7 +471,45 @@ fail:
}
#endif
#ifdef OS_IS_WIN32
#define SVC_NAME "PulseAudio"
static bool is_svc = true;
static int argc;
static char **argv;
static int real_main(int s_argc, char *s_argv[]);
static SERVICE_STATUS_HANDLE svc_status;
DWORD svc_callback(DWORD ctl, DWORD evt, LPVOID data, LPVOID userdata) {
pa_mainloop **m = userdata;
switch (ctl) {
case SERVICE_CONTROL_STOP:
case SERVICE_CONTROL_SHUTDOWN:
if (m) {
pa_log_info("Exiting.");
pa_mainloop_get_api(*m)->quit(pa_mainloop_get_api(*m), 0);
}
return NO_ERROR;
case SERVICE_CONTROL_INTERROGATE:
return NO_ERROR;
}
return ERROR_CALL_NOT_IMPLEMENTED;
}
int main(int p_argc, char *p_argv[]) {
argc = p_argc;
argv = p_argv;
if (StartServiceCtrlDispatcherA((SERVICE_TABLE_ENTRYA[]){
{SVC_NAME, (LPSERVICE_MAIN_FUNCTIONA) real_main},
{0},
})) return 0;
is_svc = false;
return real_main(0, NULL);
}
static int real_main(int s_argc, char *s_argv[]) {
#else
int main(int argc, char *argv[]) {
#endif
pa_core *c = NULL;
pa_strbuf *buf = NULL;
pa_daemon_conf *conf = NULL;
......@@ -402,6 +534,23 @@ int main(int argc, char *argv[]) {
bool start_server;
#endif
#ifdef OS_IS_WIN32
if (is_svc && !(svc_status = RegisterServiceCtrlHandlerExA(SVC_NAME, (LPHANDLER_FUNCTION_EX) svc_callback, &mainloop))) {
pa_log("Failed to register service control handler.");
goto finish;
}
if (is_svc) {
SetServiceStatus(svc_status, &(SERVICE_STATUS){
.dwServiceType = SERVICE_WIN32,
.dwCurrentState = SERVICE_START_PENDING,
.dwControlsAccepted = 0,
.dwWin32ExitCode = NO_ERROR,
.dwWaitHint = 3000,
});
}
#endif
pa_log_set_ident("pulseaudio");
pa_log_set_level(PA_LOG_NOTICE);
pa_log_set_flags(PA_LOG_COLORS|PA_LOG_PRINT_FILE|PA_LOG_PRINT_LEVEL, PA_LOG_RESET);
......@@ -1172,6 +1321,18 @@ int main(int argc, char *argv[]) {
sd_notify(0, "READY=1");
#endif
#ifdef OS_IS_WIN32
if (is_svc) {
SetServiceStatus(svc_status, &(SERVICE_STATUS){
.dwServiceType = SERVICE_WIN32,
.dwCurrentState = SERVICE_RUNNING,
.dwControlsAccepted = SERVICE_ACCEPT_STOP|SERVICE_ACCEPT_SHUTDOWN,
.dwWin32ExitCode = NO_ERROR,
.dwWaitHint = 0,
});
}
#endif
retval = 0;
if (pa_mainloop_run(mainloop, &retval) < 0)
goto finish;
......@@ -1182,6 +1343,18 @@ int main(int argc, char *argv[]) {
sd_notify(0, "STOPPING=1");
#endif
#ifdef OS_IS_WIN32
if (is_svc) {
SetServiceStatus(svc_status, &(SERVICE_STATUS){
.dwServiceType = SERVICE_WIN32,
.dwCurrentState = SERVICE_STOP_PENDING,
.dwControlsAccepted = 0,
.dwWin32ExitCode = NO_ERROR,
.dwWaitHint = 2000,
});
}
#endif
finish:
#ifdef HAVE_DBUS
if (server_bus)
......@@ -1249,5 +1422,17 @@ finish:
dbus_shutdown();
#endif
#ifdef OS_IS_WIN32
if (is_svc) {
SetServiceStatus(svc_status, &(SERVICE_STATUS){
.dwServiceType = SERVICE_WIN32,
.dwCurrentState = SERVICE_STOPPED,
.dwControlsAccepted = 0,
.dwWin32ExitCode = retval ? ERROR_PROCESS_ABORTED : NO_ERROR,
.dwWaitHint = 0,
});
}
#endif
return retval;
}
......@@ -1035,7 +1035,14 @@ int pa_context_connect(
}
/* The system wide instance via PF_LOCAL */
#ifndef OS_IS_WIN32
c->server_list = pa_strlist_prepend(c->server_list, PA_SYSTEM_RUNTIME_PATH PA_PATH_SEP PA_NATIVE_DEFAULT_UNIX_SOCKET);
#else
/* see change_user in src/daemon/main.c */
char *run_path = pa_sprintf_malloc("%s" PA_PATH_SEP "run" PA_PATH_SEP PA_NATIVE_DEFAULT_UNIX_SOCKET, pa_win32_get_system_appdata());
c->server_list = pa_strlist_prepend(c->server_list, run_path);
pa_xfree(run_path);
#endif
/* The user instance via PF_LOCAL */
c->server_list = prepend_per_user(c->server_list);
......
......@@ -83,6 +83,7 @@
#ifdef HAVE_WINDOWS_H
#include <windows.h>
#include <shlobj.h>
#endif
#ifndef ENOTSUP
......@@ -171,6 +172,15 @@ char *pa_win32_get_toplevel(HANDLE handle) {
return toplevel;
}
char *pa_win32_get_system_appdata() {
static char appdata[MAX_PATH] = {0};
if (!*appdata && SHGetFolderPathAndSubDirA(NULL, CSIDL_COMMON_APPDATA|CSIDL_FLAG_CREATE, NULL, SHGFP_TYPE_CURRENT, "PulseAudio", appdata) != S_OK)
return NULL;
return appdata;
}
#endif
static void set_nonblock(int fd, bool nonblock) {
......
......@@ -310,6 +310,7 @@ bool pa_running_in_vm(void);
#ifdef OS_IS_WIN32
char *pa_win32_get_toplevel(HANDLE handle);
char *pa_win32_get_system_appdata();
#endif
size_t pa_page_size(void);
......