From 245d8949a3a41604a2eaeab17287051065abdf2b Mon Sep 17 00:00:00 2001 From: Simon Pichugin Date: Mar 01 2020 15:30:25 +0000 Subject: Issue 50920 - cl-dump exit code is 0 even if command fails with invalid arguments Description of problem: When running the cl-dump.pl script with invalid arguments, the exit code is always 0, even if an error message is reported. Fix Description: Pass the return code to the end of the #main. Change CI test accordingly. https://pagure.io/389-ds-base/issue/50920 Reviewed by: vashirov, mreynolds (Thanks!) --- diff --git a/dirsrvtests/tests/suites/replication/changelog_test.py b/dirsrvtests/tests/suites/replication/changelog_test.py index 8d82148..e395f0e 100644 --- a/dirsrvtests/tests/suites/replication/changelog_test.py +++ b/dirsrvtests/tests/suites/replication/changelog_test.py @@ -275,9 +275,7 @@ def test_cldump_files_removed(topo): proc = subprocess.Popen(cmdline, stdout=subprocess.PIPE) msg = proc.communicate() log.info('output message : %s' % msg[0]) - # Waiting for bz1769296 fix, rc=0 is expected, so that the next steps be executed - to be changed when bz fixed. - #assert proc.returncode != 0 - assert proc.returncode == 0 + assert proc.returncode != 0 # Now the core goal of the test case # Using cl-dump without -l option diff --git a/ldap/admin/src/scripts/cl-dump.pl b/ldap/admin/src/scripts/cl-dump.pl index 2e7f204..e56c803 100755 --- a/ldap/admin/src/scripts/cl-dump.pl +++ b/ldap/admin/src/scripts/cl-dump.pl @@ -101,16 +101,17 @@ $version = "Directory Server Changelog Dump - Version 1.0"; } if (!$opt_i) { - &cl_dump_and_decode; + $rc = &cl_dump_and_decode; } elsif ($opt_c) { - &grep_csn ($opt_i); + $rc = &grep_csn ($opt_i); } else { - &cl_decode ($opt_i); + $rc = &cl_decode ($opt_i); } close (OUTPUT); + exit($rc); } # Validate the parameters @@ -209,6 +210,7 @@ sub cl_dump_and_decode &print_header ($replica, "Not Found") if !$gotldif; } $conn->close; + return 0; } sub print_header @@ -260,6 +262,7 @@ sub grep_csn printf OUTPUT "; $modts" if $modts; printf OUTPUT ")\n"; } + return 0; } sub csn_to_string @@ -316,4 +319,5 @@ sub cl_decode /^\s*(\S+)\s*\n/; $encoded .= $1; } + return 0; }