Project

General

Profile

Bug #10488

maildir on !bash is fubar

Added by Guillaume about 2 years ago. Updated over 1 year ago.

Status:
Confirmed
Priority:
Normal
Assignee:
-
Category:
maildir handler
Target version:
-
Start date:
11/05/2015
Due date:
% Done:

0%

QA Check:

Description

Yeah, I was checking custom backups I made for a client and it kept writing over the daily.1 directory. I traced down the code to realize that there is some weird bashism that was crashing on dash (prolly since that time where bash got 0wned), that made backup just "write over the old one".

You can fix via:
https://paste.debian.net/324057/

I hacked the patch by hand on concerned servers, but it is nice to check that we aren't all not having as much backups as we thought we would.

History

#1 Updated by micah about 2 years ago

This is the patch from the pastebin, because that one will expire

--- a/handlers/maildir.in
+++ b/handlers/maildir.in
@@ -178,7 +178,7 @@ function do_rotate() {
       oldest=\`find $backuproot -maxdepth 1 -type d -name \$rottype'.*' | @SED@ 's/^.*\.//' | sort -n | tail -1\`
       #echo "Debug: oldest \$oldest" 
       [ "\$oldest" == "" ] && oldest=0
-      for (( i=\$oldest; i > 0; i-- )); do
+      for i in $(seq 1 $oldest); do
          if [ -d \$dir.\$i ]; then
             if [ -f \$dir.\$i/created ]; then
                created=\`tail -1 \$dir.\$i/created\`

#2 Updated by intrigeri about 2 years ago

backupninja is full of bashisms, and explicitly declares in its shebang that it must be run with bash. I'm not aware of any ongoing effort to port it to POSIX shell.

#3 Updated by Guillaume about 2 years ago

Hi intri,

I'm not suggesting that we posixify all of backupninja, but that piece of code is part of a script that is executed on the server side (starting on line 151), that doesn't not contain #!/bin/bash on top of itself. So if sh is used on a client, basically "rotation just doesn't happen and fails silently". So either we fix this one line, or we specify the shebang on line 151, but I think this can cause to silently break running backups if a server changes from using /bin/bash by default to /bin/sh (which is our case).

G

#4 Updated by intrigeri about 2 years ago

OK, got it. Thanks for clarifying! :)

#5 Updated by intrigeri over 1 year ago

  • Category set to maildir handler
  • Status changed from New to Confirmed
  • Priority changed from High to Normal

Also available in: Atom PDF