Bug 14126 - The atomic-rsync script can exit 0 when the operation failed.
Summary: The atomic-rsync script can exit 0 when the operation failed.
Status: RESOLVED FIXED
Alias: None
Product: rsync
Classification: Unclassified
Component: core (show other bugs)
Version: 3.1.3
Hardware: All All
: P5 normal (vote)
Target Milestone: ---
Assignee: Wayne Davison
QA Contact: Rsync QA Contact
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-09-13 22:41 UTC by Chris Brannon
Modified: 2020-04-05 23:24 UTC (History)
0 users

See Also:


Attachments
patch for the issue (379 bytes, patch)
2019-09-13 22:41 UTC, Chris Brannon
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Chris Brannon 2019-09-13 22:41:27 UTC
Created attachment 15469 [details]
patch for the issue

The atomic-rsync script uses the call "exit $?" on a failed system() invocation.
$? is a 16-bit wait status, and exit() expects an 8-bit integer.
The lower 16 bits are used as the exit status.

For instance, if the called program exits 1, $? is 256, with 1 in the high 8 bits.
In this situation atomic-rsync exits 0, but the operation failed.

I made a patch.  Now it just exits 1 without trying to pass the child's status.
Comment 1 Paul Slootman 2019-09-17 07:35:15 UTC
Why not exit with $? >> 8?
Comment 2 Chris Brannon 2019-09-17 22:55:05 UTC
(In reply to Paul Slootman from comment #1)
That was, in fact, my first try.
exit $? >> 8 is recommended for Perl by some sources on the net.  However, if the called program gets a signal, "exit $? >> 8" would cause
atomic-rsync to exit 0, which is also not the right thing.

There are other correct solutions to this problem, but I think the simplest and most expedient is exit 1, especially given that atomic-rsync has been exiting 0 under failure conditions.
Comment 3 Wayne Davison 2020-04-05 23:24:34 UTC
Thanks! Fixed in git.