Skip to contentSkip to conversation

openssl: set package level PERL5LIB

PATCH In review [email protected] 1 participant 2 messages Apr 21, 2023 – Apr 25, 2023

lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 openssl: set package level PERL5LIB

From: Yang Xu <[email protected]>

Build openssl with shared state cache may meet problem under below conditions:
1. sstate cache generated by another user on same machine
2. inappropriate PERL5LIB setting
3. openssl build from scratch but perl using cache

When build openssl from scratch with perl using cache, it will be aborted at do_configure stage,
error message is like "Can't locate Text/Template.pm at /home/A/[build path]/[perl module path]/Text/Template.pm : Permission Denied".

The simplified environment and scenarios is:
1) User A, his home directory is /home/A, generate one sstate cache under /home/A.
2) This sstate cache moved to /home/Public, act as shared sstate cache
3) User B, his home directory is /home/B, using sstate cache in /home/Public and build yocto.
4) User B has no permission to access /home/A.

Some information about perl behavior:
1. perl will hardcode buildtime path in @INC in binary (module search directories)
2. when "use MODULE", perl will search @INC from begin to end until it found MODULE.
3. when perl search module through directories in @INC
3.1 if [directory]/MODULE.pm is not exist, search in next directory in @INC. 3.2 if [directory]/MODULE.pm has no permission to access, perl will ABORT.

While build openssl from from scratch with perl using cache, @INC directory order is:
1.<PERL5LIB>
2.<default module path in ${WORKDIR}/recipe-sysroot-native>
3.<hardcode module path in binary, which include /home/A/XXX/YYY> 4.<module found by FindBin, module Text-Template can be found by it>

Without appropriate PERL5LIB setting, perl can't find Text/Template.pm in <PERL5LIB>, and it also can't find it in <default module path>.

Then perl search Text/Template.pm in <hardcode module path in binary>,
*if /home/A is not existed, perl will search in <module found by FindBin> and found Text/Template.pm finally. (OK case) *if /home/A is existed but has no permission access, perl will ABORT immediately. (NG case)

So this patch does some fixup for NG case:
1) set appropriate PERL5LIB to make perl can found Text/Tempalte.pm at highest priority folder <PERL5LIB>.
2) add other perl module directories needed by openssl build in PERL5LIB
3) set PERL5LIB as package environment variable

---
 meta/recipes-connectivity/openssl/openssl_3.1.0.bb | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
meta/recipes-connectivity/openssl/openssl_3.1.0.bb +5 -1
index b319c66044..613451f265 100644
@@ -54,6 +54,10 @@ CFLAGS:append:class-nativesdk = " -DOPENSSLDIR=/not/builtin -DENGINESDIR=/not/bu
 # The default is to trust upstream choices.
 DEPRECATED_CRYPTO_FLAGS ?= ""
 
+# Set package level PERL5LIB
+PERL5LIB = "${S}/external/perl/Text-Template-1.56/lib/:${S}/crypto/perlasm"
+export PERL5LIB
+
 do_configure () {
 	# When we upgrade glibc but not uninative we see obtuse failures in openssl. Make
 	# the issue really clear that perl isn't functional due to symbol mismatch issues.
@@ -138,7 +142,7 @@ do_configure () {
 	fi
 	# WARNING: do not set compiler/linker flags (-I/-D etc.) in EXTRA_OECONF, as they will fully replace the
 	# environment variables set by bitbake. Adjust the environment variables instead.
-	HASHBANGPERL="/usr/bin/env perl" PERL=perl PERL5LIB="${S}/external/perl/Text-Template-1.46/lib/" \
+	HASHBANGPERL="/usr/bin/env perl" PERL=perl \
 	perl ${S}/Configure ${EXTRA_OECONF} ${PACKAGECONFIG_CONFARGS} ${DEPRECATED_CRYPTO_FLAGS} --prefix=$useprefix --openssldir=${libdir}/ssl-3 --libdir=${libdir} $target
 	perl ${B}/configdata.pm --dump
 }
Signature · 1 line
2.25.1
#1 lore raw

Dear Sirs,

Sorry, please NOT accept this patch because I found it will break its own sstate cache.

I will found other solution for this openssl/perl co-work issue.

Quoted 98 lines · On Fri, 2023-04-21 at 03:38 +0000, [email protected] wrote:

From: Yang Xu <[email protected]>

Build openssl with shared state cache may meet problem under below conditions:
1. sstate cache generated by another user on same machine
2. inappropriate PERL5LIB setting
3. openssl build from scratch but perl using cache

When build openssl from scratch with perl using cache, it will be aborted at do_configure stage,
error message is like "Can't locate Text/Template.pm at /home/A/[build path]/[perl module path]/Text/Template.pm : Permission Denied".

The simplified environment and scenarios is:
1) User A, his home directory is /home/A, generate one sstate cache under /home/A.
2) This sstate cache moved to /home/Public, act as shared sstate cache
3) User B, his home directory is /home/B, using sstate cache in /home/Public and build yocto.
4) User B has no permission to access /home/A.

Some information about perl behavior:
1. perl will hardcode buildtime path in @INC in binary (module search directories)
2. when "use MODULE", perl will search @INC from begin to end until it found MODULE.
3. when perl search module through directories in @INC
3.1 if [directory]/MODULE.pm is not exist, search in next
directory in @INC.
3.2 if [directory]/MODULE.pm has no permission to access, perl
will ABORT.

While build openssl from from scratch with perl using cache, @INC directory order is:
1.<PERL5LIB>
2.<default module path in ${WORKDIR}/recipe-sysroot-native> 3.<hardcode module path in binary, which include /home/A/XXX/YYY> 4.<module found by FindBin, module Text-Template can be found by it>

Without appropriate PERL5LIB setting, perl can't find Text/Template.pm in
<PERL5LIB>, and it also can't find it in <default module path>.

Then perl search Text/Template.pm in <hardcode module path in binary>,
*if /home/A is not existed, perl will search in <module found by FindBin> and found Text/Template.pm finally. (OK case) *if /home/A is existed but has no permission access, perl will ABORT immediately. (NG case)

So this patch does some fixup for NG case:
1) set appropriate PERL5LIB to make perl can found Text/Tempalte.pm at highest priority folder <PERL5LIB>.
2) add other perl module directories needed by openssl build in PERL5LIB
3) set PERL5LIB as package environment variable

---
 meta/recipes-connectivity/openssl/openssl_3.1.0.bb | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
meta/recipes-connectivity/openssl/openssl_3.1.0.bb +2 -1
index b319c66044..613451f265 100644
@@ -54,6 +54,10 @@ CFLAGS:append:class-nativesdk = "
-DOPENSSLDIR=/not/builtin -DENGINESDIR=/not/bu
 # The default is to trust upstream choices.
 DEPRECATED_CRYPTO_FLAGS ?= ""
 
+# Set package level PERL5LIB
+PERL5LIB = "${S}/external/perl/Text-Template-

1.56/lib/:${S}/crypto/perlasm"

meta/recipes-connectivity/openssl/openssl_3.1.0.bb +2 -0
+export PERL5LIB
+
 do_configure () {
 	# When we upgrade glibc but not uninative we see obtuse

failures in openssl. Make

 	# the issue really clear that perl isn't functional due to
symbol mismatch issues.
meta/recipes-connectivity/openssl/openssl_3.1.0.bb +0 -0
@@ -138,7 +142,7 @@ do_configure () {
 	fi
 	# WARNING: do not set compiler/linker flags (-I/-D etc.) in

EXTRA_OECONF, as they will fully replace the

 	# environment variables set by bitbake. Adjust the environment
variables instead.
meta/recipes-connectivity/openssl/openssl_3.1.0.bb +0 -1
-	HASHBANGPERL="/usr/bin/env perl" PERL=perl

PERL5LIB="${S}/external/perl/Text-Template-1.46/lib/" \

meta/recipes-connectivity/openssl/openssl_3.1.0.bb +1 -0
+	HASHBANGPERL="/usr/bin/env perl" PERL=perl \
 	perl ${S}/Configure ${EXTRA_OECONF} ${PACKAGECONFIG_CONFARGS}

${DEPRECATED_CRYPTO_FLAGS} --prefix=$useprefix -- openssldir=${libdir}/ssl-3 --libdir=${libdir} $target
perl ${B}/configdata.pm --dump
}