[PATCH v2] erofs-utils: support selinux file contexts

Li GuiFu bluce.lee at aliyun.com
Sun Jun 7 19:25:12 AEST 2020


It cacuses one build error in my Ubuntu 18.04.1 LTS
and it seems selinux static lib link cause it
libtool: link: gcc -Wall -Werror -I../include -g -O2 -static -o
mkfs.erofs mkfs_erofs-main.o  ../lib/.libs/liberofs.a
-L/home/liguifu/codes/lz4 -luuid -lselinux -llz4
/usr/lib/gcc/x86_64-linux-gnu/8/../../../x86_64-linux-gnu/libselinux.a(seusers.o):
In function `getseuserbyname':
(.text+0x5e9): warning: Using 'getgrouplist' in statically linked
applications requires at runtime the shared libraries from the glibc
version used for linking
(.text+0x570): warning: Using 'getgrnam_r' in statically linked
applications requires at runtime the shared libraries from the glibc
version used for linking
(.text+0x9e): warning: Using 'getpwnam_r' in statically linked
applications requires at runtime the shared libraries from the glibc
version used for linking
/usr/lib/gcc/x86_64-linux-gnu/8/../../../x86_64-linux-gnu/libselinux.a(regex.o):
In function `regex_writef':
(.text+0x73): undefined reference to `pcre_fullinfo'
(.text+0xe7): undefined reference to `pcre_fullinfo'
/usr/lib/gcc/x86_64-linux-gnu/8/../../../x86_64-linux-gnu/libselinux.a(regex.o):
In function `regex_data_free':
(.text+0x1da): undefined reference to `pcre_free'
(.text+0x1e8): undefined reference to `pcre_free_study'
/usr/lib/gcc/x86_64-linux-gnu/8/../../../x86_64-linux-gnu/libselinux.a(regex.o):
In function `regex_prepare_data':
(.text+0x248): undefined reference to `pcre_compile'
(.text+0x269): undefined reference to `pcre_study'
/usr/lib/gcc/x86_64-linux-gnu/8/../../../x86_64-linux-gnu/libselinux.a(regex.o):
In function `regex_load_mmap':
(.text+0x36a): undefined reference to `pcre_fullinfo'
(.text+0x3df): undefined reference to `pcre_fullinfo'
/usr/lib/gcc/x86_64-linux-gnu/8/../../../x86_64-linux-gnu/libselinux.a(regex.o):
In function `regex_match':
(.text+0x48b): undefined reference to `pcre_exec'
/usr/lib/gcc/x86_64-linux-gnu/8/../../../x86_64-linux-gnu/libselinux.a(regex.o):
In function `regex_cmp':
(.text+0x4ed): undefined reference to `pcre_fullinfo'
(.text+0x506): undefined reference to `pcre_fullinfo'
/usr/lib/gcc/x86_64-linux-gnu/8/../../../x86_64-linux-gnu/libselinux.a(regex.o):
In function `regex_version':
(.text+0x11): undefined reference to `pcre_version'
/usr/lib/gcc/x86_64-linux-gnu/8/../../../x86_64-linux-gnu/libselinux.a(load_policy.o):
In function `selinux_mkload_policy':
(.text+0x134): undefined reference to `sepol_policy_kern_vers_max'
(.text+0x13d): undefined reference to `sepol_policy_kern_vers_min'
(.text+0x2f3): undefined reference to `sepol_policy_kern_vers_max'
(.text+0x2fc): undefined reference to `sepol_policy_kern_vers_min'
(.text+0x331): undefined reference to `sepol_policy_kern_vers_max'
(.text+0x33a): undefined reference to `sepol_policy_kern_vers_min'
(.text+0x3b2): undefined reference to `sepol_policy_file_create'
(.text+0x3c4): undefined reference to `sepol_policydb_create'
(.text+0x3e0): undefined reference to `sepol_policy_file_set_mem'
(.text+0x3ef): undefined reference to `sepol_policydb_read'
(.text+0x405): undefined reference to `sepol_policydb_set_vers'
(.text+0x41f): undefined reference to `sepol_policydb_to_image'
(.text+0x451): undefined reference to `sepol_policy_file_free'
(.text+0x45b): undefined reference to `sepol_policydb_free'
(.text+0x4a0): undefined reference to `sepol_policy_kern_vers_max'
(.text+0x4a9): undefined reference to `sepol_policy_kern_vers_min'
(.text+0x4bf): undefined reference to `sepol_policy_file_free'
(.text+0x4c9): undefined reference to `sepol_policydb_free'
(.text+0x5bf): undefined reference to `sepol_policy_file_free'
(.text+0x5d3): undefined reference to `sepol_policy_file_free'
(.text+0x5dd): undefined reference to `sepol_policydb_free'
(.text+0x6d9): undefined reference to `sepol_genbools_array'
(.text+0x73a): undefined reference to `sepol_genusers'
(.text+0x76e): undefined reference to `sepol_genbools'
collect2: error: ld returned 1 exit status
Makefile:398: recipe for target 'mkfs.erofs' failed

On 2020/6/6 16:17, Gao Xiang wrote:
> Add --file-contexts flag that allows passing a selinux
> file_context file to setup file selabels.
> 
> Signed-off-by: Gao Xiang <hsiangkao at redhat.com>
> ---
> changes since v1:
>  fix selinux error handing and wrap up selabel
>  open pointed out by Guifu;
> 
>  configure.ac           |  27 +++++++++
>  include/erofs/config.h |  21 +++++++
>  include/erofs/xattr.h  |   3 +-
>  lib/config.c           |  42 +++++++++++++
>  lib/exclude.c          |  12 +---
>  lib/inode.c            |   3 +-
>  lib/xattr.c            | 130 ++++++++++++++++++++++++++++++++---------
>  man/mkfs.erofs.1       |   3 +
>  mkfs/Makefile.am       |   4 +-
>  mkfs/main.c            |  15 ++++-
>  10 files changed, 217 insertions(+), 43 deletions(-)
> 


More information about the Linux-erofs mailing list