Skip to contentSkip to conversation

host-mkpasswd: fix crash on Fedora 28 build host

PATCH New Stefan Becker 8 participants 38 messages May 2, 2018 – Jun 18, 2018 VFS

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 host-mkpasswd: fix crash on Fedora 28 build host

crypt() is an optional glibc feature. Some distros, like Fedora 28, are phasing it out to be replaced with libxcrypt [1]. Unfortunately this change is only ABI compatible, not source code compatible, i.e. the code will compile with warnings about undefined crypt(), but the resulting binary will crash.

Follow the guidance in the Fedora bug and include crypt.h when _XOPEN_CRYPT is not defined.

[1] https://bugzilla.redhat.com/show_bug.cgi?id=1566464

---
 package/mkpasswd/mkpasswd.c | 5 +++++
 1 file changed, 5 insertions(+)
package/mkpasswd/mkpasswd.c +5 -0
index 5820f32501..fd16230468 100644
@@ -44,6 +44,11 @@
 #include <sys/time.h>
 #endif
 
+/* glibc without crypt() */
+#ifndef _XOPEN_CRYPT
+#include <crypt.h>
+#endif
+
 /* Application-specific */
 #include "utils.h"
 
Signature · 1 line
2.17.0
#1 lore raw

PATCH 1/1 host-mkpasswd: fix crash on Fedora 28 build host

Stefan, All,

On 2018-05-02 12:05 +0300, Stefan Becker spake thusly:

Quoted 21 lines

crypt() is an optional glibc feature. Some distros, like Fedora 28, are phasing it out to be replaced with libxcrypt [1]. Unfortunately this change is only ABI compatible, not source code compatible, i.e. the code will compile with warnings about undefined crypt(), but the resulting binary will crash.

Follow the guidance in the Fedora bug and include crypt.h when _XOPEN_CRYPT is not defined.

[1] https://bugzilla.redhat.com/show_bug.cgi?id=1566464

---
 package/mkpasswd/mkpasswd.c | 5 +++++
 1 file changed, 5 insertions(+)
package/mkpasswd/mkpasswd.c +0 -0
index 5820f32501..fd16230468 100644

package/mkpasswd/mkpasswd.c line 50

Quoted 7 lines
package/mkpasswd/mkpasswd.c +4 -0
@@ -44,6 +44,11 @@
 #include <sys/time.h>
 #endif
 
+/* glibc without crypt() */
+#ifndef _XOPEN_CRYPT
+#include <crypt.h>
+#endif

But what if the libxcrypt package is not installed? Since crypt is only optional in POSIX, there is no guarantee that libxcrypt is even present on a system, especially now that glibc has decided to no longer provide it by default, and given that even --enable-obsolete-crypt does not even declare _XOPEN_CRYPT...

However, until we have another distribution with the new glibc version, this fix is good enough since it is at least working as-is on a stock Fedora 28.

Regards,
Yann E. MORIN.

Quoted 6 lines
package/mkpasswd/mkpasswd.c +0 -0
 /* Application-specific */
 #include "utils.h"
 
Signature · 1 line
2.17.0
Signature · 6 lines
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 223 225 172 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |
'------------------------------^-------^------------------^--------------------'
#2 lore raw

PATCH 1/1 host-mkpasswd: fix crash on Fedora 28 build host

Yann, All,

Quoted 7 lines · Yann E. MORIN

But what if the libxcrypt package is not installed? Since crypt is only optional in POSIX, there is no guarantee that libxcrypt is even present on a system, especially now that glibc has decided to no longer provide it by default, and given that even --enable-obsolete-crypt does not even declare _XOPEN_CRYPT...

If crypt() is provided by libxcrypt instead of glibc, then this should be automatically handled by package dependencies, i.e.

$ rpm -q --provides libxcrypt
...
libcrypt.so.1()(64bit)
libcrypt.so.1(GLIBC_2.2.5)(64bit)
libcrypt.so.1(OW_CRYPT_1.0)(64bit)
libcrypt.so.1(XCRYPT_2.0)(64bit)
$ rpm -q --whatrequires 'libcrypt.so.1()(64bit)' | wc -l
57
$ rpm -q --whatrequires 'libcrypt.so.1(XCRYPT_2.0)(64bit)' | wc -l
26

The first one ensures that pre-F28 binaries still continue to work on Fedora 28. The latter ones have obviously been rebuilt against libxcrypt.so already.

As for the development stuff:

$ rpm -ql libxcrypt-devel
/lib64/libcrypt.so
/usr/include/crypt.h
...
$ rpm -q --provides libxcrypt-devel
libxcrypt-devel = 4.0.0-5.fc28
libxcrypt-devel(x86-64) = 4.0.0-5.fc28
pkgconfig(libxcrypt) = 4.0.0
$ rpm -q --whatrequires 'libxcrypt-devel(x86-64)'
glibc-devel-2.27-8.fc28.x86_64

So at least on Fedora 28 this is handled in a backward compatible way, i.e. if I want to compile against glibc I also get libxcrypt-devel and therefore crypt.h.

In short: I updated 2 systems from F27 to F28 and automatically have libxcrypt and libxcrypt-devel available after the update. On the remaining F27 system I can see that libxcrypt isn't available at all, i.e. it is a new F28 feature.

Just my ?0.02, Stefan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.busybox.net/pipermail/buildroot/attachments/20180502/6b8ecc97/attachment.html>

#3 lore raw

PATCH 1/1 host-mkpasswd: fix crash on Fedora 28 build host

Quoted 27 lines · Stefan Becker

Yann, All,

On Wed, May 2, 2018 at 8:57 PM Yann E. MORIN <[email protected] <mailto:[email protected]>> wrote:

But what if the libxcrypt package is not installed? Since crypt is only optional in POSIX, there is no guarantee that libxcrypt is even present on a system, especially now that glibc has decided to no longer provide it by default, and given that even --enable-obsolete-crypt does not even declare _XOPEN_CRYPT...

?
If crypt() is provided by libxcrypt instead of glibc, then this should be automatically handled by package dependencies, i.e.

$ rpm -q --provides libxcrypt
...
libcrypt.so.1()(64bit)
libcrypt.so.1(GLIBC_2.2.5)(64bit)
libcrypt.so.1(OW_CRYPT_1.0)(64bit)
libcrypt.so.1(XCRYPT_2.0)(64bit)
$ rpm -q --whatrequires 'libcrypt.so.1()(64bit)' | wc -l
57
$ rpm -q --whatrequires 'libcrypt.so.1(XCRYPT_2.0)(64bit)' | wc -l
26
Quoted 8 lines

The first one ensures that pre-F28 binaries still continue to work on Fedora 28. The latter ones have obviously been rebuilt against libxcrypt.so already.

As for the development stuff:

$ rpm -ql libxcrypt-devel
/lib64/libcrypt.so
/usr/include/crypt.h

And in pre-F28 this header will be provided by glibc-devel, right?

But so in practice we can assume that crypt.h is always present, so why not
include it unconditionally?

BTW, how is this solved in upstream whois?

Regards,
Arnout

Quoted 23 lines

...

$ rpm -q --provides libxcrypt-devel
libxcrypt-devel = 4.0.0-5.fc28
libxcrypt-devel(x86-64) = 4.0.0-5.fc28
pkgconfig(libxcrypt) = 4.0.0
$ rpm -q --whatrequires 'libxcrypt-devel(x86-64)'
glibc-devel-2.27-8.fc28.x86_64

So at least on Fedora 28 this is handled in a backward compatible way, i.e. if I want to compile against glibc I also get libxcrypt-devel and therefore crypt.h.

In short: I updated 2 systems from F27 to F28 and automatically have libxcrypt and libxcrypt-devel available after the update. On the remaining F27 system I can see that libxcrypt isn't available at all, i.e. it is a new F28 feature.

Just my ?0.02, Stefan

_______________________________________________
buildroot mailing list
buildroot at busybox.net
http://lists.busybox.net/mailman/listinfo/buildroot

Signature · 6 lines
Arnout Vandecappelle                          arnout at mind be
Senior Embedded Software Architect            +32-16-286500
Essensium/Mind                                http://www.mind.be
G.Geenslaan 9, 3001 Leuven, Belgium           BE 872 984 063 RPR Leuven
LinkedIn profile: http://www.linkedin.com/in/arnoutvandecappelle
GPG fingerprint:  7493 020B C7E3 8618 8DEC 222C 82EB F404 F9AC 0DDF
#4 lore raw

PATCH 1/1 host-mkpasswd: fix crash on Fedora 28 build host

Arnout, All,

On 2018-05-02 22:38 +0200, Arnout Vandecappelle spake thusly:

Quoted 11 lines · Stefan Becker
Quoted 10 lines

On Wed, May 2, 2018 at 8:57 PM Yann E. MORIN <[email protected] <mailto:[email protected]>> wrote:
But what if the libxcrypt package is not installed? Since crypt is only optional in POSIX, there is no guarantee that libxcrypt is even present on a system, especially now that glibc has decided to no longer provide it by default, and given that even --enable-obsolete-crypt does not even declare _XOPEN_CRYPT...
?
If crypt() is provided by libxcrypt instead of glibc, then this should be automatically handled by package dependencies, i.e.

[--SNIP--]

Quoted 1 line

And in pre-F28 this header will be provided by glibc-devel, right?

At least it is so in a debian-based distro, yes.

Quoted 4 lines

But so in practice we can assume that crypt.h is always present, so why not
include it unconditionally?

BTW, how is this solved in upstream whois?

Sufficiently good that we may want to update?

When we included mkpasswd, we did not have the whois package in Buildroot. Now we have it, but there is no host variant.

Maybe it is time to add host-whois, that installs mkpasswd, and then ditch our bundled copy of mkpasswd?

rc1 is really close now (Peter said next weekend), so it is a bit late to switch, maybe... :-/

In the meantime, as I already said, this patch is good-enough to go as-is for now.

If we get a better solution after the release, we can backport it if that makes sense. But until then...

Regards,
Yann E. MORIN.

Quoted 31 lines
Quoted 23 lines

...

$ rpm -q --provides libxcrypt-devel
libxcrypt-devel = 4.0.0-5.fc28
libxcrypt-devel(x86-64) = 4.0.0-5.fc28
pkgconfig(libxcrypt) = 4.0.0
$ rpm -q --whatrequires 'libxcrypt-devel(x86-64)'
glibc-devel-2.27-8.fc28.x86_64

So at least on Fedora 28 this is handled in a backward compatible way, i.e. if I want to compile against glibc I also get libxcrypt-devel and therefore crypt.h.

In short: I updated 2 systems from F27 to F28 and automatically have libxcrypt and libxcrypt-devel available after the update. On the remaining F27 system I can see that libxcrypt isn't available at all, i.e. it is a new F28 feature.

Just my ?0.02, Stefan

_______________________________________________
buildroot mailing list
buildroot at busybox.net
http://lists.busybox.net/mailman/listinfo/buildroot

Signature · 6 lines
Arnout Vandecappelle                          arnout at mind be
Senior Embedded Software Architect            +32-16-286500
Essensium/Mind                                http://www.mind.be
G.Geenslaan 9, 3001 Leuven, Belgium           BE 872 984 063 RPR Leuven
LinkedIn profile: http://www.linkedin.com/in/arnoutvandecappelle
GPG fingerprint:  7493 020B C7E3 8618 8DEC 222C 82EB F404 F9AC 0DDF
Signature · 6 lines
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 223 225 172 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |
'------------------------------^-------^------------------^--------------------'
#5 lore raw

PATCH 1/1 host-mkpasswd: fix crash on Fedora 28 build host

In reply to Arnout Vandecappelle

Arnout, All,

Quoted 5 lines · Arnout Vandecappelle

And in pre-F28 this header will be provided by glibc-devel, right?

But so in practice we can assume that crypt.h is always present, so why not include it unconditionally?

crypt.h and -lcrypt seem to be ancient glibc artefacts. E.g. RedHat 7.x glibc-2.2.5 (
http://rpm.pbone.net/index.php3/stat/4/idpl/38881780/dir/redhat_7.x/com/glibc-devel-2.2.5-44.i386.rpm.html
).

For the Fedora 28 change see also:

*
https://fedoraproject.org/wiki/Changes/Replace_glibc_libcrypt_with_libxcrypt
*
https://src.fedoraproject.org/rpms/glibc/c/2687b3c78b7b05ca9cc568e40464fb7909e9ec6d
* https://sourceware.org/ml/libc-alpha/2017-08/msg01257.html

So at least on Linux & glibc the guidance

   #define _XOPEN_SOURCE

   #include <stdlib.h>
   #include <stdio.h>
   #include <unistd.h>

   #ifndef _XOPEN_CRYPT
   #include <crypt.h>
   #endif

   int main(int argc, char **argv)
   {
     (void)argc;
     (void)argv;
     printf("%s\n", crypt("passwd", "salt"));
     return(0);
  }

should be always correct.

Fedora 28 (glibc 2.27 + libcrypt deprecation patch):

$ gcc -Wall -Wextra -Werror -dD -E dummy.c | fgrep -e _CRYPT -e crypt.h -e
'*crypt '
    _SC_XOPEN_CRYPT,
#define _SC_XOPEN_CRYPT _SC_XOPEN_CRYPT
# 1 "/usr/include/crypt.h" 1 3 4
# 20 "/usr/include/crypt.h" 3 4
#define _CRYPT_H 1
# 63 "/usr/include/crypt.h" 3 4
extern char *crypt (const char *__phrase, const char *__setting)
...

Fedora 27 (glibc 2.26):

$ gcc -Wall -Wextra -Werror -dD -E dummy.c | fgrep -e _CRYPT -e crypt.h -e
'*crypt '
#define _XOPEN_CRYPT 1
    _SC_XOPEN_CRYPT,
#define _SC_XOPEN_CRYPT _SC_XOPEN_CRYPT
extern char *crypt (const char *__key, const char *__salt)

Ubuntu 14.04 (glibc 2.19):

$ gcc -Wall -Wextra -Werror -dD -E dummy.c | fgrep -e _CRYPT -e crypt.h -e
'*crypt '
#define _XOPEN_CRYPT 1
    _SC_XOPEN_CRYPT,
#define _SC_XOPEN_CRYPT _SC_XOPEN_CRYPT
extern char *crypt (const char *__key, const char *__salt)

Buildroot target @master (glibc 2.27):

$ output/host/bin/arm-buildroot-linux-gnueabihf-gcc -Wall -Wextra -Werror
-dD -E dummy.c | fgrep -e _CRYPT -e crypt.h -e '*crypt '
#undef __ARM_FEATURE_CRYPTO
#define _XOPEN_CRYPT 1
    _SC_XOPEN_CRYPT,
#define _SC_XOPEN_CRYPT _SC_XOPEN_CRYPT
extern char *crypt (const char *__key, const char *__salt)

Regards, Stefan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.busybox.net/pipermail/buildroot/attachments/20180503/a8c28eb0/attachment.html>

#6 lore raw

PATCH 1/1 host-mkpasswd: fix crash on Fedora 28 build host

In reply to Stefan Becker

Stefan, All,

On 2018-05-02 18:23 +0000, Stefan Becker spake thusly:

Quoted 4 lines · Yann E. MORIN

But what if the libxcrypt package is not installed? [...]
If crypt() is provided by libxcrypt instead of glibc, then this should be automatically handled by package dependencies, i.e.

[--SNIP--]

Quoted 3 lines

So at least on Fedora 28 this is handled in a backward compatible way, i.e. if I want to compile against glibc I also get libxcrypt-devel and therefore crypt.h.

OK, thanks for the explanations on how that's handled in Fedora. :-)

Regards,
Yann E. MORIN.

Signature · 6 lines
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 223 225 172 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |
'------------------------------^-------^------------------^--------------------'
#7 lore raw

PATCH 1/1 host-mkpasswd: fix crash on Fedora 28 build host

In reply to Stefan Becker

Hello,

Quoted 9 lines · Stefan Becker

crypt() is an optional glibc feature. Some distros, like Fedora 28, are phasing it out to be replaced with libxcrypt [1]. Unfortunately this change is only ABI compatible, not source code compatible, i.e. the code will compile with warnings about undefined crypt(), but the resulting binary will crash.

Follow the guidance in the Fedora bug and include crypt.h when _XOPEN_CRYPT is not defined.

Quoted 6 lines

[1] https://bugzilla.redhat.com/show_bug.cgi?id=1566464

---
 package/mkpasswd/mkpasswd.c | 5 +++++
 1 file changed, 5 insertions(+)

Applied to master, thanks.

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Bootlin (formerly Free Electrons)
Embedded Linux and Kernel engineering
https://bootlin.com
#8 lore raw

PATCH 1/1 host-mkpasswd: fix crash on Fedora 28 build host

Stefan, All,

On 2018-05-03 21:56 +0200, Thomas Petazzoni spake thusly:

Quoted 10 lines · Stefan Becker
Quoted 9 lines

crypt() is an optional glibc feature. Some distros, like Fedora 28, are phasing it out to be replaced with libxcrypt [1]. Unfortunately this change is only ABI compatible, not source code compatible, i.e. the code will compile with warnings about undefined crypt(), but the resulting binary will crash.

Follow the guidance in the Fedora bug and include crypt.h when _XOPEN_CRYPT is not defined.

Quoted 8 lines
Quoted 6 lines

[1] https://bugzilla.redhat.com/show_bug.cgi?id=1566464

---
 package/mkpasswd/mkpasswd.c | 5 +++++
 1 file changed, 5 insertions(+)

Applied to master, thanks.

Although in the long run, I believe it might be preferrable that we ditch our own bundled version, and switch to making our whois package a hot pacakge, and use that as the provider for mkpasswd.

Stefan, would you want to do that? ;-)

Regards,
Yann E. MORIN.

Signature · 6 lines
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 223 225 172 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |
'------------------------------^-------^------------------^--------------------'
#9 lore raw

PATCH 1/1 host-mkpasswd: fix crash on Fedora 28 build host

Yann, All,

Quoted 5 lines · Yann E. MORIN

ditch our own bundled version, and switch to making our whois package a hot pacakge, and use that as the provider for mkpasswd.

Stefan, would you want to do that? ;-)

I'll give it a go, but can only work on this in a few weeks when I get some free cycles...

Regards, Stefan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.busybox.net/pipermail/buildroot/attachments/20180506/25416ee7/attachment.html>

#10 lore raw

PATCH 1/1 host-mkpasswd: fix crash on Fedora 28 build host

Hello,

Quoted 7 lines
Quoted 3 lines · Yann E. MORIN

ditch our own bundled version, and switch to making our whois package a hot pacakge, and use that as the provider for mkpasswd.

Quoted 9 lines
Quoted 2 lines

Stefan, would you want to do that? ;-)

I'll give it a go, but can only work on this in a few weeks when I get some free cycles...

Regards, Stefan

We're using mkpasswd specifically for a single task (skeleton-init-common root password generation). I'm already tackling building this on Alpine (musl environment) and facing
multiple issues: had to use -lintl for linking (that libintl musl/glibc can of worms) and of course, it only makes md5 hashes since all SHA functionalities are disabled on non-glibc systems via its header.

Can we just use a couple of python code using crypt.crypt(...), since python is already a requirement. One less package to maintain is a good news (buildroots already brimming with a mind boggling number of packages).

By the way, my first post here, I hope I'm not coming off as a nagging pedestrian just adding noise. I highly appreciate the effort you guys are putting into this.
Thank you.

(My apologies for double posting - it seems, at first, I didn't reply to
all)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.busybox.net/pipermail/buildroot/attachments/20180507/f55c7698/attachment.html>

#11 lore raw

PATCH 1/1 host-mkpasswd: fix crash on Fedora 28 build host

[Added Matt as

Quoted 13 lines · M ZV

Hello,?
?

On Thu, May 3, 2018 at 11:04 PM Yann E. MORIN <[email protected] <mailto:[email protected]>> wrote:

ditch our own bundled version, and switch to making our whois package a hot pacakge, and use that as the provider for mkpasswd.

Stefan, would you want to do that? ;-)

Quoted 8 lines

I'll give it a go, but can only work on this in a few weeks when I get some free cycles...

Regards, Stefan

We're using?mkpasswd specifically for a single task (skeleton-init-common root password generation). I'm already tackling building this on Alpine (musl

Yes, Alpine is a pain :-)

Quoted 8 lines

environment) and facing?
multiple issues: had to use -lintl for linking (that libintl musl/glibc can of worms) and of course, it only makes md5 hashes since all SHA functionalities are disabled on non-glibc systems via its header.

Can we just use a couple of python code using?crypt.crypt(...), since python is already a requirement. One less package to maintain is a good news (buildroots already brimming with a mind boggling?number of packages).

Great idea! Indeed, the python script would be rather trivial - mostly
generating salt.

Probably, when doing that, more of the mkusers script could migrate to python.
But to start with it could be a python "oneliner":

	dd if=/dev/urandom bs=1 count=12 | python -c "
			import sys, crypt, base64
			salt = sys.stdin.read()
			b64salt = base64.b64encode(salt, './')
			b64salt = b64salt.strip('=')
			print(crypt.crypt('${password}',
				'${PASSWD_METHOD}' + b64salt))"

Normally, I'd say I want to avoid calling python in the normal build path
(because of python overhead, because it's a hard-to-reproduce environment, because of python2/3 uncertainty, ...). However, that ship has sailed with the introduction of check-uniq-files.

Would you like to prepare a patch introducing the python-based approach? It
should be two patches: the first one introducing the python script in mkusers, the second one removing the mkpasswd package.

Regards,
Arnout

Quoted 14 lines

By the way, my first post here, I hope I'm not coming off as a nagging pedestrian just adding noise. I highly appreciate the effort you guys are putting into this.
Thank you.

(My apologies for double posting - it seems, at first, I didn't reply to all)

_______________________________________________
buildroot mailing list
buildroot at busybox.net
http://lists.busybox.net/mailman/listinfo/buildroot

Signature · 6 lines
Arnout Vandecappelle                          arnout at mind be
Senior Embedded Software Architect            +32-16-286500
Essensium/Mind                                http://www.mind.be
G.Geenslaan 9, 3001 Leuven, Belgium           BE 872 984 063 RPR Leuven
LinkedIn profile: http://www.linkedin.com/in/arnoutvandecappelle
GPG fingerprint:  7493 020B C7E3 8618 8DEC 222C 82EB F404 F9AC 0DDF
#12 lore raw

PATCH 1/1 host-mkpasswd: fix crash on Fedora 28 build host

M ZV, All,

On 2018-05-08 23:37 +0200, Arnout Vandecappelle spake thusly:

Quoted 5 lines · M ZV
Quoted 3 lines

Hello,?
We're using?mkpasswd specifically for a single task (skeleton-init-common root password generation). I'm already tackling building this on Alpine (musl

Yes, Alpine is a pain :-)

Meh, yes... :-(

However, all the tricks required to actually build with musl are known. Except we only have code to handle that for target packages.

For host pacakges, it is more tricky to do, though...

Quoted 11 lines
Quoted 8 lines

environment) and facing?
multiple issues: had to use -lintl for linking (that libintl musl/glibc can of worms) and of course, it only makes md5 hashes since all SHA functionalities are disabled on non-glibc systems via its header.

Can we just use a couple of python code using?crypt.crypt(...), since python is already a requirement. One less package to maintain is a good news (buildroots already brimming with a mind boggling?number of packages).

Great idea! Indeed, the python script would be rather trivial - mostly
generating salt.

I don't like that we reinvent such tools... Especially when dealing with security-related tools...

Quoted 4 lines

Probably, when doing that, more of the mkusers script could migrate to python.
But to start with it could be a python "oneliner":

dd if=/dev/urandom bs=1 count=12 | python -c "

This is not optimal. Better to do a single read instead of 12: bs=12 count=1

Quoted 2 lines

import sys, crypt, base64
salt = sys.stdin.read()

Why such convoluted code to read 12 bytes of random data? Why not use Python's builtins for that?

https://docs.python.org/3/library/secrets.html

import secrets
blob = secrets.token_bytes(12)

Quoted 12 lines
			b64salt = base64.b64encode(salt, './')
			b64salt = b64salt.strip('=')
			print(crypt.crypt('${password}',
				'${PASSWD_METHOD}' + b64salt))"

Normally, I'd say I want to avoid calling python in the normal build path
(because of python overhead, because it's a hard-to-reproduce environment, because of python2/3 uncertainty, ...). However, that ship has sailed with the introduction of check-uniq-files.

Quoted 3 lines

Would you like to prepare a patch introducing the python-based approach? It
should be two patches: the first one introducing the python script in mkusers, the second one removing the mkpasswd package.

Sorry, I am not too convinced that writing our own tool is good...

Regards,
Yann E. MORIN.

Quoted 26 lines

Regards,
Arnout

Quoted 14 lines

By the way, my first post here, I hope I'm not coming off as a nagging pedestrian just adding noise. I highly appreciate the effort you guys are putting into this.
Thank you.

(My apologies for double posting - it seems, at first, I didn't reply to all)

_______________________________________________
buildroot mailing list
buildroot at busybox.net
http://lists.busybox.net/mailman/listinfo/buildroot

Signature · 6 lines
Arnout Vandecappelle                          arnout at mind be
Senior Embedded Software Architect            +32-16-286500
Essensium/Mind                                http://www.mind.be
G.Geenslaan 9, 3001 Leuven, Belgium           BE 872 984 063 RPR Leuven
LinkedIn profile: http://www.linkedin.com/in/arnoutvandecappelle
GPG fingerprint:  7493 020B C7E3 8618 8DEC 222C 82EB F404 F9AC 0DDF
Signature · 6 lines
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 223 225 172 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |
'------------------------------^-------^------------------^--------------------'
#13 lore raw

PATCH 1/1 host-mkpasswd: fix crash on Fedora 28 build host

Hello,
Arnout, Yann, All,

I just noticed there are actually two places host-mkpasswd is being used:
root account (skeleton-init-common.mk) and users table. I think, if we're going to replace mkpasswd with a script, this all should go through one single point somehow (something like support/scripts/crypt_wrapper).

Quoted 11 lines · Yann E. MORIN

I don't like that we reinvent such tools... Especially when dealing with security-related tools...

Quoted 1 line

dd if=/dev/urandom bs=1 count=12 | python -c "

This is not optimal. Better to do a single read instead of 12: bs=12 count=1

Quoted 2 lines

import sys, crypt, base64
salt = sys.stdin.read()

Quoted 8 lines

Why such convoluted code to read 12 bytes of random data? Why not use Python's builtins for that?

https://docs.python.org/3/library/secrets.html

import secrets
blob = secrets.token_bytes(12)

I actually like Arnout way of using /dev/urandom. The more we make use of system resources (and less responsibility for python) the better.

Quoted 5 lines

Sorry, I am not too convinced that writing our own tool is good...

Regards,
Yann E. MORIN.

To be honest, like all of you, I'm also very uncomfortable replacing mkpasswd with
a python solution. There're three reasons that made me convinced this is the right thing to do.

First, it's cryptographically sound. We're not going to roll our own hash algorithm.
It?s simply making a LIBC crypt(3) function call. Like mkpasswd, this is just a system/libc call wrapper.

Second, host-mkpasswd (which is carved out of another package to be a lightweight
buildroot?s own bundle) apparently needs periodic attention (as can be seen in the
mailing list archive throughout the years). In my case it actually built the shadow
with empty password for the root (SHA functions are ignored for musl) without throwing
any errors. I know these blatant failures are easily caught by the
developer before any kind
of release but they all reveal how rapidly this package is going through bit-rot.

And finally, this (python or perl script) seems to be the only cross-distribution solution
that actually works without adding hundreds of lines of code (or a full-blown whois package)
to the build infrastructure with their own specific libc compatibility patches and version bumps.
And it works on Alpine!

I personally settle for a code that is aesthetically wanting or philosophically unschooled
if the alternative is to take more of the maintainers? attention and time. An absolute rare commodity we can ill afford.

Thank you.
Mike Z. Vand

#14 lore raw

PATCH 1/1 host-mkpasswd: fix crash on Fedora 28 build host

In reply to Yann E. MORIN
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Yann" == Yann E MORIN <[email protected]> writes:

Hi,

Quoted 5 lines
Quoted 3 lines

Would you like to prepare a patch introducing the python-based approach? It should be two patches: the first one introducing the python script in mkusers, the second one removing the mkpasswd package.

Sorry, I am not too convinced that writing our own tool is good...

Me neither. Another alternative is to build host-busybox and use the mkpasswd applet with the built in crypt routines (ENABLE_USE_BB_CRYPT).

Signature · 1 line
Bye, Peter Korsgaard
#15 lore raw

PATCH 1/1 host-mkpasswd: fix crash on Fedora 28 build host

Peter, All,

On 2018-05-29 09:37 +0200, Peter Korsgaard spake thusly:

Quoted 9 lines
Quoted 6 lines
Quoted 4 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Yann" == Yann E MORIN <[email protected]> writes:

Would you like to prepare a patch introducing the python-based approach? It should be two patches: the first one introducing the python script in mkusers, the second one removing the mkpasswd package.

Sorry, I am not too convinced that writing our own tool is good...

Me neither. Another alternative is to build host-busybox and use the mkpasswd applet with the built in crypt routines (ENABLE_USE_BB_CRYPT).

Yeah, I like that idea more. Plus, we can get known-reproducible behaviour for other applets, should we need to add that.

Regards,
Yann E. MORIN.

Signature · 6 lines
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 223 225 172 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |
'------------------------------^-------^------------------^--------------------'
#16 lore raw

PATCH 1/1 host-mkpasswd: fix crash on Fedora 28 build host

Quoted 9 lines · Yann E. MORIN

Peter, All,

On 2018-05-29 09:37 +0200, Peter Korsgaard spake thusly:

Quoted 6 lines
Quoted 6 lines
Quoted 4 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Yann" == Yann E MORIN <[email protected]> writes:

Would you like to prepare a patch introducing the python-based approach? It should be two patches: the first one introducing the python script in mkusers, the second one removing the mkpasswd package.

Sorry, I am not too convinced that writing our own tool is good...

If I understand correctly, you don't want to write our own tool because "don't
roll your own security"...

Quoted 6 lines
Quoted 3 lines

Me neither. Another alternative is to build host-busybox and use the mkpasswd applet with the built in crypt routines (ENABLE_USE_BB_CRYPT).

Yeah, I like that idea more. Plus, we can get known-reproducible behaviour for other applets, should we need to add that.

... and you'd rather replace it with the busybox implementation that uses a
homegrown hash of getpid() + monotonic_us() as the salt?

The whois stuff at least uses /dev/urandom to generate the salt...

Or maybe that was your point, eliminate randomness to get known-reproducible
behaviour?

Regards,
Arnout

Signature · 6 lines
Arnout Vandecappelle                          arnout at mind be
Senior Embedded Software Architect            +32-16-286500
Essensium/Mind                                http://www.mind.be
G.Geenslaan 9, 3001 Leuven, Belgium           BE 872 984 063 RPR Leuven
LinkedIn profile: http://www.linkedin.com/in/arnoutvandecappelle
GPG fingerprint:  7493 020B C7E3 8618 8DEC 222C 82EB F404 F9AC 0DDF
#17 lore raw

PATCH 1/1 replace host-mkpasswd

As discussed in the mail thread add a host variant of busybox that provides the "mkpasswd" tool for the build.

Rough first draft that probably requires some polishing.

#18 lore raw

PATCH 1/2 package/busybox: add host variant

Build stripped down version of busybox for the build host to provide "mkpasswd" for the build.

This is a replacement for host-mkpasswd.

---
 fs/common.mk                                  |  2 +-
 package/Config.in.host                        |  2 +-
 package/busybox/Config.in.host                |  2 ++
 package/busybox/busybox.mk                    | 28 +++++++++++++++++++
 .../skeleton-init-common.mk                   |  2 +-
 5 files changed, 33 insertions(+), 3 deletions(-)
 create mode 100644 package/busybox/Config.in.host
fs/common.mk +1 -1
index 9baf367729..42d5dff569 100644
@@ -63,7 +63,7 @@ ROOTFS_COMMON_TARGET_DIR = $(FS_DIR)/target
 
 ROOTFS_COMMON_DEPENDENCIES = \
 	host-fakeroot host-makedevs \
-	$(if $(PACKAGES_USERS)$(ROOTFS_USERS_TABLES),host-mkpasswd)
+	$(if $(PACKAGES_USERS)$(ROOTFS_USERS_TABLES),host-busybox)
 
 $(ROOTFS_COMMON_TAR): ROOTFS=COMMON
 $(ROOTFS_COMMON_TAR): FAKEROOT_SCRIPT=$(FS_DIR)/fakeroot.fs
package/Config.in.host +1 -1
index 38543e7390..c524333671 100644
@@ -2,6 +2,7 @@ menu "Host utilities"
 
 	source "package/aespipe/Config.in.host"
 	source "package/android-tools/Config.in.host"
+	source "package/busybox/Config.in.host"
 	source "package/cargo/Config.in.host"
 	source "package/cbootimage/Config.in.host"
 	source "package/checkpolicy/Config.in.host"
@@ -31,7 +32,6 @@ menu "Host utilities"
 	source "package/lpc3250loader/Config.in.host"
 	source "package/lttng-babeltrace/Config.in.host"
 	source "package/mfgtools/Config.in.host"
-	source "package/mkpasswd/Config.in.host"
 	source "package/mtd/Config.in.host"
 	source "package/mtools/Config.in.host"
 	source "package/mxsldr/Config.in.host"
package/busybox/Config.in.host new file +2 -0
new file mode 100644
index 0000000000..93774bdf60
@@ -0,0 +1,2 @@
+config BR2_PACKAGE_HOST_MKPASSWD
+	bool "host mkpasswd"
package/busybox/busybox.mk +28 -0
index 75fe7e137b..aa89f1cc33 100644
@@ -302,4 +302,32 @@ $(error No BusyBox configuration file specified, check your BR2_PACKAGE_BUSYBOX_
 endif
 endif
 
+#
+# Host version of busybox to provide "mkpasswd" for the build
+#
+HOST_BUSYBOX_BUILD_CONFIG = $(HOST_BUSYBOX_DIR)/.config
+define HOST_BUSYBOX_CONFIGURE_CMDS
+	$(HOST_MAKE_ENV) $(MAKE) -C $(@D) allnoconfig
+	$(call KCONFIG_ENABLE_OPT,CONFIG_MKPASSWD,$(HOST_BUSYBOX_BUILD_CONFIG))
+	$(call KCONFIG_ENABLE_OPT,CONFIG_USE_BB_CRYPT,$(HOST_BUSYBOX_BUILD_CONFIG))
+	$(call KCONFIG_ENABLE_OPT,CONFIG_USE_BR_CRYPT_SHA,$(HOST_BUSYBOX_BUILD_CONFIG))
+	$(call KCONFIG_ENABLE_OPT,CONFIG_BUILD_LIBBUSYBOX,$(HOST_BUSYBOX_BUILD_CONFIG))
+	$(call KCONFIG_ENABLE_OPT,CONFIG_FEATURE_INDIVIDUAL,$(HOST_BUSYBOX_BUILD_CONFIG))
+endef
+
+define HOST_BUSYBOX_BUILD_CMDS
+	$(HOST_MAKE_ENV) $(MAKE) -C $(@D) busybox
+endef
+
+define HOST_BUSYBOX_INSTALL_CMDS
+	$(HOST_MAKE_ENV) $(MAKE) \
+		CONFIG_PREFIX="$(HOST_DIR)" \
+		EXTRA_LDFLAGS="-Wl,-rpath,$(HOST_DIR)/lib" \
+		-C $(@D) install
+	rm -f $(HOST_DIR)/bin/sh $(HOST_DIR)/bin/busybox
+endef
+
 $(eval $(kconfig-package))
+$(eval $(host-generic-package))
+
+MKPASSWD = $(HOST_DIR)/bin/mkpasswd
package/skeleton-init-common/skeleton-init-common.mk +1 -1
index e8a0522052..99c87e3861 100644
@@ -63,7 +63,7 @@ ifneq ($(filter $$1$$% $$5$$% $$6$$%,$(SKELETON_INIT_COMMON_ROOT_PASSWD)),)
 SKELETON_INIT_COMMON_ROOT_PASSWORD = '$(SKELETON_INIT_COMMON_ROOT_PASSWD)'
 else ifneq ($(SKELETON_INIT_COMMON_ROOT_PASSWD),)
 # This variable will only be evaluated in the finalize stage, so we can
-# be sure that host-mkpasswd will have already been built by that time.
+# be sure that host-busybox will have already been built by that time.
 SKELETON_INIT_COMMON_ROOT_PASSWORD = "`$(MKPASSWD) -m "$(SKELETON_INIT_COMMON_PASSWD_METHOD)" "$(SKELETON_INIT_COMMON_ROOT_PASSWD)"`"
 endif
 else # !BR2_TARGET_ENABLE_ROOT_LOGIN
Signature · 1 line
2.17.0
#19 lore raw

PATCH 1/2 package/busybox: add host variant

Hello,

Quoted 5 lines · Stefan Becker

Build stripped down version of busybox for the build host to provide "mkpasswd" for the build.

This is a replacement for host-mkpasswd.

Quoted 8 lines
---
 fs/common.mk                                  |  2 +-
 package/Config.in.host                        |  2 +-
 package/busybox/Config.in.host                |  2 ++
 package/busybox/busybox.mk                    | 28 +++++++++++++++++++
 .../skeleton-init-common.mk                   |  2 +-
 5 files changed, 33 insertions(+), 3 deletions(-)

The addition of host-busybox should be split in a separate patch from the patch changing to use host-busybox instead of host-mkpasswd.

Also, the commit log should explain the rationale for switching from host-mkpasswd to host-busybox. I know it has been discussed on the list, but a commit log is much easier to find in the Git history than an e-mail discussion on the mailing list. So a summary of the motivations for the change would be nice.

Thanks!

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Bootlin (formerly Free Electrons)
Embedded Linux and Kernel engineering
https://bootlin.com
#20 lore raw

PATCH 2/2 package/mkpasswd: remove obsolete package

In reply to Stefan Becker

mkpasswd for the host is now provided by busybox.

---
 package/mkpasswd/Config.in.host |   2 -
 package/mkpasswd/config.h       |  95 -------
 package/mkpasswd/mkpasswd.c     | 461 --------------------------------
 package/mkpasswd/mkpasswd.mk    |  24 --
 package/mkpasswd/utils.c        |  96 -------
 package/mkpasswd/utils.h        |  56 ----
 6 files changed, 734 deletions(-)
 delete mode 100644 package/mkpasswd/Config.in.host
 delete mode 100644 package/mkpasswd/config.h
 delete mode 100644 package/mkpasswd/mkpasswd.c
 delete mode 100644 package/mkpasswd/mkpasswd.mk
 delete mode 100644 package/mkpasswd/utils.c
 delete mode 100644 package/mkpasswd/utils.h
package/mkpasswd/Config.in.host deleted +0 -2
deleted file mode 100644
index 93774bdf60..0000000000
@@ -1,2 +0,0 @@
-config BR2_PACKAGE_HOST_MKPASSWD
-	bool "host mkpasswd"
package/mkpasswd/config.h deleted +0 -95

95 lines not on this page · raw message

package/mkpasswd/mkpasswd.c deleted +0 -461

461 lines not on this page · raw message

package/mkpasswd/mkpasswd.mk deleted +0 -24
deleted file mode 100644
index b013390572..0000000000
@@ -1,24 +0,0 @@
-################################################################################
-#
-# mkpasswd
-#
-################################################################################
-
-# source included in buildroot, taken from
-# https://github.com/rfc1036/whois/blob/master/
-# at revision 5a0f08500fa51608b6d3b73ee338be38c692eadb
-HOST_MKPASSWD_LICENSE = GPL-2.0+
-
-define HOST_MKPASSWD_BUILD_CMDS
-	$(HOSTCC) $(HOST_CFLAGS) $(HOST_LDFLAGS) \
-		package/mkpasswd/mkpasswd.c package/mkpasswd/utils.c \
-		-o $(@D)/mkpasswd -lcrypt
-endef
-
-define HOST_MKPASSWD_INSTALL_CMDS
-	$(INSTALL) -D -m 755 $(@D)/mkpasswd $(HOST_DIR)/bin/mkpasswd
-endef
-
-$(eval $(host-generic-package))
-
-MKPASSWD = $(HOST_DIR)/bin/mkpasswd
package/mkpasswd/utils.c deleted +0 -96

96 lines not on this page · raw message

package/mkpasswd/utils.h deleted +0 -56

56 lines not on this page · raw message

Signature · 1 line
2.17.0
#21 lore raw

PATCH v2 1/1 replace host-mkpasswd

In reply to Stefan Becker

As discussed in the mail thread add a host variant of busybox that provides the "mkpasswd" tool for the build.

v2: split into 3 separate patches + add some reasoning to commit

#22 lore raw

PATCH v2 1/3 package/busybox: add host variant

Build stripped down version of busybox for the build host to provide "mkpasswd" for the build.

This is a replacement for host-mkpasswd.

---
 package/busybox/Config.in.host |  2 ++
 package/busybox/busybox.mk     | 28 ++++++++++++++++++++++++++++
 2 files changed, 30 insertions(+)
 create mode 100644 package/busybox/Config.in.host
package/busybox/Config.in.host new file +2 -0
new file mode 100644
index 0000000000..93774bdf60
@@ -0,0 +1,2 @@
+config BR2_PACKAGE_HOST_MKPASSWD
+	bool "host mkpasswd"
package/busybox/busybox.mk +28 -0
index 75fe7e137b..aa89f1cc33 100644
@@ -302,4 +302,32 @@ $(error No BusyBox configuration file specified, check your BR2_PACKAGE_BUSYBOX_
 endif
 endif
 
+#
+# Host version of busybox to provide "mkpasswd" for the build
+#
+HOST_BUSYBOX_BUILD_CONFIG = $(HOST_BUSYBOX_DIR)/.config
+define HOST_BUSYBOX_CONFIGURE_CMDS
+	$(HOST_MAKE_ENV) $(MAKE) -C $(@D) allnoconfig
+	$(call KCONFIG_ENABLE_OPT,CONFIG_MKPASSWD,$(HOST_BUSYBOX_BUILD_CONFIG))
+	$(call KCONFIG_ENABLE_OPT,CONFIG_USE_BB_CRYPT,$(HOST_BUSYBOX_BUILD_CONFIG))
+	$(call KCONFIG_ENABLE_OPT,CONFIG_USE_BR_CRYPT_SHA,$(HOST_BUSYBOX_BUILD_CONFIG))
+	$(call KCONFIG_ENABLE_OPT,CONFIG_BUILD_LIBBUSYBOX,$(HOST_BUSYBOX_BUILD_CONFIG))
+	$(call KCONFIG_ENABLE_OPT,CONFIG_FEATURE_INDIVIDUAL,$(HOST_BUSYBOX_BUILD_CONFIG))
+endef
+
+define HOST_BUSYBOX_BUILD_CMDS
+	$(HOST_MAKE_ENV) $(MAKE) -C $(@D) busybox
+endef
+
+define HOST_BUSYBOX_INSTALL_CMDS
+	$(HOST_MAKE_ENV) $(MAKE) \
+		CONFIG_PREFIX="$(HOST_DIR)" \
+		EXTRA_LDFLAGS="-Wl,-rpath,$(HOST_DIR)/lib" \
+		-C $(@D) install
+	rm -f $(HOST_DIR)/bin/sh $(HOST_DIR)/bin/busybox
+endef
+
 $(eval $(kconfig-package))
+$(eval $(host-generic-package))
+
+MKPASSWD = $(HOST_DIR)/bin/mkpasswd
Signature · 1 line
2.17.0
#23 lore raw

PATCH v2 2/3 build: replace host-mkpasswd with host-busybox

In reply to Stefan Becker

host-mkpasswd was a fork from whois to provide a host version of mkpasswd for the build. This has caused a maintenance headache.

Replace it with host-busybox which can provide "mkpasswd" functionality from own source code. That causes less hassle for different build platforms.

---
 fs/common.mk                                         | 2 +-
 package/Config.in.host                               | 2 +-
 package/skeleton-init-common/skeleton-init-common.mk | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)
fs/common.mk +1 -1
index 9baf367729..42d5dff569 100644
@@ -63,7 +63,7 @@ ROOTFS_COMMON_TARGET_DIR = $(FS_DIR)/target
 
 ROOTFS_COMMON_DEPENDENCIES = \
 	host-fakeroot host-makedevs \
-	$(if $(PACKAGES_USERS)$(ROOTFS_USERS_TABLES),host-mkpasswd)
+	$(if $(PACKAGES_USERS)$(ROOTFS_USERS_TABLES),host-busybox)
 
 $(ROOTFS_COMMON_TAR): ROOTFS=COMMON
 $(ROOTFS_COMMON_TAR): FAKEROOT_SCRIPT=$(FS_DIR)/fakeroot.fs
package/Config.in.host +1 -1
index 38543e7390..c524333671 100644
@@ -2,6 +2,7 @@ menu "Host utilities"
 
 	source "package/aespipe/Config.in.host"
 	source "package/android-tools/Config.in.host"
+	source "package/busybox/Config.in.host"
 	source "package/cargo/Config.in.host"
 	source "package/cbootimage/Config.in.host"
 	source "package/checkpolicy/Config.in.host"
@@ -31,7 +32,6 @@ menu "Host utilities"
 	source "package/lpc3250loader/Config.in.host"
 	source "package/lttng-babeltrace/Config.in.host"
 	source "package/mfgtools/Config.in.host"
-	source "package/mkpasswd/Config.in.host"
 	source "package/mtd/Config.in.host"
 	source "package/mtools/Config.in.host"
 	source "package/mxsldr/Config.in.host"
package/skeleton-init-common/skeleton-init-common.mk +1 -1
index e8a0522052..99c87e3861 100644
@@ -63,7 +63,7 @@ ifneq ($(filter $$1$$% $$5$$% $$6$$%,$(SKELETON_INIT_COMMON_ROOT_PASSWD)),)
 SKELETON_INIT_COMMON_ROOT_PASSWORD = '$(SKELETON_INIT_COMMON_ROOT_PASSWD)'
 else ifneq ($(SKELETON_INIT_COMMON_ROOT_PASSWD),)
 # This variable will only be evaluated in the finalize stage, so we can
-# be sure that host-mkpasswd will have already been built by that time.
+# be sure that host-busybox will have already been built by that time.
 SKELETON_INIT_COMMON_ROOT_PASSWORD = "`$(MKPASSWD) -m "$(SKELETON_INIT_COMMON_PASSWD_METHOD)" "$(SKELETON_INIT_COMMON_ROOT_PASSWD)"`"
 endif
 else # !BR2_TARGET_ENABLE_ROOT_LOGIN
Signature · 1 line
2.17.0
#24 lore raw

PATCH v2 2/3 build: replace host-mkpasswd with host-busybox

Quoted 6 lines · Stefan Becker

host-mkpasswd was a fork from whois to provide a host version of mkpasswd for the build. This has caused a maintenance headache.

Replace it with host-busybox which can provide "mkpasswd" functionality from own source code. That causes less hassle for different build platforms.

Just to be clear: does everybody agree that it is a good idea to use
weakly-random numbers as salt, rather than real random numbers like whois does?

Regards,
Arnout

Signature · 6 lines
Arnout Vandecappelle                          arnout at mind be
Senior Embedded Software Architect            +32-16-286500
Essensium/Mind                                http://www.mind.be
G.Geenslaan 9, 3001 Leuven, Belgium           BE 872 984 063 RPR Leuven
LinkedIn profile: http://www.linkedin.com/in/arnoutvandecappelle
GPG fingerprint:  7493 020B C7E3 8618 8DEC 222C 82EB F404 F9AC 0DDF
#25 lore raw

PATCH v2 2/3 build: replace host-mkpasswd with host-busybox

Quoted 10 lines

From: "Arnout Vandecappelle" <[email protected]>
To: "Stefan Becker" <[email protected]>, "buildroot" <[email protected]>
Cc: "Yann Morin" <[email protected]>, "Thomas Petazzoni" <[email protected]>
Sent: Monday, June 4, 2018 7:21:10 PM
Subject: Re: [Buildroot] [PATCHv2 proposal/next 2/3] build: replace host-mkpasswd with host-busybox

Quoted 3 lines · Stefan Becker

host-mkpasswd was a fork from whois to provide a host version of mkpasswd for the build. This has caused a maintenance headache.

Quoted 6 lines
Quoted 3 lines

Replace it with host-busybox which can provide "mkpasswd" functionality from own source code. That causes less hassle for different build platforms.

Just to be clear: does everybody agree that it is a good idea to use weakly-random numbers as salt, rather than real random numbers like whois does?

Wouldn't it be better to add a host version of the whois package that installs mkpasswd, only?

Signature · 3 lines
Carlos Santos (Casantos) - DATACOM, P&D
?Marched towards the enemy, spear upright, armed with the certainty
that only the ignorant can have.? ? Epitaph of a volunteer
#26 lore raw

PATCH v2 2/3 build: replace host-mkpasswd with host-busybox

Carlos, All,

On 2018-06-05 08:22 -0300, Carlos Santos spake thusly:

Quoted 14 lines
Quoted 14 lines

From: "Arnout Vandecappelle" <[email protected]>
To: "Stefan Becker" <[email protected]>, "buildroot" <[email protected]>
Cc: "Yann Morin" <[email protected]>, "Thomas Petazzoni" <[email protected]>
Sent: Monday, June 4, 2018 7:21:10 PM
Subject: Re: [Buildroot] [PATCHv2 proposal/next 2/3] build: replace host-mkpasswd with host-busybox

Quoted 6 lines · Stefan Becker

host-mkpasswd was a fork from whois to provide a host version of mkpasswd for the build. This has caused a maintenance headache.

Replace it with host-busybox which can provide "mkpasswd" functionality from own source code. That causes less hassle for different build platforms.

Quoted 5 lines
Quoted 2 lines

Just to be clear: does everybody agree that it is a good idea to use weakly-random numbers as salt, rather than real random numbers like whois does?

Wouldn't it be better to add a host version of the whois package that installs mkpasswd, only?

That's what I initially suggested, but whois' mkpasswd uses some optional glibc features, which have been disabled in some distros, like Fedora28, which can then no longer build our mkpasswd. And our own mkasswd is an extract from way back then, when we did not have the whois package in busybox.

So, switching to host-whois is not an imporovement over the current situation.

Regards,
Yann E. MORIN.

Signature · 6 lines
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 223 225 172 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |
'------------------------------^-------^------------------^--------------------'
#27 lore raw

PATCH v2 2/3 build: replace host-mkpasswd with host-busybox

Sorry for top post, on mobile.

What about using openssl?

https://www.openssl.org/docs/manmaster/man1/openssl-passwd.html

Quoted 52 lines · Yann E. MORIN

Carlos, All,

On 2018-06-05 08:22 -0300, Carlos Santos spake thusly:

Quoted 2 lines
Quoted 2 lines

From: "Arnout Vandecappelle" <[email protected]>
To: "Stefan Becker" <[email protected]>, "buildroot" <

buildroot at buildroot.org>

Quoted 1 line
Quoted 1 line
Cc "Yann Morin" <[email protected]>, "Thomas Petazzoni" <

thomas.petazzoni at bootlin.com>

Quoted 2 lines
Quoted 2 lines

Sent: Monday, June 4, 2018 7:21:10 PM
Subject: Re: [Buildroot] [PATCHv2 proposal/next 2/3] build: replace

host-mkpasswd with host-busybox

Quoted 6 lines
Quoted 6 lines · Stefan Becker
Quoted 4 lines

host-mkpasswd was a fork from whois to provide a host version of mkpasswd for the build. This has caused a maintenance headache.

Replace it with host-busybox which can provide "mkpasswd"

functionality

Quoted 5 lines
Quoted 5 lines
Quoted 2 lines

from own source code. That causes less hassle for different build platforms.

Just to be clear: does everybody agree that it is a good idea to use weakly-random numbers as salt, rather than real random numbers like

whois does?

Quoted 3 lines

Wouldn't it be better to add a host version of the whois package that installs mkpasswd, only?

That's what I initially suggested, but whois' mkpasswd uses some optional glibc features, which have been disabled in some distros, like Fedora28, which can then no longer build our mkpasswd. And our own mkasswd is an extract from way back then, when we did not have the whois package in busybox.

So, switching to host-whois is not an imporovement over the current situation.

Regards,
Yann E. MORIN.

--

.-----------------.--------------------.------------------.--------------------.

|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics'
conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___
     |
| +33 223 225 172 `------------.-------:  X  AGAINST      |  \e/  There is
no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v
 conspiracy.  |
Quoted 6 lines

'------------------------------^-------^------------------^--------------------'
_______________________________________________
buildroot mailing list
buildroot at busybox.net
http://lists.busybox.net/mailman/listinfo/buildroot

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.busybox.net/pipermail/buildroot/attachments/20180605/dde121ac/attachment.html>

#28 lore raw

PATCH v2 2/3 build: replace host-mkpasswd with host-busybox

Christopher, All,

On 2018-06-05 09:35 -0700, Christopher McCrory spake thusly:

Quoted 3 lines

Sorry for top post, on mobile.
What about using openssl? [1]https://www.openssl.org/docs/manmaster/man1/openssl-passwd.html

Since we do not require that openssl be installed on the build machine, we'd have to build our own one. We do have a host-openssl package, but it takes quite a bit of time to build: on my relativelty fast laptop, it adds about 32s to the build time. This is a pretty big hit...

So, not an option IMHO...

Regards,
Yann E. MORIN.

Quoted 61 lines · Yann E. MORIN

Carlos, All,

On 2018-06-05 08:22 -0300, Carlos Santos spake thusly:

Quoted 14 lines
Quoted 14 lines

From: "Arnout Vandecappelle" < [3][email protected]>
To: "Stefan Becker" < [4][email protected]>, "buildroot" < [5][email protected]>
Cc: "Yann Morin" < [6][email protected]>, "Thomas Petazzoni" < [7][email protected]>
Sent: Monday, June 4, 2018 7:21:10 PM
Subject: Re: [Buildroot] [PATCHv2 proposal/next 2/3] build: replace host-mkpasswd with host-busybox

Quoted 6 lines · Stefan Becker

host-mkpasswd was a fork from whois to provide a host version of mkpasswd for the build. This has caused a maintenance headache.

Replace it with host-busybox which can provide "mkpasswd" functionality from own source code. That causes less hassle for different build platforms.

Quoted 5 lines
Quoted 2 lines

Just to be clear: does everybody agree that it is a good idea to use weakly-random numbers as salt, rather than real random numbers like whois does?

Wouldn't it be better to add a host version of the whois package that installs mkpasswd, only?

That's what I initially suggested, but whois' mkpasswd uses some optional glibc features, which have been disabled in some distros, like Fedora28, which can then no longer build our mkpasswd. And our own mkasswd is an extract from way back then, when we did not have the whois package in busybox.

So, switching to host-whois is not an imporovement over the current situation.

Regards,
Yann E. MORIN.

--
.-----------------.--------------------.------------------.--------------------.

  |? Yann E. MORIN? | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
  | +33 662 376 056 | Software? Designer | \ / CAMPAIGN? ? ?|? ___? ? ? ? ? ?
  ? ?|
  | +33 223 225 172 `------------.-------:? X? AGAINST? ? ? |? \e/? There is no? |
  | [8]http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL? ? |? ?v? ?conspiracy.? |

'------------------------------^-------^------------------^--------------------'
_______________________________________________
buildroot mailing list
[9]buildroot at busybox.net [10]http://lists.busybox.net/mailman/listinfo/buildroot

Links:
1. https://www.openssl.org/docs/manmaster/man1/openssl-passwd.html
2. mailto:yann.morin.1998 at free.fr
3. mailto:arnout at mind.be
4. mailto:chemobejk at gmail.com
5. mailto:buildroot at buildroot.org
6. mailto:yann.morin.1998 at free.fr
7. mailto:thomas.petazzoni at bootlin.com
8. http://ymorin.is-a-geek.org/
9. mailto:buildroot at busybox.net
10. http://lists.busybox.net/mailman/listinfo/buildroot

Signature · 6 lines
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 223 225 172 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |
'------------------------------^-------^------------------^--------------------'
#29 lore raw

PATCH v2 2/3 build: replace host-mkpasswd with host-busybox

Quoted 7 lines · Yann E. MORIN

Christopher, All,

On 2018-06-05 09:35 -0700, Christopher McCrory spake thusly:

Quoted 3 lines

Sorry for top post, on mobile.
What about using openssl? [1]https://www.openssl.org/docs/manmaster/man1/openssl-passwd.html

Quoted 6 lines

Since we do not require that openssl be installed on the build machine, we'd have to build our own one. We do have a host-openssl package, but it takes quite a bit of time to build: on my relativelty fast laptop, it adds about 32s to the build time. This is a pretty big hit...

So, not an option IMHO...

So, not whois, not busybox, not openssl... What about python, which we anyway
require to be installed on the host? I remember that someone has posted a one-liner that would do the job :-P

Regards,
Arnout

[snip]

Signature · 6 lines
Arnout Vandecappelle                          arnout at mind be
Senior Embedded Software Architect            +32-16-286500
Essensium/Mind                                http://www.mind.be
G.Geenslaan 9, 3001 Leuven, Belgium           BE 872 984 063 RPR Leuven
LinkedIn profile: http://www.linkedin.com/in/arnoutvandecappelle
GPG fingerprint:  7493 020B C7E3 8618 8DEC 222C 82EB F404 F9AC 0DDF
#30 lore raw

PATCH v2 2/3 build: replace host-mkpasswd with host-busybox

Hi Arnout, All,

Quoted 4 lines · Arnout Vandecappelle

So, not whois, not busybox, not openssl... What about python, which we anyway
require to be installed on the host? I remember that someone has posted a one-liner that would do the job :-P

Because a python one-liner is not enough. F.ex. from support/scripts/mkuser:

   # Encode a password
   encode_password() {
       local passwd="${1}"
       mkpasswd -m "${PASSWD_METHOD}" "${passwd}"

}

i.e. you need at least a python script with mkpasswd-compatible command line parameters.

Regards, Stefan

#31 lore raw

PATCH v2 2/3 build: replace host-mkpasswd with host-busybox

Stefan, Arnout, All,

On 2018-06-08 14:40 +0300, Stefan Becker spake thusly:

Quoted 4 lines · Arnout Vandecappelle
Quoted 3 lines

So, not whois, not busybox, not openssl... What about python, which we anyway
require to be installed on the host? I remember that someone has posted a one-liner that would do the job :-P

Well, I'd still prefer we had a script, and especially I did not like that it would read the random bytes from stdin, when python provides a proper random abstraction:

import os
os.urandom(64) # 64 random bytes

This is even portable, using various backends on various OSes... Then your previous proposal becomes acceptable. Now. ;-)

Quoted 8 lines

Because a python one-liner is not enough. F.ex. from support/scripts/mkuser:

   # Encode a password
   encode_password() {
       local passwd="${1}"
       mkpasswd -m "${PASSWD_METHOD}" "${passwd}"

}

Well, that one is an internal script of oours (I wrote it), so we can very well change it to use another tool without problem.

Quoted 2 lines

i.e. you need at least a python script with mkpasswd-compatible command line parameters.

Ideally, a mkpasswd-compatible tool would be nice, but as long as we use it internally, we don't care much, in fact.

Regards,
Yann E. MORIN.

Signature · 6 lines
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 223 225 172 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |
'------------------------------^-------^------------------^--------------------'
#32 lore raw

PATCH v2 2/3 build: replace host-mkpasswd with host-busybox

In reply to Arnout Vandecappelle

Arnout, All,

On 2018-06-05 00:21 +0200, Arnout Vandecappelle spake thusly:

Quoted 10 lines · Stefan Becker
Quoted 6 lines

host-mkpasswd was a fork from whois to provide a host version of mkpasswd for the build. This has caused a maintenance headache.

Replace it with host-busybox which can provide "mkpasswd" functionality from own source code. That causes less hassle for different build platforms.

Just to be clear: does everybody agree that it is a good idea to use
weakly-random numbers as salt, rather than real random numbers like whois does?

Not really, no. That is definitely no good. I was not aware of how bad the busybox salt generator was.. Sigh....

(note: I did see your previous reply, but did not get enough time to properly reply so far; sorry.)

Regards,
Yann E. MORIN.

Signature · 6 lines
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 223 225 172 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |
'------------------------------^-------^------------------^--------------------'
#33 lore raw

PATCH v2 2/3 build: replace host-mkpasswd with host-busybox

Quoted 12 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Yann" == Yann E MORIN <[email protected]> writes:

Arnout, All,
On 2018-06-05 00:21 +0200, Arnout Vandecappelle spake thusly:

Quoted 8 lines · Stefan Becker
Quoted 6 lines

host-mkpasswd was a fork from whois to provide a host version of mkpasswd for the build. This has caused a maintenance headache.

Replace it with host-busybox which can provide "mkpasswd" functionality from own source code. That causes less hassle for different build platforms.

Quoted 5 lines
Quoted 2 lines

Just to be clear: does everybody agree that it is a good idea to use weakly-random numbers as salt, rather than real random numbers like whois does?

Not really, no. That is definitely no good. I was not aware of how bad the busybox salt generator was.. Sigh....

If that is the only problem then we could still use it and pass our own salt, but that leaves the problem of coming up with a sufficiently random salt. I guess we could do something with reading /dev/urandom and base64 encoding it.

But yeah, just going for the python implementation may be the easiest.

Signature · 1 line
Bye, Peter Korsgaard
#34 lore raw

PATCH v2 2/3 build: replace host-mkpasswd with host-busybox

Hello,

Quoted 6 lines · Peter Korsgaard
Quoted 5 lines
Quoted 2 lines

Just to be clear: does everybody agree that it is a good idea to use weakly-random numbers as salt, rather than real random numbers like whois does?

Not really, no. That is definitely no good. I was not aware of how bad the busybox salt generator was.. Sigh....

Quoted 6 lines

If that is the only problem then we could still use it and pass our own salt, but that leaves the problem of coming up with a sufficiently random salt. I guess we could do something with reading /dev/urandom and base64 encoding it.

But yeah, just going for the python implementation may be the easiest.

Once again, what is the problem with the current solution we have ?

We have been happy with it for several years, and the only thing that prompted this discussion is that it failed to build on Fedora 28, which was fixed by a 3 lines change. Is it really worth it changing this stuff ?

Best regards,

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Bootlin (formerly Free Electrons)
Embedded Linux and Kernel engineering
https://bootlin.com
#35 lore raw

PATCH v2 3/3 package/mkpasswd: remove obsolete package

In reply to Stefan Becker

mkpasswd for the host is now provided by busybox.

---
 package/mkpasswd/Config.in.host |   2 -
 package/mkpasswd/config.h       |  95 -------
 package/mkpasswd/mkpasswd.c     | 461 --------------------------------
 package/mkpasswd/mkpasswd.mk    |  24 --
 package/mkpasswd/utils.c        |  96 -------
 package/mkpasswd/utils.h        |  56 ----
 6 files changed, 734 deletions(-)
 delete mode 100644 package/mkpasswd/Config.in.host
 delete mode 100644 package/mkpasswd/config.h
 delete mode 100644 package/mkpasswd/mkpasswd.c
 delete mode 100644 package/mkpasswd/mkpasswd.mk
 delete mode 100644 package/mkpasswd/utils.c
 delete mode 100644 package/mkpasswd/utils.h
package/mkpasswd/Config.in.host deleted +0 -2
deleted file mode 100644
index 93774bdf60..0000000000
@@ -1,2 +0,0 @@
-config BR2_PACKAGE_HOST_MKPASSWD
-	bool "host mkpasswd"
package/mkpasswd/config.h deleted +0 -95

95 lines not on this page · raw message

package/mkpasswd/mkpasswd.c deleted +0 -461

461 lines not on this page · raw message

package/mkpasswd/mkpasswd.mk deleted +0 -24
deleted file mode 100644
index b013390572..0000000000
@@ -1,24 +0,0 @@
-################################################################################
-#
-# mkpasswd
-#
-################################################################################
-
-# source included in buildroot, taken from
-# https://github.com/rfc1036/whois/blob/master/
-# at revision 5a0f08500fa51608b6d3b73ee338be38c692eadb
-HOST_MKPASSWD_LICENSE = GPL-2.0+
-
-define HOST_MKPASSWD_BUILD_CMDS
-	$(HOSTCC) $(HOST_CFLAGS) $(HOST_LDFLAGS) \
-		package/mkpasswd/mkpasswd.c package/mkpasswd/utils.c \
-		-o $(@D)/mkpasswd -lcrypt
-endef
-
-define HOST_MKPASSWD_INSTALL_CMDS
-	$(INSTALL) -D -m 755 $(@D)/mkpasswd $(HOST_DIR)/bin/mkpasswd
-endef
-
-$(eval $(host-generic-package))
-
-MKPASSWD = $(HOST_DIR)/bin/mkpasswd
package/mkpasswd/utils.c deleted +0 -96

96 lines not on this page · raw message

package/mkpasswd/utils.h deleted +0 -56

56 lines not on this page · raw message

Signature · 1 line
2.17.0
#36 lore raw

PATCH 1/1 host-mkpasswd: fix crash on Fedora 28 build host

In reply to Yann E. MORIN

Yann, All,

Quoted 7 lines · Yann E. MORIN

Stefan, All,

Although in the long run, I believe it might be preferrable that we ditch our own bundled version, and switch to making our whois package a hot pacakge, and use that as the provider for mkpasswd.

Stefan, would you want to do that? ;-)

I poked around in package/whois this morning to add host-whois. IMHO that package is not much of an improvement over package/mkpasswd. Everything is hard-coded there too, i.e. the build does not detect if the build host needs crypt.h/-lcrypt or not.

Just my $0.02,

Stefan

#37 lore raw

PATCH 1/1 host-mkpasswd: fix crash on Fedora 28 build host

In reply to Stefan Becker
Quoted 8 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Stefan" == Stefan Becker <[email protected]> writes:

crypt() is an optional glibc feature. Some distros, like Fedora 28, are phasing it out to be replaced with libxcrypt [1]. Unfortunately this change is only ABI compatible, not source code compatible, i.e. the code will compile with warnings about undefined crypt(), but the resulting binary will crash.

Quoted 6 lines

Follow the guidance in the Fedora bug and include crypt.h when _XOPEN_CRYPT is not defined.

[1] https://bugzilla.redhat.com/show_bug.cgi?id=1566464

Committed to 2018.02.x, thanks.

Signature · 1 line
Bye, Peter Korsgaard