Skip to contentSkip to conversation

package/sudo: Enable libxcrypt with glibc, allowing hashed passwords without PAM

PATCH Applied Nathaniel Roach via buildroot 1 participant 3 messages Jul 21, 2025 – Aug 7, 2025

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 package/sudo: Enable libxcrypt with glibc, allowing hashed passwords without PAM

Per https://gitlab.com/buildroot.org/buildroot/-/issues/27 , on glibc builds without PAM, sudo will "fail" all password prompts.

It was found that it's simply checking the entered string against the raw hash, because 'libcryp' isn't available. On glibc, we need libxcrypt, so enable it and ensure sudo is built with it.

musl and uclibc do have crypt() functions, so this is not needed.

Relevant code from sudo:
https://github.com/sudo-project/sudo/blob/v1.9.17p1/plugins/sudoers/auth/passwd.c#L139

---
Backport to 2025.02.x, 2025.05.x

Changes v1 -> v2:
- Update makefile logic to depend on libxcrypt regardless of PAM (h/t Julien)
- Update description, backport notes

---
 package/sudo/Config.in | 1 +
 package/sudo/sudo.mk   | 4 ++++
 2 files changed, 5 insertions(+)
package/sudo/Config.in +1 -0
index ee5ea542ab..85bc4859b8 100644
@@ -2,6 +2,7 @@ config BR2_PACKAGE_SUDO
 	bool "sudo"
 	# uses fork()
 	depends on BR2_USE_MMU
+	select BR2_PACKAGE_LIBXCRYPT if BR2_TOOLCHAIN_USES_GLIBC
 	help
 	  Sudo is a program designed to allow a sysadmin to give
 	  limited root privileges to users and log root activity. The
package/sudo/sudo.mk +4 -0
index f57a86805a..0aacd8207d 100644
@@ -37,6 +37,10 @@ else
 SUDO_CONF_OPTS += --without-pam
 endif
 
+ifeq ($(BR2_PACKAGE_LIBXCRYPT),y)
+SUDO_DEPENDENCIES += libxcrypt
+endif
+
 ifeq ($(BR2_PACKAGE_ZLIB),y)
 SUDO_CONF_OPTS += --enable-zlib
 SUDO_DEPENDENCIES += zlib
Signature · 6 lines
2.39.5

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
#1 lore raw
Quoted 7 lines · Nathaniel Roach via buildroot

Per https://gitlab.com/buildroot.org/buildroot/-/issues/27 , on glibc builds without PAM, sudo will "fail" all password prompts.

It was found that it's simply checking the entered string against the raw hash, because 'libcryp' isn't available. On glibc, we need libxcrypt, so enable it and ensure sudo is built with it.

Quoted 7 lines

musl and uclibc do have crypt() functions, so this is not needed.

Relevant code from sudo:

https://github.com/sudo-project/sudo/blob/v1.9.17p1/plugins/sudoers/auth/passwd.c#L139

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

#2 lore raw
In reply to Nathaniel Roach via buildroot

In reply of:

Quoted 7 lines

Per https://gitlab.com/buildroot.org/buildroot/-/issues/27 , on glibc builds without PAM, sudo will "fail" all password prompts.

It was found that it's simply checking the entered string against the raw hash, because 'libcryp' isn't available. On glibc, we need libxcrypt, so enable it and ensure sudo is built with it.

Quoted 7 lines

musl and uclibc do have crypt() functions, so this is not needed.

Relevant code from sudo:
https://github.com/sudo-project/sudo/blob/v1.9.17p1/plugins/sudoers/auth/passwd.c#L139

Applied to 2025.02.x & 2025.05.x. Thanks

Quoted 47 lines

---
Backport to 2025.02.x, 2025.05.x

Changes v1 -> v2:
- Update makefile logic to depend on libxcrypt regardless of PAM (h/t Julien)
- Update description, backport notes

---
 package/sudo/Config.in | 1 +
 package/sudo/sudo.mk   | 4 ++++
 2 files changed, 5 insertions(+)
package/sudo/Config.in +1 -0
index ee5ea542ab..85bc4859b8 100644
@@ -2,6 +2,7 @@ config BR2_PACKAGE_SUDO
 	bool "sudo"
 	# uses fork()
 	depends on BR2_USE_MMU
+	select BR2_PACKAGE_LIBXCRYPT if BR2_TOOLCHAIN_USES_GLIBC
 	help
 	  Sudo is a program designed to allow a sysadmin to give
 	  limited root privileges to users and log root activity. The
package/sudo/sudo.mk +4 -0
index f57a86805a..0aacd8207d 100644
@@ -37,6 +37,10 @@ else
 SUDO_CONF_OPTS += --without-pam
 endif
 
+ifeq ($(BR2_PACKAGE_LIBXCRYPT),y)
+SUDO_DEPENDENCIES += libxcrypt
+endif
+
 ifeq ($(BR2_PACKAGE_ZLIB),y)
 SUDO_CONF_OPTS += --enable-zlib
 SUDO_DEPENDENCIES += zlib
Signature · 6 lines
2.39.5

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

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