From aeb87620d8f088a108033eccbdf74733c7c3cfb5 Mon Sep 17 00:00:00 2001 From: lubinglun Date: Tue, 23 Apr 2024 11:11:38 +0800 Subject: [PATCH 1/4] expose libc interface:dlvsym,crypt,eaccess Issue:https://gitee.com/openharmony/interface_sdk_c/issues/I97JTK Signed-off-by: lubinglun --- third_party/musl/ndk_musl_include/dlfcn.h | 13 ++++++++++ third_party/musl/ndk_musl_include/unistd.h | 26 +++++++++++++++++++ .../musl/ndk_script/adapter/libc.ndk.json | 3 +++ 3 files changed, 42 insertions(+) diff --git a/third_party/musl/ndk_musl_include/dlfcn.h b/third_party/musl/ndk_musl_include/dlfcn.h index c764c8bed..998f0f196 100644 --- a/third_party/musl/ndk_musl_include/dlfcn.h +++ b/third_party/musl/ndk_musl_include/dlfcn.h @@ -25,6 +25,19 @@ char *dlerror(void); void *dlopen(const char *, int); void *dlsym(void *__restrict, const char *__restrict); + +/** + * @brief Obtain address of a symbol in a shared object or executable + * + * @param (void *__restrict): the handle to the dynamic link library + * @param (const char *restrict): the name of the symbol to be looked up + * @param (const char *restrict): the specific version of the symbol to be looked up + * + * @return On success, return the address associated with symbol. On failure, return NULL + * @since 12 +*/ +void *dlvsym(void *__restrict, const char *__restrict, const char *__restrict); + /* namespace apis */ #define NS_NAME_MAX 255 typedef struct { diff --git a/third_party/musl/ndk_musl_include/unistd.h b/third_party/musl/ndk_musl_include/unistd.h index c0556ab7f..0ba4de63e 100644 --- a/third_party/musl/ndk_musl_include/unistd.h +++ b/third_party/musl/ndk_musl_include/unistd.h @@ -138,6 +138,20 @@ int lockf(int, int, off_t); int nice(int); void sync(void); pid_t setpgrp(void); + +/** + * @brief Encrypts a password using the DES algorithm. + * + * The `crypt` function encrypts the given password string using the DES algorithm + * and returns the encrypted string. It is commonly used for storing and verifying user passwords. + * + * @param (const char *) The password string to be encrypted. + * @param (const char *) The salt value string used to increase the randomness of encryption. + * + * @return Return the encrypted string or NULL in case of an error. + * @since 12 +*/ +char *crypt(const char *, const char *); void swab(const void *__restrict, void *__restrict, ssize_t); #endif @@ -176,6 +190,18 @@ int setresgid(gid_t, gid_t, gid_t); int getresuid(uid_t *, uid_t *, uid_t *); int getresgid(gid_t *, gid_t *, gid_t *); int syncfs(int); + +/** + * @brief Check permissions and existence of the file identified by pathname. + * + * @param (const char *) Path to the file. + * @param (int) The access permissions to be tested. + * + * @return On success, zero is returned, On error, -1 is returned + * + * @since 12 +*/ +int eaccess(const char *, int); ssize_t copy_file_range(int, off_t *, int, off_t *, size_t, unsigned); pid_t gettid(void); #endif diff --git a/third_party/musl/ndk_script/adapter/libc.ndk.json b/third_party/musl/ndk_script/adapter/libc.ndk.json index 41070eecd..db27a438d 100644 --- a/third_party/musl/ndk_script/adapter/libc.ndk.json +++ b/third_party/musl/ndk_script/adapter/libc.ndk.json @@ -257,6 +257,7 @@ { "name": "creall" }, { "name": "creat" }, { "name": "creat64" }, + { "name": "crypt" }, { "name": "csin" }, { "name": "csinf" }, { "name": "csinh" }, @@ -287,6 +288,7 @@ { "name": "dlerror" }, { "name": "dlopen" }, { "name": "dlsym" }, + { "name": "dlvsym" }, { "name": "dn_comp" }, { "name": "dn_expand" }, { "name": "dn_skipname" }, @@ -298,6 +300,7 @@ { "name": "dup2" }, { "name": "dup3" }, { "name": "duplocale" }, + { "name": "eaccess" }, { "name": "endgrent" }, { "name": "endhostent" }, { "name": "endmntent" }, -- Gitee From a16067aee7790366a3fab0562eb82d3972102c98 Mon Sep 17 00:00:00 2001 From: lubinglun Date: Wed, 24 Apr 2024 01:50:42 +0000 Subject: [PATCH 2/4] update third_party/musl/ndk_musl_include/unistd.h. Signed-off-by: lubinglun --- third_party/musl/ndk_musl_include/unistd.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/third_party/musl/ndk_musl_include/unistd.h b/third_party/musl/ndk_musl_include/unistd.h index 0ba4de63e..b439de66c 100644 --- a/third_party/musl/ndk_musl_include/unistd.h +++ b/third_party/musl/ndk_musl_include/unistd.h @@ -140,13 +140,13 @@ void sync(void); pid_t setpgrp(void); /** - * @brief Encrypts a password using the DES algorithm. + * @brief Encrypts a password using the DES algorithm * * The `crypt` function encrypts the given password string using the DES algorithm - * and returns the encrypted string. It is commonly used for storing and verifying user passwords. + * and returns the encrypted string. It is commonly used for storing and verifying user passwords * * @param (const char *) The password string to be encrypted. - * @param (const char *) The salt value string used to increase the randomness of encryption. + * @param (const char *) The salt value string used to increase the randomness of encryption * * @return Return the encrypted string or NULL in case of an error. * @since 12 -- Gitee From 3649827d61f3bdf6597bce7c3d29995231172c0d Mon Sep 17 00:00:00 2001 From: lubinglun Date: Wed, 24 Apr 2024 01:52:38 +0000 Subject: [PATCH 3/4] update third_party/musl/ndk_musl_include/unistd.h. Signed-off-by: lubinglun --- third_party/musl/ndk_musl_include/unistd.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/third_party/musl/ndk_musl_include/unistd.h b/third_party/musl/ndk_musl_include/unistd.h index b439de66c..ba046d4d4 100644 --- a/third_party/musl/ndk_musl_include/unistd.h +++ b/third_party/musl/ndk_musl_include/unistd.h @@ -197,7 +197,7 @@ int syncfs(int); * @param (const char *) Path to the file. * @param (int) The access permissions to be tested. * - * @return On success, zero is returned, On error, -1 is returned + * @return On success, zero is returned. On error, -1 is returned * * @since 12 */ -- Gitee From aa8722d34bac6f9f4f2c6978d5283cbcc2c5917f Mon Sep 17 00:00:00 2001 From: lubinglun Date: Wed, 24 Apr 2024 01:54:36 +0000 Subject: [PATCH 4/4] update third_party/musl/ndk_musl_include/dlfcn.h. Signed-off-by: lubinglun --- third_party/musl/ndk_musl_include/dlfcn.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/third_party/musl/ndk_musl_include/dlfcn.h b/third_party/musl/ndk_musl_include/dlfcn.h index 998f0f196..985529a0d 100644 --- a/third_party/musl/ndk_musl_include/dlfcn.h +++ b/third_party/musl/ndk_musl_include/dlfcn.h @@ -29,14 +29,14 @@ void *dlsym(void *__restrict, const char *__restrict); /** * @brief Obtain address of a symbol in a shared object or executable * - * @param (void *__restrict): the handle to the dynamic link library - * @param (const char *restrict): the name of the symbol to be looked up - * @param (const char *restrict): the specific version of the symbol to be looked up + * @param (void *__restrict) the handle to the dynamic link library + * @param (const char *restrict) the name of the symbol to be looked up + * @param (const char *restrict) the specific version of the symbol to be looked up * * @return On success, return the address associated with symbol. On failure, return NULL * @since 12 */ -void *dlvsym(void *__restrict, const char *__restrict, const char *__restrict); +void *dlvsym(void *__restrict, const char *__restrict, const char *__restrict); /* namespace apis */ #define NS_NAME_MAX 255 -- Gitee