host-mkpasswd: new package
PATCH v2 1/1 host-mkpasswd: new package
Since the addition of root password setting support in buildroot, there have been a few bug reports in this area ([1], [2]). In these cases, the system mkpasswd did either not work, or did not provide the options we expect, like -m <method>.
This patch adds a mkpasswd host package, based on the sources from whois. When a non-empty root password is set, this package is used as a dependency.
[1] http://lists.busybox.net/pipermail/buildroot/2013-July/075771.html
[2] http://lists.busybox.net/pipermail/buildroot/2013-July/075869.html
---
v2: fix license (GPLv2+ iso GPLv2)
package/mkpasswd/config.h | 95 ++++++ package/mkpasswd/mkpasswd.c | 456 +++++++++++++++++++++++++++++++ package/mkpasswd/mkpasswd.mk | 25 + package/mkpasswd/utils.c | 96 ++++++ package/mkpasswd/utils.h | 56 +++ support/dependencies/dependencies.sh | 8 - system/system.mk | 10 +- 7 files changed, 734 insertions(+), 12 deletions(-)
Notes:
1. currently, the mkpasswd is always built if you set a non-empty root password, even if the system mkpasswd is perfectly fine. An alternative would be to use the suitable-host-package mechanism.
2. to build the host mkpasswd, we need to link with libcrypt. Currently this is taken from the build machine, but I'm not sure if we can assume that (the development version of) this library is always present. We could either build our own, or set it as a dependency.
3. the whois package is GPLv2+. I did not include the COPYING file in buildroot, but maybe I should?
Feedback is very welcome.
package/mkpasswd/config.h new file +95 -0
@@ -0,0 +1,95 @@ +/* Program version */ +#define VERSION "5.0.26" + +/* Configurable features */ + +/* Always hide legal disclaimers */ +#undef ALWAYS_HIDE_DISCL + +/* Default server */ +#define DEFAULTSERVER "whois.arin.net" + +/* Configuration file */ +/* +#define CONFIG_FILE "/etc/whois.conf" +*/ + + +/* autoconf in cpp macros */ +#ifdef linux +# define ENABLE_NLS +#endif + +#ifdef __FreeBSD__ +/* which versions? */ +# define HAVE_GETOPT_LONG +# define HAVE_GETADDRINFO +# define ENABLE_NLS +# ifndef LOCALEDIR +# define LOCALEDIR "/usr/local/share/locale" +# endif +#endif + +/* needs unistd.h */ +#if defined _POSIX_C_SOURCE && _POSIX_C_SOURCE >=200112L +# define HAVE_GETADDRINFO +# define HAVE_REGEXEC +#endif + +#if defined __APPLE__ && defined __MACH__ +# define HAVE_GETOPT_LONG +# define HAVE_GETADDRINFO +#endif + +#if defined __GLIBC__ +# define HAVE_GETOPT_LONG +# if __GLIBC__ >=2 && __GLIBC_MINOR__ >=1 +# define HAVE_GETADDRINFO +# endif +# if __GLIBC__ >=2 && __GLIBC_MINOR__ >=7 +# define HAVE_SHA_CRYPT +# endif +#endif + +/* Unknown versions of Solaris */ +#if defined __SVR4 && defined __sun +# define HAVE_SHA_CRYPT +# define HAVE_SOLARIS_CRYPT_GENSALT +#endif + +/* FIXME: which systems lack this? */ +#define HAVE_GETTIMEOFDAY +/* FIXME: disabled because it does not parse addresses with a netmask length. +* The code using it needs to be either fixed or removed. +#define HAVE_INET_PTON +*/ + +/* +* Please send patches to correctly ignore old releases which lack a RNG +* and add more systems which have one. +*/ +#ifdef RANDOM_DEVICE +#elif defined __GLIBC__ \ + || defined __FreeBSD__ || defined __NetBSD__ || defined __OpenBSD__ \ +/* AIX >= 5.2? */ \ + || defined _AIX52 \ +/* HP-UX >= B.11.11.09? */ \ + || defined __hpux \ +/* OS X: */ \ + || (defined __APPLE__ && defined __MACH__) \ +/* Solaris >= 9 (this is >= 7): */ \ + || (defined __SVR4 && defined __sun && defined SUSv2) \ +/* Tru64 UNIX >= 5.1B? */ \ + || defined __osf +# define RANDOM_DEVICE "/dev/urandom" +#endif + +#ifdef ENABLE_NLS +# ifndef NLS_CAT_NAME +# define NLS_CAT_NAME "whois" +# endif +# ifndef LOCALEDIR +# define LOCALEDIR "/usr/share/locale" +# endif +#endif +
package/mkpasswd/mkpasswd.c new file +456 -0
456 lines not on this page · raw message
package/mkpasswd/mkpasswd.mk new file +25 -0
@@ -0,0 +1,25 @@ +################################################################################ +# +# mkpasswd +# +################################################################################ + +# source included in buildroot, taken from +# https://github.com/rfc1036/whois/blob/master/ +# at revision 5a0f08500fa51608b6d3b73ee338be38c692eadb +HOST_MKPASSWD_SOURCE = +HOST_MKPASSWD_LICENSE = GPLv2+ + +define HOST_MKPASSWD_BUILD_CMDS + $(HOSTCC) $(HOST_CFLAGS) $(HOST_LDFLAGS) -lcrypt \ + package/mkpasswd/mkpasswd.c package/mkpasswd/utils.c \ + -o $(@D)/mkpasswd +endef + +define HOST_MKPASSWD_INSTALL_CMDS + install -D -m 755 $(@D)/mkpasswd $(HOST_DIR)/usr/bin/mkpasswd +endef + +$(eval $(host-generic-package)) + +MKPASSWD = $(HOST_DIR)/usr/bin/mkpasswd
package/mkpasswd/utils.c new file +96 -0
96 lines not on this page · raw message
package/mkpasswd/utils.h new file +56 -0
56 lines not on this page · raw message
support/dependencies/dependencies.sh +0 -8
@@ -173,14 +173,6 @@ if grep -q ^BR2_PACKAGE_CLASSPATH=y $BUI done fi -if grep -E '^BR2_TARGET_GENERIC_ROOT_PASSWD=".+"$' $BUILDROOT_CONFIG > /dev/null 2>&1; then - if ! which mkpasswd > /dev/null 2>&1; then - /bin/echo -e "\nYou need the 'mkpasswd' utility to set the root password\n" - /bin/echo -e "(in Debian/ubuntu, 'mkpasswd' provided by the whois package)\n" - exit 1 - fi -fi - if grep -q ^BR2_HOSTARCH_NEEDS_IA32_LIBS=y $BUILDROOT_CONFIG ; then if test ! -f /lib/ld-linux.so.2 ; then /bin/echo -e "\nYour Buildroot configuration uses pre-built tools for the x86 architecture,"
system/system.mk +6 -4
@@ -2,9 +2,6 @@ TARGET_GENERIC_HOSTNAME := $(call qstrip TARGET_GENERIC_ISSUE := $(call qstrip,$(BR2_TARGET_GENERIC_ISSUE)) TARGET_GENERIC_ROOT_PASSWD := $(call qstrip,$(BR2_TARGET_GENERIC_ROOT_PASSWD)) TARGET_GENERIC_PASSWD_METHOD := $(call qstrip,$(BR2_TARGET_GENERIC_PASSWD_METHOD)) -ifneq ($(TARGET_GENERIC_ROOT_PASSWD),) -TARGET_GENERIC_ROOT_PASSWD_HASH = $(shell mkpasswd -m "$(TARGET_GENERIC_PASSWD_METHOD)" "$(TARGET_GENERIC_ROOT_PASSWD)") -endif TARGET_GENERIC_GETTY := $(call qstrip,$(BR2_TARGET_GENERIC_GETTY_PORT)) TARGET_GENERIC_GETTY_BAUDRATE := $(call qstrip,$(BR2_TARGET_GENERIC_GETTY_BAUDRATE)) TARGET_GENERIC_GETTY_TERM := $(call qstrip,$(BR2_TARGET_GENERIC_GETTY_TERM))
@@ -23,8 +20,13 @@ target-generic-issue: mkdir -p $(TARGET_DIR)/etc echo "$(TARGET_GENERIC_ISSUE)" > $(TARGET_DIR)/etc/issue +ifneq ($(TARGET_GENERIC_ROOT_PASSWD),) +target-root-passwd: host-mkpasswd +endif target-root-passwd: - $(SED) 's,^root:[^:]*:,root:$(TARGET_GENERIC_ROOT_PASSWD_HASH):,' $(TARGET_DIR)/etc/shadow + [ -n "$(TARGET_GENERIC_ROOT_PASSWD)" ] && \ + TARGET_GENERIC_ROOT_PASSWD_HASH=$$($(MKPASSWD) -m "$(TARGET_GENERIC_PASSWD_METHOD)" "$(TARGET_GENERIC_ROOT_PASSWD)"); \ + $(SED) "s,^root:[^:]*:,root:$$TARGET_GENERIC_ROOT_PASSWD_HASH:," $(TARGET_DIR)/etc/shadow target-generic-getty-busybox: $(SED) '/# GENERIC_SERIAL$$/s~^.*#~$(TARGET_GENERIC_GETTY)::respawn:/sbin/getty -L $(TARGET_GENERIC_GETTY) $(TARGET_GENERIC_GETTY_BAUDRATE) $(TARGET_GENERIC_GETTY_TERM) #~' \
PATCH v2 1/1 host-mkpasswd: new package
Dear Thomas De Schampheleire,
Quoted 9 lines · Thomas De Schampheleire
Since the addition of root password setting support in buildroot, there have been a few bug reports in this area ([1], [2]). In these cases, the system mkpasswd did either not work, or did not provide the options we expect, like -m <method>.
This patch adds a mkpasswd host package, based on the sources from whois. When a non-empty root password is set, this package is used as a dependency.
Signed-off-by Thomas De Schampheleire <[email protected]>
Committed, thanks. I just did two minor changes:
* Put -lcrypt at the end of the compilation line, otherwise the mkpasswd build was failing here.
* Change 'install' to '$(INSTALL)'
Thomas
Signature · 4 lines
Thomas Petazzoni, Free Electrons Kernel, drivers, real-time and embedded Linux development, consulting, training and support. http://free-electrons.com