Skip to contentSkip to conversation

Allow setting the password for user default

PATCH Superseded Stephan Hoffmann 2 participants 2 messages Jun 3, 2014

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 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".

---
 system/Config.in | 23 ++++++++++++++++++++++-
 system/system.mk | 11 ++++++++++-
 2 files changed, 32 insertions(+), 2 deletions(-)
system/Config.in +22 -1
index 53bca53..d5408e1 100644
@@ -194,7 +194,7 @@ config BR2_TARGET_GENERIC_ROOT_PASSWD
 	string "Root password"
 	default ""
 	help
-	  Set the initial root password (in clear). It will be md5-encrypted.
+	  Set the initial root password (in clear). It will be encrypted.
 
 	  If set to empty (the default), then no root password will be set,
 	  and root will need no password to log in.
@@ -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 1/1 Allow setting the password for user default

Hi Stephan,

Quoted 14 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".

---
 system/Config.in | 23 ++++++++++++++++++++++-
 system/system.mk | 11 ++++++++++-
 2 files changed, 32 insertions(+), 2 deletions(-)
system/Config.in +0 -0
index 53bca53..d5408e1 100644

system/Config.in config BR2_TARGET_GENERIC_ROOT_PASSWD · line 197

Quoted 5 lines
system/Config.in +1 -1
@@ -194,7 +194,7 @@ config BR2_TARGET_GENERIC_ROOT_PASSWD
 	string "Root password"
 	default ""
 	help
-	  Set the initial root password (in clear). It will be md5-encrypted.
+	  Set the initial root password (in clear). It will be encrypted.

This should be done in a separate patch.

system/Config.in config BR2_TARGET_GENERIC_ROOT_PASSWD · line 218

Quoted 12 lines
system/Config.in +5 -0
 	  If set to empty (the default), then no root password will be set,
 	  and root will need no password to log in.
@@ -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.

But you can still use this wording here.

baruch

Quoted 3 lines
system/Config.in +3 -0
+
+	  If set to empty (the default), then no password will be set,
+	  and default will need no password to log in.
Signature · 3 lines
     http://baruch.siach.name/blog/                  ~. .~   Tk Open Systems
=}------------------------------------------------ooO--U--Ooo------------{=
   - baruch at tkos.co.il - tel: +972.2.679.5364, http://www.tkos.co.il -