Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions .github/workflows/CI-win.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,17 @@ jobs:
shell: cmd
run:
build\\RelWithDebInfo\\uv_run_tests_a.exe
- name: Test AppContainer
if: ${{ matrix.config.arch != 'arm64' }}
shell: cmd
run:
build\\RelWithDebInfo\\uv_run_appcontainer.exe build\\RelWithDebInfo\\${{ matrix.config.config == 'ASAN' && 'uv_run_tests_a.exe' || 'uv_run_tests.exe' }}

build-mingw:
runs-on: ubuntu-latest
# Note: Using ubuntu-26.04 early (before it becomes ubuntu-latest)
# for access to a newer mingw for #5181.
# Can change back to ubuntu-latest once it means 26.04 or later.
runs-on: ubuntu-26.04
name: build-mingw-${{ matrix.config.arch }}
strategy:
fail-fast: false
Expand All @@ -91,7 +99,8 @@ jobs:
cmake --install build --prefix "`pwd`/build/usr"
mkdir -p build/usr/test build/usr/bin
cp -av test/fixtures build/usr/test
cp -av build/uv_run_tests_a.exe build/uv_run_tests.exe build/uv_run_tests_a_no_ext build/uv_run_tests_no_ext \
cp -av build/uv_run_tests_a.exe build/uv_run_tests.exe build/uv_run_appcontainer.exe \
build/uv_run_tests_a_no_ext build/uv_run_tests_no_ext \
`${{ matrix.config.arch }}-w64-mingw32-gcc -print-file-name=libgcc_s_${{ matrix.config.libgcc }}-1.dll` \
`${{ matrix.config.arch }}-w64-mingw32-gcc -print-file-name=libwinpthread-1.dll` \
`${{ matrix.config.arch }}-w64-mingw32-gcc -print-file-name=libatomic-1.dll` \
Expand Down Expand Up @@ -126,3 +135,7 @@ jobs:
shell: cmd
run: |
bin\uv_run_tests.exe
- name: Test AppContainer
shell: cmd
run: |
bin\uv_run_appcontainer.exe bin\uv_run_tests.exe
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -747,6 +747,8 @@ if(LIBUV_BUILD_TESTS)
COMMAND "${CMAKE_COMMAND}" -E copy
"$<TARGET_FILE:uv_run_tests_a>"
"$<TARGET_FILE_DIR:uv_run_tests_a>/uv_run_tests_a_no_ext")
add_executable(uv_run_appcontainer test/appcontainer.c)
target_link_libraries(uv_run_appcontainer userenv advapi32 ntdll)
endif()

if(QNX)
Expand Down
36 changes: 35 additions & 1 deletion src/win/pipe.c
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,42 @@ static int includes_nul(const char *s, size_t n) {
}


static int uv_is_app_container_;
static uv_once_t uv_is_app_container_guard_ = UV_ONCE_INIT;


/* Is this process running under Windows AppContainer? */
/* Detection algorithm from https://learn.microsoft.com/en-us/windows/win32/secauthz/appcontainer-for-legacy-applications- */
static void uv__init__is_app_container(void) {
HANDLE token;
DWORD ac;
DWORD len;
int ok;

if (!OpenProcessToken(GetCurrentProcess(), TOKEN_QUERY, &token)) {
uv_is_app_container_ = 0;
return;
}
ac = 0;
len = sizeof(ac);
ok = GetTokenInformation(token, TokenIsAppContainer, &ac, len, &len);
CloseHandle(token);
uv_is_app_container_ = ok && ac != 0;
}


/* Is this process running under Windows AppContainer? */
/* Cached form for repeated use in the process. */
static int uv__is_appcontainer(void) {
uv_once(&uv_is_app_container_guard_, uv__init__is_app_container);
return uv_is_app_container_;
}


static void uv__unique_pipe_name(unsigned long long ptr, char* name, size_t size) {
snprintf(name, size, "\\\\?\\pipe\\uv\\%llu-%lu", ptr, GetCurrentProcessId());
snprintf(name, size, "\\\\?\\pipe\\%suv\\%llu-%lu",
uv__is_appcontainer() ? "LOCAL\\" : "",
ptr, GetCurrentProcessId());
}


Expand Down
Loading