Skip to contentSkip to conversation

package/linux: don't leak host timezone into linux version string

PATCH Applied Nuno Gonçalves via buildroot 4 participants 9 messages Oct 4, 2022 – Nov 14, 2022

lore
Share & tools
lore
#0 lore raw

PATCH 1/3 package/linux: don't leak host timezone into linux version string

---
 linux/linux.mk | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
linux/linux.mk +1 -1
index efdc21eff2..6b547a68ed 100644
@@ -162,7 +162,7 @@ LINUX_MAKE_ENV += \
 	KBUILD_BUILD_VERSION=1 \
 	KBUILD_BUILD_USER=buildroot \
 	KBUILD_BUILD_HOST=buildroot \
-	KBUILD_BUILD_TIMESTAMP="$(shell LC_ALL=C date -d @$(SOURCE_DATE_EPOCH))"
+	KBUILD_BUILD_TIMESTAMP="$(shell LC_ALL=C TZ='UTC' date -d @$(SOURCE_DATE_EPOCH))"
 endif
 
 # gcc-8 started warning about function aliases that have a
Signature · 6 lines
2.37.3

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
#1 lore raw

PATCH 2/3 package/sudo: explicitly disable tzdir and tmpfiles as otherwise they are based on build host directories

---
 package/sudo/sudo.mk | 2 ++
 1 file changed, 2 insertions(+)
package/sudo/sudo.mk +2 -0
index 4f9fdb4b2c..97f83d9f6f 100644
@@ -16,6 +16,8 @@ SUDO_SELINUX_MODULES = sudo
 # This is to avoid sudo's make install from chown()ing files which fails
 SUDO_INSTALL_TARGET_OPTS = INSTALL_OWNER="" DESTDIR="$(TARGET_DIR)" install
 SUDO_CONF_OPTS = \
+	--with-tzdir=no \
+	--enable-tmpfiles.d=no \
 	--without-lecture \
 	--without-sendmail \
 	--without-umask \
Signature · 6 lines
2.37.3

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
#2 lore raw

Re: [Buildroot] [PATCH 2/3] package/sudo: explicitly disable tzdir and tmpfiles as otherwise they are based on build host directories

Nuno, All,

On 2022-10-04 12:15 +0100, Nuno Gonçalves spake thusly:

Quoted 1 line

Commit title is way too long.

Also, I am not sure I understand what's going on, so it would be nice if you could respin with a better commit log.

But see below...

package/sudo/sudo.mk SUDO_SELINUX_MODULES = sudo · line 19

Quoted 13 lines
---
 package/sudo/sudo.mk | 2 ++
 1 file changed, 2 insertions(+)
package/sudo/sudo.mk +1 -0
index 4f9fdb4b2c..97f83d9f6f 100644
@@ -16,6 +16,8 @@ SUDO_SELINUX_MODULES = sudo
 # This is to avoid sudo's make install from chown()ing files which fails
 SUDO_INSTALL_TARGET_OPTS = INSTALL_OWNER="" DESTDIR="$(TARGET_DIR)" install
 SUDO_CONF_OPTS = \
+	--with-tzdir=no \

As I understand the code, this path is only used at runtime, to sanitize the TZ environment variable. So, we should be able to pass the proper path, but only if tzdata is enabled:

    --with-tzdir=$(if $(BR2_PACKAGE_TZDATA),/usr/share/zoneinfo,no)

(note that /usr/share/zoneinfo is where we install TZ data in the tzdata package).

package/sudo/sudo.mk SUDO_SELINUX_MODULES = sudo · line 20

Quoted 1 line
package/sudo/sudo.mk +1 -0
+	--enable-tmpfiles.d=no \

Ditto, I am not sure it makes sense to ubnconditionally disable support for tmpfiles, especially when systemd is actually used as the init system.

Indeed, the code defaults to looking on the host to find where they should be, and of course tht does not work in cross-compilation. But that path is used to install files, so there is probably no reason not tell sudo where to install its files:

    --enable-tmpfiles.d=$(if $(BR2_PACAKGE_SYSTEMD),/usr/lib/tmpfiles.d,no)

Could you look into this and respin a patch, please?

Regards,
Yann E. MORIN.

Quoted 10 lines
package/sudo/sudo.mk +0 -0
 	--without-lecture \
 	--without-sendmail \
 	--without-umask \
Signature · 6 lines
2.37.3

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
Signature · 10 lines
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 561 099 427 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |
'------------------------------^-------^------------------^--------------------'
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
#3 lore raw

Re: [Buildroot] [PATCH 2/3] package/sudo: explicitly disable tzdir and tmpfiles as otherwise they are based on build host directories

Hi Yann,

Quoted 15 lines · Yann E. MORIN

As I understand the code, this path is only used at runtime, to sanitize the TZ environment variable. So, we should be able to pass the proper path, but only if tzdata is enabled:

    --with-tzdir=$(if $(BR2_PACKAGE_TZDATA),/usr/share/zoneinfo,no)

(note that /usr/share/zoneinfo is where we install TZ data in the tzdata package).

Quoted 1 line

+ --enable-tmpfiles.d=no \

Ditto, I am not sure it makes sense to ubnconditionally disable support for tmpfiles, especially when systemd is actually used as the init system.

Quoted 8 lines

Indeed, the code defaults to looking on the host to find where they should be, and of course tht does not work in cross-compilation. But that path is used to install files, so there is probably no reason not tell sudo where to install its files:

    --enable-tmpfiles.d=$(if $(BR2_PACAKGE_SYSTEMD),/usr/lib/tmpfiles.d,no)

Yes, it seems it is as you said.

My approach was just "if it is broken" (as it looks for host paths only), then let's just disable it.

I am using systemd so your solution also likely fixes tmpfiles sudo support for me (which I would only have depending if my build host/container used systemd).

I will provide now the patches with your suggestions to fix it

Thanks,
Nuno

Quoted 2 lines

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot

#4 lore raw

PATCH 3/3 package/libopenssl: don't build afalgeng

In reply to Nuno Gonçalves via buildroot

Afalgeng is not cross-compiled so is useless and leaks build host info

---
 package/libopenssl/libopenssl.mk | 1 +
 1 file changed, 1 insertion(+)
package/libopenssl/libopenssl.mk +1 -0
index c7a2d65cc4..50d41a6533 100644
@@ -83,6 +83,7 @@ define LIBOPENSSL_CONFIGURE_CMDS
 			no-tests \
 			no-fuzz-libfuzzer \
 			no-fuzz-afl \
+			no-afalgeng \
 			$(if $(BR2_PACKAGE_LIBOPENSSL_ENABLE_CHACHA),,no-chacha) \
 			$(if $(BR2_PACKAGE_LIBOPENSSL_ENABLE_RC5),,no-rc5) \
 			$(if $(BR2_PACKAGE_LIBOPENSSL_ENABLE_RC2),,no-rc2) \
Signature · 6 lines
2.37.3

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
#5 lore raw

Re: [Buildroot] [PATCH 3/3] package/libopenssl: don't build afalgeng

Nuno, All,

On 2022-10-04 12:15 +0100, Nuno Gonçalves spake thusly:

Quoted 1 line

Afalgeng is not cross-compiled so is useless and leaks build host info

Looking at the configure script for libopenssl, afalgeng should already be forcibly disabled because of cross-compilation:

  1557         if ($config{CROSS_COMPILE} eq "") {
  1558             my $verstr = `uname -r`;
  1559             my ($ma, $mi1, $mi2) = split("\\.", $verstr);
  1560             ($mi2) = $mi2 =~ /(\d+)/;
  1561             my $ver = $ma*10000 + $mi1*100 + $mi2;
  1562             if ($ver < $minver) {
  1563                 disable('too-old-kernel', 'afalgeng');
  1564             } else {
  1565                 push @{$config{engdirs}}, "afalg";
  1566             }
  1567         } else {
  1568             disable('cross-compiling', 'afalgeng');
  1569         }

However, we never set CROSS_COMPILE...

So, I've extended the commit log to explain the situation better.

Quoted 1 line

Applied to master, thanks.

Regards,
Yann E. MORIN.

Quoted 23 lines
---
 package/libopenssl/libopenssl.mk | 1 +
 1 file changed, 1 insertion(+)
package/libopenssl/libopenssl.mk +1 -0
index c7a2d65cc4..50d41a6533 100644
@@ -83,6 +83,7 @@ define LIBOPENSSL_CONFIGURE_CMDS
 			no-tests \
 			no-fuzz-libfuzzer \
 			no-fuzz-afl \
+			no-afalgeng \
 			$(if $(BR2_PACKAGE_LIBOPENSSL_ENABLE_CHACHA),,no-chacha) \
 			$(if $(BR2_PACKAGE_LIBOPENSSL_ENABLE_RC5),,no-rc5) \
 			$(if $(BR2_PACKAGE_LIBOPENSSL_ENABLE_RC2),,no-rc2) \
Signature · 6 lines
2.37.3

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
Signature · 10 lines
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 561 099 427 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |
'------------------------------^-------^------------------^--------------------'
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
#6 lore raw

Re: [Buildroot] [PATCH 3/3] package/libopenssl: don't build afalgeng

In reply to Nuno Gonçalves
Quoted 4 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Nuno" == Nuno Gonçalves <[email protected]> writes:

Afalgeng is not cross-compiled so is useless and leaks build host info

Committed to 2022.08.x and 2022.02.x, thanks.

Signature · 5 lines
Bye, Peter Korsgaard
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
#7 lore raw
In reply to Nuno Gonçalves via buildroot

Nuno, All,

On 2022-10-04 12:15 +0100, Nuno Gonçalves via buildroot spake thusly:

Quoted 1 line

Applied to master, thanks.
Regards,
Yann E. MORIN.

Quoted 24 lines
---
 linux/linux.mk | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
linux/linux.mk +1 -1
index efdc21eff2..6b547a68ed 100644
@@ -162,7 +162,7 @@ LINUX_MAKE_ENV += \
 	KBUILD_BUILD_VERSION=1 \
 	KBUILD_BUILD_USER=buildroot \
 	KBUILD_BUILD_HOST=buildroot \
-	KBUILD_BUILD_TIMESTAMP="$(shell LC_ALL=C date -d @$(SOURCE_DATE_EPOCH))"
+	KBUILD_BUILD_TIMESTAMP="$(shell LC_ALL=C TZ='UTC' date -d @$(SOURCE_DATE_EPOCH))"
 endif
 
 # gcc-8 started warning about function aliases that have a
Signature · 6 lines
2.37.3

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
Signature · 10 lines
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 561 099 427 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |
'------------------------------^-------^------------------^--------------------'
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
#8 lore raw
In reply to Nuno Gonçalves via buildroot
Quoted 3 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Nuno" == Nuno Gonçalves via buildroot <[email protected]> writes:

Committed to 2022.08.x and 2022.02.x, thanks.

Signature · 5 lines
Bye, Peter Korsgaard
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot