Skip to contentSkip to conversation

Allow setting the password for user default

PATCH Superseded Stephan Hoffmann 3 participants 5 messages Jun 3, 2014 – Jun 4, 2014

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 Allow setting the password for user default

---
Since we can set the password for root while configuring the system it seems logical to have the same possibility for user "default".

Changes v1 -> v2
- remove rewording in help text for BR2_TARGET_GENERIC_ROOT_PASSWD

---
 system/Config.in | 23 ++++++++++++++++++++++-
 system/system.mk | 11 ++++++++++-
 2 files changed, 32 insertions(+), 2 deletions(-)
system/Config.in +21 -0
index 53bca53..d5408e1 100644
@@ -211,6 +211,27 @@ config BR2_TARGET_GENERIC_ROOT_PASSWD
 	  in the build log! Avoid using a valuable password if either the
 	  .config file or the build log may be distributed!
 
+config BR2_TARGET_GENERIC_DEFAULT_PASSWD
+	string "Password for user default"
+	default ""
+	help
+	  Set the initial password for user default (in clear). It will be encrypted.
+
+	  If set to empty (the default), then no password will be set,
+	  and default will need no password to log in.
+
+	  WARNING! WARNING!
+	  Although pretty strong, MD5 is now an old hash function, and
+	  suffers from some weaknesses, which makes it susceptible to attacks.
+	  It is showing its age, so this root password should not be trusted
+	  to properly secure any product that can be shipped to the wide,
+	  hostile world.
+
+	  WARNING! WARNING!
+	  The password appears in clear in the .config file, and may appear
+	  in the build log! Avoid using a valuable password if either the
+	  .config file or the build log may be distributed!
+
 config BR2_TARGET_GENERIC_GETTY
 	bool "Run a getty (login prompt) after boot"
 	default y
system/system.mk +10 -1
index 01a6c3a..367a8c4 100644
@@ -1,6 +1,7 @@
 TARGET_GENERIC_HOSTNAME = $(call qstrip,$(BR2_TARGET_GENERIC_HOSTNAME))
 TARGET_GENERIC_ISSUE = $(call qstrip,$(BR2_TARGET_GENERIC_ISSUE))
 TARGET_GENERIC_ROOT_PASSWD = $(call qstrip,$(BR2_TARGET_GENERIC_ROOT_PASSWD))
+TARGET_GENERIC_DEFAULT_PASSWD:=$(call qstrip,$(BR2_TARGET_GENERIC_DEFAULT_PASSWD))
 TARGET_GENERIC_PASSWD_METHOD = $(call qstrip,$(BR2_TARGET_GENERIC_PASSWD_METHOD))
 TARGET_GENERIC_GETTY_PORT = $(call qstrip,$(BR2_TARGET_GENERIC_GETTY_PORT))
 TARGET_GENERIC_GETTY_BAUDRATE = $(call qstrip,$(BR2_TARGET_GENERIC_GETTY_BAUDRATE))
@@ -29,6 +30,14 @@ target-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
 
+ifneq ($(TARGET_GENERIC_DEFAULT_PASSWD),)
+target-default-passwd: host-mkpasswd
+endif
+target-default-passwd:
+	[ -n "$(TARGET_GENERIC_DEFAULT_PASSWD)" ] && \
+		TARGET_GENERIC_DEFAULT_PASSWD_HASH=$$($(MKPASSWD) -m "$(TARGET_GENERIC_PASSWD_METHOD)" "$(TARGET_GENERIC_DEFAULT_PASSWD)"); \
+	$(SED) "s,^default:[^:]*:,default:$$TARGET_GENERIC_DEFAULT_PASSWD_HASH:," $(TARGET_DIR)/etc/shadow
+
 target-generic-getty-busybox:
 	$(SED) '/# GENERIC_SERIAL$$/s~^.*#~$(TARGET_GENERIC_GETTY_PORT)::respawn:/sbin/getty -L $(TARGET_GENERIC_GETTY_OPTIONS) $(TARGET_GENERIC_GETTY_PORT) $(TARGET_GENERIC_GETTY_BAUDRATE) $(TARGET_GENERIC_GETTY_TERM) #~' \
 		$(TARGET_DIR)/etc/inittab
@@ -60,7 +69,7 @@ TARGETS += target-generic-issue
 endif
 
 ifeq ($(BR2_ROOTFS_SKELETON_DEFAULT),y)
-TARGETS += target-root-passwd
+TARGETS += target-root-passwd target-default-passwd
 
 ifeq ($(BR2_TARGET_GENERIC_GETTY),y)
 TARGETS += target-generic-getty-$(if $(BR2_PACKAGE_SYSVINIT),sysvinit,busybox)
Signature · 1 line
2.0.0.rc2
#1 lore raw

PATCH v2 1/1 Allow setting the password for user default

Quoted 25 lines · Stephan Hoffmann

---
Since we can set the password for root while configuring the system it seems logical to have the same possibility for user "default".

Changes v1 -> v2
- remove rewording in help text for BR2_TARGET_GENERIC_ROOT_PASSWD

---
 system/Config.in | 23 ++++++++++++++++++++++-
 system/system.mk | 11 ++++++++++-
 2 files changed, 32 insertions(+), 2 deletions(-)
system/Config.in +5 -0
index 53bca53..d5408e1 100644
@@ -211,6 +211,27 @@ config BR2_TARGET_GENERIC_ROOT_PASSWD
 	  in the build log! Avoid using a valuable password if either the
 	  .config file or the build log may be distributed!
 
+config BR2_TARGET_GENERIC_DEFAULT_PASSWD
+	string "Password for user default"
+	default ""
+	help
+	  Set the initial password for user default (in clear). It will be encrypted.

system/Config.in config BR2_TARGET_GENERIC_ROOT_PASSWD · line 228

Quoted 10 lines
system/Config.in +10 -0
+
+	  If set to empty (the default), then no password will be set,
+	  and default will need no password to log in.
+
+	  WARNING! WARNING!
+	  Although pretty strong, MD5 is now an old hash function, and
+	  suffers from some weaknesses, which makes it susceptible to attacks.
+	  It is showing its age, so this root password should not be trusted
+	  to properly secure any product that can be shipped to the wide,
+	  hostile world.

Since we can now select the hash, this warning has no merit anymore.

With that fixed:

Quoted 22 lines
system/Config.in +6 -0
+
+	  WARNING! WARNING!
+	  The password appears in clear in the .config file, and may appear
+	  in the build log! Avoid using a valuable password if either the
+	  .config file or the build log may be distributed!
+
 config BR2_TARGET_GENERIC_GETTY
 	bool "Run a getty (login prompt) after boot"
 	default y
system/system.mk +1 -0
index 01a6c3a..367a8c4 100644
@@ -1,6 +1,7 @@
 TARGET_GENERIC_HOSTNAME = $(call qstrip,$(BR2_TARGET_GENERIC_HOSTNAME))
 TARGET_GENERIC_ISSUE = $(call qstrip,$(BR2_TARGET_GENERIC_ISSUE))
 TARGET_GENERIC_ROOT_PASSWD = $(call qstrip,$(BR2_TARGET_GENERIC_ROOT_PASSWD))
+TARGET_GENERIC_DEFAULT_PASSWD:=$(call qstrip,$(BR2_TARGET_GENERIC_DEFAULT_PASSWD))
 TARGET_GENERIC_PASSWD_METHOD = $(call qstrip,$(BR2_TARGET_GENERIC_PASSWD_METHOD))
 TARGET_GENERIC_GETTY_PORT = $(call qstrip,$(BR2_TARGET_GENERIC_GETTY_PORT))
 TARGET_GENERIC_GETTY_BAUDRATE = $(call qstrip,$(BR2_TARGET_GENERIC_GETTY_BAUDRATE))

system/system.mk target-root-passwd: · line 39

Quoted 10 lines
system/system.mk +7 -0
@@ -29,6 +30,14 @@ target-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
 
+ifneq ($(TARGET_GENERIC_DEFAULT_PASSWD),)
+target-default-passwd: host-mkpasswd
+endif
+target-default-passwd:
+	[ -n "$(TARGET_GENERIC_DEFAULT_PASSWD)" ] && \
+		TARGET_GENERIC_DEFAULT_PASSWD_HASH=$$($(MKPASSWD) -m "$(TARGET_GENERIC_PASSWD_METHOD)" "$(TARGET_GENERIC_DEFAULT_PASSWD)"); \
+	$(SED) "s,^default:[^:]*:,default:$$TARGET_GENERIC_DEFAULT_PASSWD_HASH:," $(TARGET_DIR)/etc/shadow

It would have been nice to factor this with the root password generation, but
that can be done in a follow-up patch if needed.

Regards,
Arnout

Quoted 14 lines
system/system.mk +2 -1
+
 target-generic-getty-busybox:
 	$(SED) '/# GENERIC_SERIAL$$/s~^.*#~$(TARGET_GENERIC_GETTY_PORT)::respawn:/sbin/getty -L $(TARGET_GENERIC_GETTY_OPTIONS) $(TARGET_GENERIC_GETTY_PORT) $(TARGET_GENERIC_GETTY_BAUDRATE) $(TARGET_GENERIC_GETTY_TERM) #~' \
 		$(TARGET_DIR)/etc/inittab
@@ -60,7 +69,7 @@ TARGETS += target-generic-issue
 endif
 
 ifeq ($(BR2_ROOTFS_SKELETON_DEFAULT),y)
-TARGETS += target-root-passwd
+TARGETS += target-root-passwd target-default-passwd
 
 ifeq ($(BR2_TARGET_GENERIC_GETTY),y)
 TARGETS += target-generic-getty-$(if $(BR2_PACKAGE_SYSVINIT),sysvinit,busybox)
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:  7CB5 E4CC 6C2E EFD4 6E3D A754 F963 ECAB 2450 2F1F
#2 lore raw

PATCH v2 1/1 Allow setting the password for user default

In reply to Stephan Hoffmann
Quoted 20 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Stephan" == Stephan Hoffmann <[email protected]> writes:

---
Since we can set the password for root while configuring the system it seems logical to have the same possibility for user "default".

Changes v1 -> v2
- remove rewording in help text for BR2_TARGET_GENERIC_ROOT_PASSWD

---
 system/Config.in | 23 ++++++++++++++++++++++-
 system/system.mk | 11 ++++++++++-
 2 files changed, 32 insertions(+), 2 deletions(-)
system/Config.in +0 -0
index 53bca53..d5408e1 100644
@@ -211,6 +211,27 @@ config BR2_TARGET_GENERIC_ROOT_PASSWD
 	  in the build log! Avoid using a valuable password if either the

system/Config.in config BR2_TARGET_GENERIC_ROOT_PASSWD · line 221

Quoted 10 lines
system/Config.in +8 -0
 	  .config file or the build log may be distributed!
 
+config BR2_TARGET_GENERIC_DEFAULT_PASSWD
+	string "Password for user default"
+	default ""
+	help
+	  Set the initial password for user default (in clear). It will be encrypted.
+
+	  If set to empty (the default), then no password will be set,
+	  and default will need no password to log in.

I would actually rather get rid of the 'default' user, now that we have support for BR2_ROOTFS_USERS_TABLES. The 'default' user is not needed for anything in Buildroot itself, and I'm pretty sure some people might not know / remember that we always have this password-less user and remember to remove it in a post build - I know I haven't.

Do you have any use case for keeping it instead of just using BR2_ROOTFS_USERS_TABLES?

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

PATCH v2 1/1 Allow setting the password for user default

Quoted 21 lines · Peter Korsgaard
Quoted 20 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Stephan" == Stephan Hoffmann <[email protected]> writes:

---
Since we can set the password for root while configuring the system it seems logical to have the same possibility for user "default".

Changes v1 -> v2
- remove rewording in help text for BR2_TARGET_GENERIC_ROOT_PASSWD

---
 system/Config.in | 23 ++++++++++++++++++++++-
 system/system.mk | 11 ++++++++++-
 2 files changed, 32 insertions(+), 2 deletions(-)
system/Config.in +0 -0
index 53bca53..d5408e1 100644
@@ -211,6 +211,27 @@ config BR2_TARGET_GENERIC_ROOT_PASSWD
 	  in the build log! Avoid using a valuable password if either the
 	  .config file or the build log may be distributed!
Quoted 14 lines

system/Config.in config BR2_TARGET_GENERIC_ROOT_PASSWD · line 221

Quoted 8 lines
system/Config.in +8 -0
+config BR2_TARGET_GENERIC_DEFAULT_PASSWD
+	string "Password for user default"
+	default ""
+	help
+	  Set the initial password for user default (in clear). It will be encrypted.
+
+	  If set to empty (the default), then no password will be set,
+	  and default will need no password to log in.

I would actually rather get rid of the 'default' user, now that we have support for BR2_ROOTFS_USERS_TABLES. The 'default' user is not needed for anything in Buildroot itself, and I'm pretty sure some people might not know / remember that we always have this password-less user and remember to remove it in a post build - I know I haven't.

Good point, Peter!

This patch was sitting around here for a while and I obviously missed the invention of BR2_ROOTFS_USERS_TABLES.

Quoted 2 lines

Do you have any use case for keeping it instead of just using BR2_ROOTFS_USERS_TABLES?

No, so we shall drop this patch. I can also cook a patch that removes the old default user, because I definitively do not want to have it without the possibility to give it a password easily.

Kind regards

Stephan

Quoted 1 line
Signature · 4 lines
reLinux     -    Stephan Hoffmann
Am Schmidtgrund 124    50765 K?ln
Tel. +49.221.95595-19    Fax: -64
www.reLinux.de Stephan at reLinux.de
#4 lore raw

PATCH v2 1/1 Allow setting the password for user default

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Stephan" == Stephan Hoffmann <[email protected]> writes:

Hi,

Quoted 5 lines
Quoted 2 lines

Do you have any use case for keeping it instead of just using BR2_ROOTFS_USERS_TABLES?

No, so we shall drop this patch. I can also cook a patch that removes the old default user, because I definitively do not want to have it without the possibility to give it a password easily.

Yes, please do - Thanks!

Signature · 1 line
Bye, Peter Korsgaard