Merge ~ahasenack/ubuntu/+source/samba:cosmic-samba-rmdir-1795772 into ubuntu/+source/samba:ubuntu/devel

Proposed by Andreas Hasenack
Status: Merged
Approved by: Andreas Hasenack
Approved revision: ce0fe6a620fc88cb9b138fec72218137e70db2eb
Merged at revision: ce0fe6a620fc88cb9b138fec72218137e70db2eb
Proposed branch: ~ahasenack/ubuntu/+source/samba:cosmic-samba-rmdir-1795772
Merge into: ubuntu/+source/samba:ubuntu/devel
Diff against target: 79 lines (+57/-0)
3 files modified
debian/changelog (+8/-0)
debian/patches/fix-rmdir.patch (+48/-0)
debian/patches/series (+1/-0)
Reviewer Review Type Date Requested Status
Christian Ehrhardt  (community) Approve
Canonical Server Pending
Canonical Server Core Reviewers Pending
Review via email: mp+356356@code.launchpad.net

Description of the change

This MP is superseeding Karl's one at https://code.launchpad.net/~kstenerud/ubuntu/+source/samba/+git/samba/+merge/356153, since he won't be able to finish that work before final freeze.

Bileto ticket: https://bileto.ubuntu.com/#/ticket/3463
PPA (still building): ppa:ci-train-ppa-service/3463

This branch fixes the case where rmdir fails to remove a non-empty directory but returns successfully, indicating to the caller that all went well. It's a bug in the library and affects many client tools, like smbclient and GUI file browsers.

Testing instructions, taken from Karl's work:
# lxc launch ubuntu-daily:cosmic sambatest
# lxc exec sambatest bash

# apt update
# apt dist-upgrade -y
# apt install -y samba samba-client
# mkdir -p /tmp/shared/testdir/testsubdir
# chown -R nobody:nogroup /tmp/shared
# printf "%s" "[global]
    workgroup = WORKGROUP
    server role = standalone server
    security = user
    map to guest = Bad User
    guest ok = yes
    guest only = yes
    guest account = nobody
[shared]
    path = /tmp/shared
    writable = yes
    browsable = yes
    guest ok = yes
" | tee "/etc/samba/smb.conf" >/dev/null
# service smbd restart
# CLI_FORCE_INTERACTIVE=yes smbclient -U " "%" " //localhost/shared <<EOF
rmdir testdir
quit
EOF

* This will not report an error, but it should.

With the updated packages, the smbclient call will correctly report that the directory is not empty.

To post a comment you must log in.
Revision history for this message
Andreas Hasenack (ahasenack) wrote :

Only gvfs failed on s390x so far, all other dep8 tests passed. I clicked retry, let's see tomorrow.

Revision history for this message
Christian Ehrhardt  (paelzer) wrote :

Don't care about s390x GVFS andreas
=> http://autopkgtest.ubuntu.com/packages/g/gvfs/cosmic/s390x

And
ubuntu-release:61:force-badtest gvfs/1.36.1-0ubuntu3/ppc64el gvfs/1.36.1-0ubuntu3/s390x gvfs/1.38.0-2ubuntu2/s390x

So consider the tests to be good.

Revision history for this message
Christian Ehrhardt  (paelzer) wrote :

Also the MP LGTM

Revision history for this message
Christian Ehrhardt  (paelzer) wrote :

Tested from the PPA:
- testcase is fine
- also works if the subelements are files instead of dirs
- rmdir woorks as expected if the dir is empty

Overall +1

review: Approve
Revision history for this message
Andreas Hasenack (ahasenack) wrote :

Thanks, tagged and uploaded

Update scan failed

At least one of the branches involved have failed to scan. You can manually schedule a rescan if required.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/debian/changelog b/debian/changelog
2index cbab972..2c638a4 100644
3--- a/debian/changelog
4+++ b/debian/changelog
5@@ -1,3 +1,11 @@
6+samba (2:4.8.4+dfsg-2ubuntu2) cosmic; urgency=high
7+
8+ [ Karl Stenerud ]
9+ * d/p/fix-rmdir.patch: Fix to make the samba client library report
10+ directory-not-empty errors (LP: #1795772)
11+
12+ -- Andreas Hasenack <andreas@canonical.com> Tue, 09 Oct 2018 14:32:16 -0300
13+
14 samba (2:4.8.4+dfsg-2ubuntu1) cosmic; urgency=medium
15
16 * Merge with Debian unstable (LP: #1778125). Remaining changes:
17diff --git a/debian/patches/fix-rmdir.patch b/debian/patches/fix-rmdir.patch
18new file mode 100644
19index 0000000..2a03d5b
20--- /dev/null
21+++ b/debian/patches/fix-rmdir.patch
22@@ -0,0 +1,48 @@
23+Description: Explicitly set delete_on_close token for rmdir
24+
25+The current implementation of `rmdir` hopes to get the directory deleted
26+on closing last open handle when FILE_DELETE_ON_CLOSE is set on it. But
27+for non-empty directories Windows doesn't error out during an open call.
28+Following that we internally refuse to set initial delete_on_close while
29+opening a non-empty directory. This prevents us from trying to delete
30+the directory when last open handle is closed.
31+
32+Instead of relying on FILE_DELETE_ON_CLOSE during an open we explicitly
33+set delete_on_close token on directory handle once it is available. This
34+ensures that NT_STATUS_DIRECTORY_NOT_EMPTY is returned for `rmdir` on
35+non-empty directories while closing open directory handle.
36+
37+Author: Anoop C S <anoopcs@redhat.com>
38+Origin: upstream, https://github.com/samba-team/samba/commit/6b68e3eca631c04d6d57c489daf60f64732fc86d
39+Bug: https://bugzilla.samba.org/show_bug.cgi?id=13204
40+Bug-Ubuntu: https://bugs.launchpad.net/ubuntu/+source/samba/+bug/1795772
41+Last-Update: 2018-10-09
42+---
43+This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
44+diff --git a/source3/libsmb/cli_smb2_fnum.c b/source3/libsmb/cli_smb2_fnum.c
45+index c397b29b3..7b2f39c02 100644
46+--- a/source3/libsmb/cli_smb2_fnum.c
47++++ b/source3/libsmb/cli_smb2_fnum.c
48+@@ -682,7 +682,7 @@ NTSTATUS cli_smb2_rmdir(struct cli_state *cli, const char *dname)
49+ FILE_ATTRIBUTE_DIRECTORY, /* file attributes */
50+ FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_SHARE_DELETE, /* share_access */
51+ FILE_OPEN, /* create_disposition */
52+- FILE_DIRECTORY_FILE|FILE_DELETE_ON_CLOSE, /* create_options */
53++ FILE_DIRECTORY_FILE, /* create_options */
54+ &fnum,
55+ NULL);
56+
57+@@ -710,6 +710,13 @@ NTSTATUS cli_smb2_rmdir(struct cli_state *cli, const char *dname)
58+ if (!NT_STATUS_IS_OK(status)) {
59+ return status;
60+ }
61++
62++ status = cli_smb2_delete_on_close(cli, fnum, true);
63++ if (!NT_STATUS_IS_OK(status)) {
64++ cli_smb2_close_fnum(cli, fnum);
65++ return status;
66++ }
67++
68+ return cli_smb2_close_fnum(cli, fnum);
69+ }
70+
71diff --git a/debian/patches/series b/debian/patches/series
72index c3ca4c2..28d241e 100644
73--- a/debian/patches/series
74+++ b/debian/patches/series
75@@ -9,3 +9,4 @@ heimdal-rfc3454.txt
76 Fix-pidl-manpage-sections.patch
77 Fix-spelling.patch
78 Improve-vfs_linux_xfs_sgid-manpage.patch
79+fix-rmdir.patch

Subscribers

People subscribed via source and target branches