From: norbert.bizet Date: Mon, 11 Dec 2023 15:23:26 +0000 (-0500) Subject: aws_cloud_driver: Fix #10604 upload() might not exit with correct error code X-Git-Tag: Beta-15.0.1~23 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=87f25a974553fd48b4d88266236cba9a80f531ec;p=thirdparty%2Fbacula.git aws_cloud_driver: Fix #10604 upload() might not exit with correct error code --- diff --git a/bacula/scripts/aws_cloud_driver.in b/bacula/scripts/aws_cloud_driver.in index e598cb529..3ef711336 100755 --- a/bacula/scripts/aws_cloud_driver.in +++ b/bacula/scripts/aws_cloud_driver.in @@ -155,6 +155,7 @@ def upload(): # sort out only exception errors since progress is reported into stderr (yuck!) if err: sys.stderr.write(err) + ret = proc.returncode cmd = ["aws", "s3", "ls", os.path.join(cloud_path, volume, part)] if endpoint_url: cmd += ["--endpoint-url", endpoint_url] @@ -179,7 +180,8 @@ def upload(): # forward out stds logging.info("ls outputing {0}".format(output)) sys.stdout.write(output) - return proc.returncode + ret = ret + proc.returncode + return ret except Exception as e: exc = traceback.format_exception_only(type(e), e)[0] sys.stderr.write(exc) @@ -197,7 +199,6 @@ def move(): proc = Popen( cmd, stdout=PIPE, stderr=PIPE, universal_newlines=True) output,err = proc.communicate() logging.debug("move proc communicate output:{0} , err:{1}".format(output,err)) - ret = proc.returncode if not err: sys.stdout.write("{0}\0".format(local_part)) return 0 @@ -207,6 +208,7 @@ def move(): return 0 logging.error("move got error {0}".format(err)) sys.stderr.write(err) + return proc.returncode except Exception as e: exc = traceback.format_exception_only(type(e), e)[0] sys.stderr.write(exc) diff --git a/bacula/src/stored/generic_driver.c b/bacula/src/stored/generic_driver.c index abde8b341..6cae0bc95 100644 --- a/bacula/src/stored/generic_driver.c +++ b/bacula/src/stored/generic_driver.c @@ -286,6 +286,8 @@ bool generic_driver::init(CLOUD *cloud, POOLMEM *&err) { } /* helper to handler close_bpipe error code */ +/* be.code(stat) extracts the actual error code returned by the driver script */ +/* the pipe-specific errors are concated to the err string */ int handle_error(int stat, POOLMEM *&err) { berrno be;