Skip to content

[Bug]: SMB listings may omit long filenames and misparse directory rows #182

Open

Description

@X1pheR

Problem

DBackup's SMB adapter delegates directory enumeration to samba-client (client.list()). With long backup archive filenames, smbclient can emit a line without the usual padded filename column. The downstream has observed cases where samba-client returns an empty or incomplete listing while a raw dir command still contains those entries.

Example (synthetic data):

  Critical_Backups_2026-10-10_01-20-00_full-000.tar A 2580549120  Sat Oct 10 01:20:00 2026
  nightly.index A 100  Sat Oct 10 01:20:00 2026
  snapshot-2026-10-10                Dn        0  Sat Oct 10 01:20:00 2026

Related downstream discoveries: inconsistent raw output type (string/Buffer), non-padded filenames, mixed-case DOS directory flags, and directories containing spaces. These are related symptoms of one logical SMB listing correctness problem, not separate feature requests.

Current upstream

At v4.0.0 / current main, src/lib/adapters/storage/smb.ts uses client.list(currentDir + "/*") for recursive listing and does not recover rows omitted by the library parser.

Proposed upstream-compatible fix

  1. Normalize enumeration to a properly scoped current directory so names containing spaces are not interpreted as a glob/path outside the intended listing.
  2. Recover otherwise omitted entries from the same smbclient directory output using a conservative right-anchored parser, retaining only syntactically valid rows.
  3. Merge parsed entries by exact filename with ordinary list() output to avoid duplicates, preserving original API shape.
  4. Recognize mixed-case DOS attribute flags and correctly distinguish files from directories.
  5. Preserve existing path-prefix and credential-sanitization boundaries; no Homelab-specific paths or policy.
  6. Include source-level regressions for long filename, partial/empty library listing, directory containing spaces, Dn attributes, and failed raw enumeration.

A maintained downstream has regression coverage for these cases. This issue is intended to converge that single logical patch with upstream rather than submit iterative repair commits as multiple unrelated PRs. A separate issue covers incomplete recursive listings after permission errors (#181), which has different compatibility considerations.

Activity

  1. self-assigned this
    on Oct 10, 2026
  2. changed the title [-]SMB listings may omit long filenames and misparse directory rows[/-] [+][Bug]: SMB listings may omit long filenames and misparse directory rows[/+] on Oct 10, 2026
  3. Skyfay commented on Oct 10, 2026

    @Skyfay
    Owner

    Hey @X1pheR

    Thanks for the report. The problem is real, I could reproduce it against a Samba 4.22 server, but the cause is a bit different from what the issue describes.

    smbclient prints every row as %-30s%7.7s %8.0f %s, so the attribute is right-aligned in 7 characters. samba-client parses that with \s{6,}([A-Z0-9]{1,2})\s+, which drops a row when:

    • the attribute has a lowercase flag, like An or Dn on Windows servers with content indexing turned off. On such a share the listing comes back completely empty.
    • the attribute has three or more flags, like AHS.
    • the name is 30 characters or longer and the attribute has two flags, because only 5 spaces are left in front of it.

    When a folder row is dropped, everything below it is missing too.

      h.tar                              AH        5  Sat Oct 10 03:56:09 2026
      Long_hidden_backup_name_2026-10-10_full.tar     AH        5  Sat Oct 10 03:56:09 2026
      Critical_Backups_2026-10-10_01-20-00_full-000.tar      A        5  Sat Oct 10 03:56:09 2026
    

    The first and the last row are found on dev, the second one isn't. So a long name on its own is fine, and smbclient never prints a row with a single space like in your example. Folder names with spaces also work today, since samba-client puts the path in quotes. The Buffer case doesn't happen either, execa returns a string here.

    I left my notes on the fix in #183.

    Thanks :)

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

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions