Bug 15229 - Regression: smbclient tar 'r' option excludes broken
Summary: Regression: smbclient tar 'r' option excludes broken
Status: NEW
Alias: None
Product: Samba 4.1 and newer
Classification: Unclassified
Component: Tools (show other bugs)
Version: 4.17.1
Hardware: All All
: P5 normal (vote)
Target Milestone: ---
Assignee: Samba QA Contact
QA Contact: Samba QA Contact
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-11-08 10:02 UTC by main.haarp
Modified: 2025-09-29 02:47 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description main.haarp 2022-11-08 10:02:01 UTC
Hello,

after upgrading my distro I notice that smbclient excludes have broken. The issue was traced to the tar 'r' option. It broke somewhere between 4.9.5 and 4.13.13. While the manpage considers the option deprecated:

> r - Use wildcard matching to include or exclude. Deprecated.

It is still present and actively used by other software, such as BackupPC. See https://github.com/backuppc/backuppc/issues/252

The results of using the 'r' option are unusual. Most excludes without wildcards do not work. Excludes for files on the root dir anchored with `//` or `\\` do work. Excludes with wildcards in them mostly do work, but only if anchored with `//` or `\\`. In short: things are inconsistent and broken.

Bisecting samba reveals https://gitlab.com/samba-team/samba/-/commit/d2d5007936ba4f48edad61c7613bed07c31da463 to be the culprit (related: bug 11642). I'm CCing the author.

Some test cases:

Doesn't work: smbclient '\\wsfoo\C' -U user%pw -E -d 1 -c 'tarmode full' -mSMB3 -TcrX - //foo
Does work: smbclient '\\wsfoo\C' -U user%pw -E -d 1 -c 'tarmode full' -mSMB3 -TcrX - //foo/*
Does work if foo is a file: smbclient '\\wsfoo\C' -U user%pw -E -d 1 -c 'tarmode full' -mSMB3 -TcrX - //foo
Doesn't work: smbclient '\\wsfoo\C' -U user%pw -E -d 1 -c 'tarmode full' -mSMB3 -TcrX - */foo


Thanks!
Comment 1 main.haarp 2025-09-29 02:24:46 UTC
Hey Samba team, any news on this?


Upon further testing, I think I figured out when excludes work if wildcards are enabled. (note: I'm using forward slashes throughout)

- The exclude needs to start with `//`, unless it starts with a wildcard
- The exclude must not end with a trailing slash
- The exclude must not end with a directory - except when the directory name *ends* with a wildcard!

So these work:

- //haarp/Downloads/*
- //haarp/Down*
- //h*/Downloads/*
- //*/*loads/*
- *aarp/*loads/*
- */*loads/*

These do not work:

- haarp/Downloads/*
- h*/Downloads/*
- //haarp/Downloads/
- //haarp/Downloads
- //haarp/Down*/
- //haarp/*loads/
Comment 2 main.haarp 2025-09-29 02:26:02 UTC
Forgot to mention: This was now tested on smbclient Version 4.22.4-Debian-4.22.4+dfsg-1~deb13u1.