Merge ~ahasenack/ubuntu/+source/backuppc:xenial-backuppc-smb-1576187 into ubuntu/+source/backuppc:ubuntu/xenial-devel

Proposed by Andreas Hasenack
Status: Merged
Approved by: Christian Ehrhardt 
Approved revision: ac8f8ab77a1afa939853b9d572a9a5daed37deb8
Merged at revision: 704c86a0699ce75b918440a65d272e7d783a0232
Proposed branch: ~ahasenack/ubuntu/+source/backuppc:xenial-backuppc-smb-1576187
Merge into: ubuntu/+source/backuppc:ubuntu/xenial-devel
Diff against target: 204 lines (+167/-0)
5 files modified
debian/changelog (+8/-0)
debian/patches/smb-compat-fix.patch (+66/-0)
debian/rules (+1/-0)
debian/tests/control (+3/-0)
debian/tests/smb-backup (+89/-0)
Reviewer Review Type Date Requested Status
Christian Ehrhardt  (community) Approve
Canonical Server Pending
Canonical Server Core Reviewers Pending
Review via email: mp+356880@code.launchpad.net

Description of the change

This branch applies the fix that upstream chose for #1576187. This is different from what was applied in debian (which is what we have in bionic and later), but also fixes the problem, and in a better way we believe.

While writing up the testing instructions, I realized these could be easily scripted, and as such I'm also adding a simple samba-based DEP8 test to this package. This test actually exercises the present bug, so if it's run with the package without the fix, it will correctly fail.

The same dep8 test can and will be added to cosmic+1 once it opens (see https://bugs.launchpad.net/ubuntu/+source/backuppc/+bug/1677755).

Testing instructions are provided in the bug, but they are the same as the newly added DEP8 test, which you can run manually if you want.

Bileto ticket: https://bileto.ubuntu.com/#/ticket/3487
PPA: sudo add-apt-repository ppa:ci-train-ppa-service/3487

UPDATE: the dep8 tests are stuck in bileto and I don't know why, but they run locally just fine.

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

Nice data digging to get to the log :-)
+1 on adding the test along the fix.
This would also make it catch other simmilar issues further on with the tool relying on output "a lot"

Minor optional changes inline, but +1 on the MP as is if you want to keep it that way.

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

It looks better above indeed, thanks.

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

Tagged and uploaded.

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

Sorry, I missed the comment about the /public contents.

I wrote this in IRC as a reply:
<andreas> I had it copying /usr/bin earlier, then /sbin, and had an issue with symlinks, that's why i switched to /etc
<andreas> I wondered about touching files, but I wanted more content, something more than just empty files, then I thought about creating some random ones and dd-fill them with garbage, but it started getting over engineered I thought

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

Please take another look, I'm now creating a set of random files for the backup test.

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

I will squash that change later, and I checked with #ubuntu-release that I can reuse the package's version/release.

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

Totally like it now, there is one further improvement on the file creation that I sugegsted inline.
Up to you to implement it or call it good-as-is - you have my approval either way.

review: Approve
Revision history for this message
Andreas Hasenack (ahasenack) :
Revision history for this message
Christian Ehrhardt  (paelzer) wrote :

+1 on the new file creation - thanks

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

What is going on with armhf?

I wondered if samba doesn't even start fine there, but conf/config.pl:1669 looks as this would be a real basic ping that fails.
Would we need (want) to bump all sorts of timeouts for armhf to have a reliable chance to succeed?

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

I'll add the verbose option to see if it helps diagnose the problem.

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

I'm gonna need a live armhf system for this I think:
Performing a full backup
+ result=0
+ echo Performing a full backup
+ sudo -u backuppc -H /usr/share/backuppc/bin/BackupPC_dump -v -f localhost
cmdSystemOrEval: about to system -c 1 localhost
cmdSystemOrEval: finished: got output Exec of -c 1 localhost failed

CheckHostAlive: first ping failed (256, )
+ result=1
+ check_status 1 Full backup
+ local status_code=1
+ local msg=Full backup
+ [ 1 -ne 0 ]
+ echo ERROR: Full backup failed, exit status was 1

also just saw a permission problem that I will examine and fix:
...
Domain=[WORKGROUP] OS=[Windows 6.1] Server=[Samba 4.3.11-Ubuntu]
tar:316 tarmode is now full, system, hidden, noreset, quiet
tar:957 NT_STATUS_ACCESS_DENIED opening remote file \tmp.O95gzO
tar:957 NT_STATUS_ACCESS_DENIED opening remote file \tmp.PUgM2b

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

Oh, check this out.

Non-arm:
+ sudo -u backuppc -H /usr/share/backuppc/bin/BackupPC_dump -v -f localhost
cmdSystemOrEval: about to system /bin/ping -c 1 localhost

Arm:
+ sudo -u backuppc -H /usr/share/backuppc/bin/BackupPC_dump -v -f localhost
cmdSystemOrEval: about to system -c 1 localhost

What's missing in the arm case? :)

Tracking down the missing ping command.

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

Got it, for some reason on the armh system it thought it needed to use ping6, for ipv6. Configuring that for the test case fixed it:

cmdSystemOrEval: about to system /bin/ping6 -c 1 localhost

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

This now contains all the latest changes.

Updated bileto ticket: https://bileto.ubuntu.com/#/ticket/3487

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

Thanks for sorting out the arm issue. I like this. As usual also remember to submit the test to Debian. But on the SRU which would make it check future regressions it really is nice.

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

Tagged and uploaded.

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

Submitted to Debian at https://salsa.debian.org/debian/backuppc/merge_requests/1

That git repo seems active, so I don't think I need to file a bug to get their attention.

For Debian, I had to add sudo to the dependency list in debian/tests/control. It's a no-op for ubuntu, and we can adopt that too if they merge.

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 22544b2..57c9e13 100644
3--- a/debian/changelog
4+++ b/debian/changelog
5@@ -1,3 +1,11 @@
6+backuppc (3.3.1-2ubuntu3.4) xenial; urgency=medium
7+
8+ * d/rules, d/p/smb-compat-fix.patch: cope with changes in newer smbclient.
9+ Thanks to Maksym Schipka <maksym@hotmail.com> (LP: #1576187)
10+ * d/t/{control,smb-backup}: simple smb-based DEP8 test (LP: #1677755)
11+
12+ -- Andreas Hasenack <andreas@canonical.com> Tue, 16 Oct 2018 17:58:38 -0300
13+
14 backuppc (3.3.1-2ubuntu3.3) xenial; urgency=medium
15
16 * Fix debian/rules so the patch is actually applied. (LP: #1612600)
17diff --git a/debian/patches/smb-compat-fix.patch b/debian/patches/smb-compat-fix.patch
18new file mode 100644
19index 0000000..b436970
20--- /dev/null
21+++ b/debian/patches/smb-compat-fix.patch
22@@ -0,0 +1,66 @@
23+From d7a8403b537ed0068e862abc20065e98209527b7 Mon Sep 17 00:00:00 2001
24+From: Maksym Schipka <maksym@hotmail.com>
25+Date: Sun, 14 Aug 2016 09:24:52 +0100
26+Subject: [PATCH] Fixing compatibility with Samba 4.3
27+Origin: https://github.com/backuppc/backuppc/commit/c550528be63c3b66744830e992b908fff3f2e271
28+Bug: https://github.com/backuppc/backuppc/issues/21
29+Bug-Ubuntu: https://bugs.launchpad.net/ubuntu/+source/backuppc/+bug/1576187
30+Bug-Debian: https://bugzilla.samba.org/show_bug.cgi?id=11642
31+Last-Update: 2018-10-16
32+
33+---
34+ bin/BackupPC_dump | 2 ++
35+ lib/BackupPC/Xfer/Smb.pm | 13 ++++++++++++-
36+ 2 files changed, 14 insertions(+), 1 deletion(-)
37+diff --git a/bin/BackupPC_dump b/bin/BackupPC_dump
38+index 9491046..e41cb68 100755
39+--- debian/backuppc/usr/share/backuppc/bin/BackupPC_dump
40++++ debian/backuppc/usr/share/backuppc/bin/BackupPC_dump
41+@@ -873,6 +873,8 @@ for my $shareName ( @$ShareNames ) {
42+ # Merge the xfer status (need to accumulate counts)
43+ #
44+ my $newStat = $xfer->getStats;
45++ # MAKSYM 14082016: forcing the right file count if some bytes were transferred; ensures compatibility with at least Samba-4.3
46++ $newStat->{fileCnt} = $nFilesTotal if ( $useTar && $newStat->{fileCnt} == 0 && $xfer->getStats->{byteCnt} > 0 );
47+ if ( $newStat->{fileCnt} == 0 ) {
48+ $noFilesErr ||= "No files dumped for share $shareName";
49+ }
50+diff --git a/lib/BackupPC/Xfer/Smb.pm b/lib/BackupPC/Xfer/Smb.pm
51+index eaf002e..48964cb 100644
52+--- debian/backuppc/usr/share/backuppc/lib/BackupPC/Xfer/Smb.pm
53++++ debian/backuppc/usr/share/backuppc/lib/BackupPC/Xfer/Smb.pm
54+@@ -217,6 +217,8 @@ sub readOutput
55+ # This section is highly dependent on the version of smbclient.
56+ # If you upgrade Samba, make sure that these regexp are still valid.
57+ #
58++ # MAKSYM 14082016: The next regex will never match on Samba-4.3, as
59++ # smbclient doesn't produce output required; keeping it for older Sambas
60+ if ( /^\s*(-?\d+) \(\s*\d+[.,]\d kb\/s\) (.*)$/ ) {
61+ my $sambaFileSize = $1;
62+ my $pcFileName = $2;
63+@@ -230,8 +232,15 @@ sub readOutput
64+ $t->{byteCnt} += $2;
65+ $t->{fileCnt}++;
66+ $t->{XferLOG}->write(\"$_\n") if ( $t->{logLevel} >= 1 );
67+- } elsif ( /^\s*tar: dumped \d+ files/ ) {
68++ } elsif ( /^\s*tar: dumped (\d+) files/) {
69++ # MAKSYM 14082016: Updating file count to the likely number
70+ $t->{xferOK} = 1;
71++ $t->{fileCnt} = $1;
72++ $t->{XferLOG}->write(\"$_\n") if ( $t->{logLevel} >= 0 );
73++ } elsif ( /^\s*tar:\d+\s*Total bytes received: (\d+)/) {
74++ # MAKSYM 14082016: Updating byte count to the likely number
75++ $t->{xferOK} = 1;
76++ $t->{byteCnt} = $1;
77+ $t->{XferLOG}->write(\"$_\n") if ( $t->{logLevel} >= 0 );
78+ } elsif ( /^\s*tar: restored \d+ files/ ) {
79+ $t->{xferOK} = 1;
80+@@ -270,6 +279,8 @@ sub readOutput
81+ } elsif ( /^\s*directory \\/i ) {
82+ $t->{XferLOG}->write(\"$_\n") if ( $t->{logLevel} >= 2 );
83+ } elsif ( /smb: \\>/
84++ || /^\s*tar:\d+/ # MAKSYM 14082016: ignoring 2 more Samba-4.3 specific lines
85++ || /^\s*WARNING:/i
86+ || /^\s*added interface/i
87+ || /^\s*tarmode is now/i
88+ || /^\s*Total bytes written/i
89diff --git a/debian/rules b/debian/rules
90index 051c1ba..7077ff7 100755
91--- a/debian/rules
92+++ b/debian/rules
93@@ -81,6 +81,7 @@ install: build
94 rm -rf debian/backuppc/etc/backuppc/config.pl
95 patch --no-backup-if-mismatch -p0 < debian/patches/escape-braces-in-perl-regex.diff
96 patch --no-backup-if-mismatch -p0 < debian/patches/setuid.patch
97+ patch --no-backup-if-mismatch -p0 < debian/patches/smb-compat-fix.patch
98
99 # Build architecture-independent files here.
100 binary-indep: build install
101diff --git a/debian/tests/control b/debian/tests/control
102new file mode 100644
103index 0000000..c07f175
104--- /dev/null
105+++ b/debian/tests/control
106@@ -0,0 +1,3 @@
107+Tests: smb-backup
108+Depends: @, samba, smbclient
109+Restrictions: isolation-container, allow-stderr, needs-root
110diff --git a/debian/tests/smb-backup b/debian/tests/smb-backup
111new file mode 100644
112index 0000000..7ec3f21
113--- /dev/null
114+++ b/debian/tests/smb-backup
115@@ -0,0 +1,89 @@
116+#!/bin/sh
117+
118+set -ex
119+
120+check_status() {
121+ local status_code=$1
122+ local msg="${2:-task}"
123+
124+ if [ "$status_code" -ne "0" ]; then
125+ echo "ERROR: $msg failed, exit status was $status_code"
126+ exit "$status_code"
127+ else
128+ echo "OK: $msg succeeded"
129+ fi
130+}
131+
132+populate_directory() {
133+ local target="$1"
134+ local tempfile
135+
136+ # target must exist and be a directory
137+ test -d "$target" || exit 1
138+
139+ for n in $(seq 1 10); do
140+ tempfile=$(mktemp "$target/tmp.XXXXXX")
141+ # the date command makes each tempfile different
142+ # the seq command just produces a lot of output
143+ # using a "here" document as to not pollute the set -x
144+ # output with large command lines
145+ cat > "$tempfile" <<EOF
146+$(date +%s%N)
147+$(seq 1 81920)
148+EOF
149+ chmod 0644 "$tempfile"
150+ done
151+}
152+
153+add_samba_share() {
154+ if ! testparm -s 2>&1 | grep -qE "^\[public\]"; then
155+ echo "Adding [public] share"
156+ cat >> /etc/samba/smb.conf <<EOFEOF
157+[public]
158+ path = /public
159+ read only = no
160+ guest ok = yes
161+EOFEOF
162+ service smbd reload
163+ else
164+ echo "No need to add [public] share, continuing."
165+ fi
166+ echo "Populating share"
167+ rm -rf /public
168+ mkdir -p /public
169+ chmod 1777 /public
170+ populate_directory /public
171+}
172+
173+add_localhost_backuppc_config() {
174+ cat > /etc/backuppc/localhost.pl <<EOFEOF
175+\$Conf{XferMethod} = 'smb';
176+\$Conf{XferLogLevel} = 1;
177+\$Conf{ClientCharset} = '';
178+\$Conf{ClientCharsetLegacy} = 'iso-8859-1';
179+\$Conf{SmbShareName} = 'public';
180+\$Conf{SmbShareUserName} = '';
181+\$Conf{SmbSharePasswd} = '';
182+\$Conf{PingPath} = '/bin/ping';
183+\$Conf{Ping6Path} = '/bin/ping6';
184+EOFEOF
185+}
186+
187+echo "Adding samba share"
188+add_samba_share
189+
190+echo "Configuring backuppc"
191+add_localhost_backuppc_config
192+
193+result=0
194+echo "Performing a full backup"
195+sudo -u backuppc -H /usr/share/backuppc/bin/BackupPC_dump -v -f localhost || result=$?
196+check_status $result "Full backup"
197+
198+result=0
199+echo "Changing share content and performing an incremental backup"
200+populate_directory /public
201+sudo -u backuppc -H /usr/share/backuppc/bin/BackupPC_dump -v -i localhost || result=$?
202+check_status $result "Incremental backup"
203+
204+echo "Done."

Subscribers

People subscribed via source and target branches