The shadow package does not correctly configure the ENCRYPT_METHOD option according to BR2_TARGET_GENERIC_PASSWD_SHA256/512


### Check-list

- [x] I did not find the issue in the existing issues
- [ ] I can reproduce the issue with unmodified Buildroot from [this repository](https://gitlab.com/buildroot.org/buildroot), not from a fork somewhere else
- [ ] I can reproduce the issue on the latest commit of the branch I'm using:
  - [ ] master
  - [ ] stable (i.e. 20NN.MM.x - please specify)
  - [x] LTS (i.e. 20NN.02.x - please specify)
- [x] I can reproduce the issue after running `make clean; make`
- [ ] I attached the full build log file (e.g. `make 2>&1 |tee build.log`)
- [ ] I attached a **minimal** defconfig file that can reproduce the issue (`make BR2_DEFCONFIG=$(pwd)/issue_defconfig savedefconfig`)
- [ ] I also attached the configuration for kconfig-based packages that are enabled (and necessary to reproduce the issue), most notably:
  - [ ] busybox
  - [ ] linux
  - [ ] uclibc
  - [ ] uboot
  - [ ] …

### What happens

When I configured the system-wide password encryption method and selected the shadowd package to provide the password tool, shadow used DES to encrypt the /etc/shadow file by default, which was not passed to the final rootfs file according to the config settings.

In shadow, the hashing method is configured in /etc/login.defs, and the default is only DES.

`config:`

`[root@Builder buildroot]# cat .config |grep BR2_TARGET_GENERIC_PASSWD `

`# BR2_TARGET_GENERIC_PASSWD_SHA256 is not set `

`BR2_TARGET_GENERIC_PASSWD_SHA512=y `

`BR2_TARGET_GENERIC_PASSWD_METHOD="sha-512" `

`# BR2_TARGET_GENERIC_PASSWD_MD5 is not set `

`[root@Builder buildroot]# cat .config |grep password `

`BR2_TARGET_GENERIC_ROOT_PASSWD="password"`

**Use the login.defs file in shadow to control passwd encryption**

```null
# Only works if compiled with MD5_CRYPT defined:
# If set to "yes", new passwords will be encrypted using the MD5-based
# algorithm compatible with the one used by recent releases of FreeBSD.
# It supports passwords of unlimited length and longer salt strings.
# Set to "no" if you need to copy encrypted passwords to other systems
# which don't understand the new algorithm.  Default is "no".
#
# Note: If you use PAM, it is recommended to use a value consistent with
# the PAM modules configuration.
#
# This variable is deprecated. You should use ENCRYPT_METHOD instead.
#
#MD5_CRYPT_ENAB	no

#
# Only works if compiled with ENCRYPTMETHOD_SELECT defined:
# If set to MD5, MD5-based algorithm will be used for encrypting password
# If set to SHA256, SHA256-based algorithm will be used for encrypting password
# If set to SHA512, SHA512-based algorithm will be used for encrypting password
# If set to BCRYPT, BCRYPT-based algorithm will be used for encrypting password
# If set to YESCRYPT, YESCRYPT-based algorithm will be used for encrypting password
# If set to DES, DES-based algorithm will be used for encrypting password (default)
# MD5 and DES should not be used for new hashes, see crypt(5) for recommendations.
# Overrides the MD5_CRYPT_ENAB option
#
# Note: If you use PAM, it is recommended to use a value consistent with
# the PAM modules configuration.
#
#ENCRYPT_METHOD DES

### What was expected

_It is recommended to modify the configuration of login.defs globally in the mk file according to the config configuration so that the behavior of passwd is consistent with .config._

---

### Extra information

_Here, you may write additional information that does not fit above_
Assignee Loading
Time tracking Loading