The open source OpenXR runtime
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

ipc: Allow UWP/AppContainer and others to connect

Including: UWP/AppContainer, Authenticated user and Administrator. Currently
guarded with IPC_RELAXED_CONNECTION_SECURITY env variable.

+58 -1
+1
scripts/monado-codespell.exclude
··· 5 5 #include <Unknwn.h> 6 6 #include <asm/byteorder.h> 7 7 if (stream.parm.capture.capability & V4L2_CAP_TIMEPERFRAME) { 8 + TEXT("(A;OICI;GA;;;BA)"); // Administrator: full control
+57 -1
src/xrt/ipc/server/ipc_server_mainloop_windows.cpp
··· 26 26 #include "util/u_debug.h" 27 27 #include "util/u_trace_marker.h" 28 28 #include "util/u_file.h" 29 + #include "util/u_windows.h" 29 30 30 31 #include "shared/ipc_shmem.h" 31 32 #include "server/ipc_server.h" 32 33 33 34 #include <conio.h> 35 + #include <sddl.h> 36 + 37 + 38 + /* 39 + * 40 + * Helpers. 41 + * 42 + */ 43 + 44 + #define ERROR_STR(BUF, ERR) (u_winerror(BUF, ARRAY_SIZE(BUF), ERR, true)) 45 + 46 + DEBUG_GET_ONCE_BOOL_OPTION(relaxed, "IPC_RELAXED_CONNECTION_SECURITY", false) 34 47 35 48 36 49 /* ··· 42 55 static bool 43 56 create_pipe_instance(struct ipc_server_mainloop *ml, bool first) 44 57 { 58 + SECURITY_ATTRIBUTES sa{}; 59 + sa.nLength = sizeof(sa); 60 + sa.lpSecurityDescriptor = nullptr; 61 + sa.bInheritHandle = FALSE; 62 + 63 + /* 64 + * Change the pipe's DACL to allow other users access. 65 + * 66 + * https://learn.microsoft.com/en-us/windows/win32/secbp/creating-a-dacl 67 + * https://learn.microsoft.com/en-us/windows/win32/secauthz/sid-strings 68 + */ 69 + const TCHAR *str = // 70 + TEXT("D:") // Discretionary ACL 71 + TEXT("(D;OICI;GA;;;BG)") // Guest: deny 72 + TEXT("(D;OICI;GA;;;AN)") // Anonymous: deny 73 + TEXT("(A;OICI;GRGWGX;;;AC)") // UWP/AppContainer packages: read/write/execute 74 + TEXT("(A;OICI;GRGWGX;;;AU)") // Authenticated user: read/write/execute 75 + TEXT("(A;OICI;GA;;;BA)"); // Administrator: full control 76 + 77 + BOOL bret = ConvertStringSecurityDescriptorToSecurityDescriptor( // 78 + str, // StringSecurityDescriptor 79 + SDDL_REVISION_1, // StringSDRevision 80 + &sa.lpSecurityDescriptor, // SecurityDescriptor 81 + NULL); // SecurityDescriptorSize 82 + if (!bret) { 83 + DWORD err = GetLastError(); 84 + char buffer[1024]; 85 + U_LOG_E("ConvertStringSecurityDescriptorToSecurityDescriptor: %u %s", err, ERROR_STR(buffer, err)); 86 + } 87 + 88 + LPSECURITY_ATTRIBUTES lpsa = nullptr; 89 + if (debug_get_bool_option_relaxed()) { 90 + U_LOG_W("Using relax security permissions on pipe"); 91 + lpsa = &sa; 92 + } 93 + 45 94 DWORD dwOpenMode = PIPE_ACCESS_DUPLEX; 46 95 DWORD dwPipeMode = PIPE_TYPE_MESSAGE | PIPE_READMODE_MESSAGE | PIPE_NOWAIT | PIPE_REJECT_REMOTE_CLIENTS; 47 96 ··· 57 106 IPC_BUF_SIZE, // 58 107 IPC_BUF_SIZE, // 59 108 0, // 60 - nullptr); // 109 + lpsa); // 110 + 111 + if (sa.lpSecurityDescriptor != nullptr) { 112 + // Need to free the security descriptor. 113 + LocalFree(sa.lpSecurityDescriptor); 114 + sa.lpSecurityDescriptor = nullptr; 115 + } 116 + 61 117 if (ml->pipe_handle != INVALID_HANDLE_VALUE) { 62 118 return true; 63 119 }