Skip to content

nixos/vsftpd: cannot log in with localUsers configured #515531

Closed

Description

@me-and

Nixpkgs version

  • Unstable (26.05)

Describe the bug

As of #420889, my attempts to log in to a vsftpd server have started failing. I suspect the issue is that I have services.vsftpd.localUsers configured, and that PR changed the authentication behaviour. I have a reasonably minimal repro below.

Steps to reproduce

I have a minimal repro repository at https://github.com/me-and/nixos-minimal-vm/tree/vsftpd. This sets up a temporary virtual machine with vsftpd running that demonstrates the problem.

If you have flakes set up, you can do the following:

  1. Run nix run github:me-and/nixos-minimal-vm/vsftpd in one terminal, and wait for the VM to boot up.
  2. In another terminal, run curl -v --user vsftpdtest:12345 ftp://127.0.0.1:2121.

In both the old and new cases, the curl command will fail. However, the failure should be because the test VM doesn't have its network set up for a the PASV connection to succeed, and the curl output will include 230 Login successful. In the failing case, the login fails with the message 530 Login incorrect..

Expected behaviour

Users can log in to the vsftpd server using their password. Or, in the case of the minimal test VM, the FTP connection doesn't fail until the user's password has been accepted.

Screenshots

No response

Relevant log output

Additional context

No response

System metadata

  • system: "x86_64-linux"
  • host os: Linux 6.6.87.2-microsoft-standard-WSL2, NixOS, 26.05 (Yarara), 26.05.20260427.1c3fe55
  • multi-user?: yes
  • sandbox: relaxed
  • version: nix-env (Nix) 2.34.6
  • nixpkgs: /nix/store/l61vfkyy0qrnz9bmgx84fa7z3bjzhyp4-source

Notify maintainers

Key folk involved in #420889: @Majiir @phaer

vsftpd maintainer: @peterhoeg


Note for maintainers: Please tag this issue in your pull request description. (i.e. Resolves #ISSUE.)

I assert that this issue is relevant for Nixpkgs

Is this issue important to you?

Add a 👍 reaction to issues you find important.

Activity

  1. added
    0.kind: bug
    6.topic: nixos
    0.kind: regression
    on May 1, 2026
  2. Majiir commented on May 2, 2026

    @Majiir
    Contributor

    This is happening because #420889 fixed a bug where the vsftpd PAM service was being created with a set of default rules when it was supposed to be disabled entirely.

    The services.vsftpd module only tries to create the vsftpd PAM service when cfg.enableVirtualUsers && cfg.userDbPath != null, which is false in your config because those options are not set. You need to configure these if you want to use pam_userdb. (That's not new - it's how services.vsftpd is intended to work.)

    But because of the bug, the older nixpkgs commit results in a default vsftpd PAM service with the wrong rules. The fix results in the vsftpd PAM service going away in your example config.

    If you want to use a vsftpd PAM service but without using services.vsftpd.enableVirtualUsers, then you need to configure security.pam.services.vsftpd yourself.

  3. me-and commented on May 3, 2026

    @me-and
    MemberAuthor

    @Majiir This might be how services.vsftpd was intended to work, but I disagree that this change of behaviour isn't new and isn't a functional regression.

    I had intended to use vsftpd with local system user accounts. It isn't obvious to me, either from the NixOS option documentation or the vsftpd.conf documentation that this should require cfg.enableVirtualUsers and cfg.userDbPath to both be set. I don't think my use case is particularly unusual.

    Further, I've tested as far back as NixOS 22.11, and my configuration worked as expected there, so this change of behaviour very much is new. I only stopped at 22.11 because 22.05 had some unrelated evaluation errors I didn't want to spend too much time debugging, not because the vsftpd module worked as it was apparently designed there.

    I think we need to do one of:

    • Adapt the vsftpd module such that localUsers = true works without needing to also set enableVirtualUsers and userDbPath.
    • Document this in the 26.05 release notes as a backwards-incompatible change, and ideally also add module evaluation warnings or errors to catch people using localUsers without enableVirtualUsers.
    • Back nixos: replace 'text' with structured PAM rules #420889 out of 26.05 and re-attempt the fixes in that PR in 26.11 when we can take a bit more time to make sure we're not introducing regressions.
  4. reopened this on May 3, 2026
  5. Majiir commented on May 4, 2026

    @Majiir
    Contributor

    In the previous state, the vsftpd PAM service was not explicitly configured anywhere; it was using the defaults that are applied to all PAM services in NixOS. (Those defaults are themselves not really a documented feature, and more of an artifact of how pam.nix works.) That strikes me as an unsafe behavior and not something that should be restored.

    Someone more familiar with vsftpd should fix the module. A release note sounds fine in the meantime.

    I'm not sure that setting enableVirtualUsers is the right workaround, since the vsftpd PAM service will only have the pam_userdb rules created by the module, and nothing else. To restore the defaults as before, configure:

    {
      security.pam.services.vsftpd.enable = true;
    }
  6. wigust commented on May 15, 2026

    @wigust
    Contributor

    The test suite currently fails without @Majiir fix:

    diff --git a/nixos/tests/vsftpd.nix b/nixos/tests/vsftpd.nix
    index f3bd182a3748..31183b324f6f 100644
    --- a/nixos/tests/vsftpd.nix
    +++ b/nixos/tests/vsftpd.nix
    @@ -13,6 +13,7 @@
             localRoot = "/tmp";
           };
           networking.firewall.enable = false;
    +      security.pam.services.vsftpd.enable = true;
     
           users = {
             users.ftp-test-user = {
  7. mdaniels5757 commented on May 25, 2026

    @mdaniels5757
    Member

    I just merged release notes in #517011/#524166, feel free to make a PR to refine them if needed.

    I've also merged a fix for the tests in #520930/#524171.

  8. phaer commented on May 30, 2026

    @phaer
    Member

    My understanding here is that changes were intentional and that the changed behavior is now properly documented in the release notes.

    So closing this, feel free to re-open if needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    0.kind: bug0.kind: regression6.topic: nixos

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions