Merge commit from fork
This commit is contained in:
@ -279,7 +279,12 @@ else ()
|
|||||||
message (" Libc builtin disabled")
|
message (" Libc builtin disabled")
|
||||||
endif ()
|
endif ()
|
||||||
if (WAMR_BUILD_LIBC_UVWASI EQUAL 1)
|
if (WAMR_BUILD_LIBC_UVWASI EQUAL 1)
|
||||||
message (" Libc WASI enabled with uvwasi implementation")
|
message (" Libc WASI enabled with uvwasi implementation\n"
|
||||||
|
" WANRING:: uvwasi does not currently provide the comprehensive\n"
|
||||||
|
" file system security properties provided by some WASI runtimes.\n"
|
||||||
|
" Full support for secure file system sandboxing may or may not\n"
|
||||||
|
" be implemented in future. In the mean time, DO NOT RELY ON IT\n"
|
||||||
|
" TO RUN UNTRUSTED CODE.")
|
||||||
elseif (WAMR_BUILD_LIBC_WASI EQUAL 1)
|
elseif (WAMR_BUILD_LIBC_WASI EQUAL 1)
|
||||||
message (" Libc WASI enabled")
|
message (" Libc WASI enabled")
|
||||||
else ()
|
else ()
|
||||||
|
|||||||
@ -10,7 +10,7 @@ set(CMAKE_POLICY_VERSION_MINIMUM 3.5 FORCE)
|
|||||||
|
|
||||||
set (LIBC_WASI_DIR ${CMAKE_CURRENT_LIST_DIR})
|
set (LIBC_WASI_DIR ${CMAKE_CURRENT_LIST_DIR})
|
||||||
|
|
||||||
set (LIBUV_VERSION v1.46.0)
|
set (LIBUV_VERSION v1.51.0)
|
||||||
|
|
||||||
add_definitions (-DWASM_ENABLE_LIBC_WASI=1 -DWASM_ENABLE_UVWASI=1)
|
add_definitions (-DWASM_ENABLE_LIBC_WASI=1 -DWASM_ENABLE_UVWASI=1)
|
||||||
|
|
||||||
@ -29,15 +29,10 @@ else()
|
|||||||
GIT_REPOSITORY https://github.com/libuv/libuv.git
|
GIT_REPOSITORY https://github.com/libuv/libuv.git
|
||||||
GIT_TAG ${LIBUV_VERSION}
|
GIT_TAG ${LIBUV_VERSION}
|
||||||
)
|
)
|
||||||
FetchContent_GetProperties(libuv)
|
FetchContent_MakeAvailable(libuv)
|
||||||
if (NOT libuv_POPULATED)
|
include_directories("${libuv_SOURCE_DIR}/include")
|
||||||
message("-- Fetching libuv ..")
|
set (LIBUV_LIBRARIES uv_a)
|
||||||
FetchContent_Populate(libuv)
|
set_target_properties(uv_a PROPERTIES POSITION_INDEPENDENT_CODE 1)
|
||||||
include_directories("${libuv_SOURCE_DIR}/include")
|
|
||||||
add_subdirectory(${libuv_SOURCE_DIR} ${libuv_BINARY_DIR} EXCLUDE_FROM_ALL)
|
|
||||||
set (LIBUV_LIBRARIES uv_a)
|
|
||||||
set_target_properties(uv_a PROPERTIES POSITION_INDEPENDENT_CODE 1)
|
|
||||||
endif()
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
## uvwasi
|
## uvwasi
|
||||||
@ -48,17 +43,12 @@ else()
|
|||||||
FetchContent_Declare(
|
FetchContent_Declare(
|
||||||
uvwasi
|
uvwasi
|
||||||
GIT_REPOSITORY https://github.com/nodejs/uvwasi.git
|
GIT_REPOSITORY https://github.com/nodejs/uvwasi.git
|
||||||
GIT_TAG main
|
GIT_TAG v0.0.21
|
||||||
)
|
)
|
||||||
FetchContent_GetProperties(uvwasi)
|
FetchContent_MakeAvailable(uvwasi)
|
||||||
if (NOT uvwasi_POPULATED)
|
include_directories("${uvwasi_SOURCE_DIR}/include")
|
||||||
message("-- Fetching uvwasi ..")
|
set (UVWASI_LIBRARIES uvwasi_a)
|
||||||
FetchContent_Populate(uvwasi)
|
set_target_properties(uvwasi_a PROPERTIES POSITION_INDEPENDENT_CODE 1)
|
||||||
include_directories("${uvwasi_SOURCE_DIR}/include")
|
|
||||||
add_subdirectory(${uvwasi_SOURCE_DIR} ${uvwasi_BINARY_DIR} EXCLUDE_FROM_ALL)
|
|
||||||
set (UVWASI_LIBRARIES uvwasi_a)
|
|
||||||
set_target_properties(uvwasi_a PROPERTIES POSITION_INDEPENDENT_CODE 1)
|
|
||||||
endif()
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
set (UV_A_LIBS ${LIBUV_LIBRARIES} ${UVWASI_LIBRARIES})
|
set (UV_A_LIBS ${LIBUV_LIBRARIES} ${UVWASI_LIBRARIES})
|
||||||
|
|||||||
@ -890,6 +890,24 @@ wasi_path_symlink(wasm_exec_env_t exec_env, const char *old_path,
|
|||||||
if (!uvwasi)
|
if (!uvwasi)
|
||||||
return (wasi_errno_t)-1;
|
return (wasi_errno_t)-1;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* check if old_path is valid.
|
||||||
|
* if it is a symlink, follow it.
|
||||||
|
*
|
||||||
|
* this is a workaround for the fact that
|
||||||
|
* uvwasi_path_symlink does not check if the old_path is valid
|
||||||
|
*
|
||||||
|
* the goal is trigger uvwasi__resolve_path() to check
|
||||||
|
*/
|
||||||
|
{
|
||||||
|
uvwasi_filestat_t filestat = { 0 };
|
||||||
|
wasi_errno_t err =
|
||||||
|
uvwasi_path_filestat_get(uvwasi, fd, UVWASI_LOOKUP_SYMLINK_FOLLOW,
|
||||||
|
old_path, old_path_len, &filestat);
|
||||||
|
if (err)
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
|
||||||
return uvwasi_path_symlink(uvwasi, old_path, old_path_len, fd, new_path,
|
return uvwasi_path_symlink(uvwasi, old_path, old_path_len, fd, new_path,
|
||||||
new_path_len);
|
new_path_len);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user