Skip to contentSkip to conversation

package/shadow: default to BR2_TARGET_GENERIC_PASSWD_ algo

PATCH Applied Peter Korsgaard 2 participants 5 messages Feb 4 – Feb 13

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 package/shadow: default to BR2_TARGET_GENERIC_PASSWD_ algo

Make shadow follow the the BR2_TARGET_GENERIC_PASSWD_* system configuration option when changing password rather than DES.

Fixes:
https://gitlab.com/buildroot.org/buildroot/-/issues/134

---
 package/shadow/shadow.mk | 15 +++++++++++++++
 1 file changed, 15 insertions(+)
package/shadow/shadow.mk +15 -0
index 2ba7a0e03e..cf05fc1bdc 100644
@@ -140,4 +140,19 @@ define SHADOW_PERMISSIONS
 	$(SHADOW_SUBORDINATE_IDS_PERMISSIONS)
 endef
 
+ifeq ($(BR2_TARGET_GENERIC_PASSWD_SHA256),y)
+SHADOW_ENCRYPT_METHOD = SHA256
+else ifeq ($(BR2_TARGET_GENERIC_PASSWD_SHA512),y)
+SHADOW_ENCRYPT_METHOD = SHA512
+endif
+
+ifneq ($(SHADOW_ENCRYPT_METHOD),)
+define SHADOW_SET_ENCRYPT_METHOD
+	$(SED) 's/^[#]\?ENCRYPT_METHOD .*/ENCRYPT_METHOD $(SHADOW_ENCRYPT_METHOD)/' \
+		$(TARGET_DIR)/etc/login.defs
+endef
+
+SHADOW_POST_INSTALL_TARGET_HOOKS += SHADOW_SET_ENCRYPT_METHOD
+endif
+
 $(eval $(autotools-package))
Signature · 6 lines
2.47.3

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

PATCH 2/2 package/shadow: ensure that SHA support is enabled when requested

Ensure that the SHA_CRYPT option is enabled when the system configuration is set to SHA256/512, as otherwise passwd complains when a password is changed:

passwd
...
Invalid ENCRYPT_METHOD value: 'SHA512'.
Defaulting to DES.

---
 package/shadow/Config.in | 3 +++
 1 file changed, 3 insertions(+)
package/shadow/Config.in +3 -0
index bbbea811ce..93216bd14c 100644
@@ -3,6 +3,9 @@ menuconfig BR2_PACKAGE_SHADOW
 	depends on !BR2_STATIC_LIBS
 	depends on BR2_TOOLCHAIN_HEADERS_AT_LEAST_4_14
 	select BR2_PACKAGE_LIBXCRYPT if BR2_TOOLCHAIN_USES_GLIBC
+	select BR2_PACKAGE_SHADOW_SHA_CRYPT if \
+	       (BR2_TARGET_GENERIC_PASSWD_SHA256 || \
+	        BR2_TARGET_GENERIC_PASSWD_SHA512)
 	help
 	  Utilities to deal with user accounts.
 
Signature · 6 lines
2.47.3

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

Re: [Buildroot] [PATCH 2/2] package/shadow: ensure that SHA support is enabled when requested

In reply of:

Quoted 9 lines

Ensure that the SHA_CRYPT option is enabled when the system configuration is set to SHA256/512, as otherwise passwd complains when a password is changed:

passwd
...
Invalid ENCRYPT_METHOD value: 'SHA512'.
Defaulting to DES.

Applied to 2025.02.x & 2025.11.x. Thanks

Quoted 25 lines
---
 package/shadow/Config.in | 3 +++
 1 file changed, 3 insertions(+)
package/shadow/Config.in +3 -0
index bbbea811ce..93216bd14c 100644
@@ -3,6 +3,9 @@ menuconfig BR2_PACKAGE_SHADOW
 	depends on !BR2_STATIC_LIBS
 	depends on BR2_TOOLCHAIN_HEADERS_AT_LEAST_4_14
 	select BR2_PACKAGE_LIBXCRYPT if BR2_TOOLCHAIN_USES_GLIBC
+	select BR2_PACKAGE_SHADOW_SHA_CRYPT if \
+	       (BR2_TARGET_GENERIC_PASSWD_SHA256 || \
+	        BR2_TARGET_GENERIC_PASSWD_SHA512)
 	help
 	  Utilities to deal with user accounts.
 
Signature · 6 lines
2.47.3

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

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

#3 lore raw
In reply to Peter Korsgaard
Quoted 7 lines · Peter Korsgaard

Make shadow follow the the BR2_TARGET_GENERIC_PASSWD_* system configuration option when changing password rather than DES.

Fixes:
https://gitlab.com/buildroot.org/buildroot/-/issues/134

Series applied to master, thanks.
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot

#4 lore raw
In reply to Peter Korsgaard

In reply of:

Quoted 7 lines

Make shadow follow the the BR2_TARGET_GENERIC_PASSWD_* system configuration option when changing password rather than DES.

Fixes:
https://gitlab.com/buildroot.org/buildroot/-/issues/134

Applied to 2025.02.x & 2025.11.x. Thanks

Quoted 35 lines
---
 package/shadow/shadow.mk | 15 +++++++++++++++
 1 file changed, 15 insertions(+)
package/shadow/shadow.mk +15 -0
index 2ba7a0e03e..cf05fc1bdc 100644
@@ -140,4 +140,19 @@ define SHADOW_PERMISSIONS
 	$(SHADOW_SUBORDINATE_IDS_PERMISSIONS)
 endef
 
+ifeq ($(BR2_TARGET_GENERIC_PASSWD_SHA256),y)
+SHADOW_ENCRYPT_METHOD = SHA256
+else ifeq ($(BR2_TARGET_GENERIC_PASSWD_SHA512),y)
+SHADOW_ENCRYPT_METHOD = SHA512
+endif
+
+ifneq ($(SHADOW_ENCRYPT_METHOD),)
+define SHADOW_SET_ENCRYPT_METHOD
+	$(SED) 's/^[#]\?ENCRYPT_METHOD .*/ENCRYPT_METHOD $(SHADOW_ENCRYPT_METHOD)/' \
+		$(TARGET_DIR)/etc/login.defs
+endef
+
+SHADOW_POST_INSTALL_TARGET_HOOKS += SHADOW_SET_ENCRYPT_METHOD
+endif
+
 $(eval $(autotools-package))
Signature · 6 lines
2.47.3

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

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