Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

libxcrypt: Remaining changes #195271

Merged
merged 3 commits into from
Oct 11, 2022
Merged

Conversation

mweinelt
Copy link
Member

@mweinelt mweinelt commented Oct 9, 2022

Description of changes

Updates that I didn't want to push into #181764 anymore. These should be uncontroversial updates to the libxcrypt package and manual updates.

And an activation script that notifies users if they need to update their password hashes in /etc/shadow.

Things done
  • Built on platform(s)
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • For non-Linux: Is sandbox = true set in nix.conf? (See Nix manual)
  • Tested, as applicable:
  • Tested compilation of all packages that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage
  • Tested basic functionality of all binary files (usually in ./result/bin/)
  • 22.11 Release Notes (or backporting 22.05 Release notes)
    • (Package updates) Added a release notes entry if the change is major or breaking
    • (Module updates) Added a release notes entry if the change is significant
    • (Module addition) Added a release notes entry if adding a new NixOS module
    • (Release notes changes) Ran nixos/doc/manual/md-to-db.sh to update generated release notes
  • Fits CONTRIBUTING.md.


users = set()
try:
with open("/etc/shadow", "r") as fd:
Copy link
Member Author

@mweinelt mweinelt Oct 10, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I should probably grab getent shadow to account for other lookups. But is crypt even involved in that case? 🤔

nixos/modules/config/supported-hashes.py Outdated Show resolved Hide resolved
@@ -32,8 +32,7 @@ account will cease to exist. Also, imperative commands for managing users and
groups, such as useradd, are no longer available. Passwords may still be
assigned by setting the user\'s
[hashedPassword](#opt-users.users._name_.hashedPassword) option. A
hashed password can be generated using `mkpasswd -m
sha-512`.
hashed password can be generated using `mkpasswd -m yescrypt`.
Copy link
Contributor

@oxalica oxalica Oct 10, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the rationale for this change? sha-512 $6$ is still allowed as good_schemes.
Also note that yescrypt is the default method when calling mkpassword without -m.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll reference https://fedoraproject.org/wiki/Changes/yescrypt_as_default_hashing_method_for_shadow, where the author of libxcrypt explains why sha256crypt & sha512crypt are not optimal.

I'm aware it is the default, the ordering comes from the order in https://github.com/besser82/libxcrypt/blob/v4.4.28/lib/hashes.conf#L41.

I'm fine with removing the -m parameter entirely, and I'm against sticking with sha512 explicitly, because documentation gets outdated far too quickly.

Comment on lines 50 to 55
print(
"""
WARNING: The following users are relying on password hashes that will
be removed in NixOS 23.05. They should be renewed as soon as possible!""",
file=sys.stderr,
)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we abort the switching in a next deprecation step?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also thought this was a good idea, but realized it's an obvious bad idea when doing nixos-rebuild boot into e.g. 23.05 -- the system would just fail to boot with that message, which... I don't know if we want that. Maybe we do? Not sure.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can harden the validation for hashedPassword using strMatching, but we don't have an equally good solution for mutable passwords.

@oxalica
Copy link
Contributor

oxalica commented Oct 10, 2022

We should also warn earlier at eval-time if users set users.users.<name>.hashedPassword, in,
https://github.com/NixOS/nixpkgs/blob/9771e3bce8f57bbca0b20a38deb23a1b7bcb3e20/nixos/modules/config/users-groups.nix#L690-L719

@mweinelt mweinelt marked this pull request as draft October 10, 2022 20:12
@mweinelt
Copy link
Member Author

Converting to draft while untested and with open change requests. If someone wants to work on the warning for hashedPassword please speak up.

The shadow test uses a password that is hashed with libxcrypt and the
login test uses the passwd command.
@mweinelt
Copy link
Member Author

mweinelt commented Oct 11, 2022

Reduced to the uncontroversial changes so they land in the same staging cycle as the libxcrypt migration. Moving documentation and deprecation warning changes into dedicated PR.

@mweinelt mweinelt merged commit 2085ea1 into NixOS:staging Oct 11, 2022
@mweinelt mweinelt deleted the libxcrypt-continued branch October 11, 2022 09:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants