Hide Forgot
Description of problem: For subscription-manager cli consistency, a failed command should return an exitCode of 255 and the error message in stderr Steps to Reproduce / Actual results: # subscription-manager import --certificate=FOO 1>/dev/null # echo $? 0 ^^^ THAT EXIT CODE SHOULD BE 255 AND THE ERROR MESSAGE SHOULD BE RETURNED TO STDERR (THE ERROR MESSAGE IS CURRENTLY GOING TO STDOUT) Expected results: # subscription-manager import --certificate=FOO 1>/dev/null FOO is not a valid certificate file. Please use a valid certificate. # echo $? 255 Version-Release number of selected component (if applicable): [root@jsefler-onprem-62server ~]# rpm -q subscription-manager subscription-manager-0.96.7-1.git.14.c203b16.el6.x86_64
What commands get you a 255?
(In reply to comment #1) > What commands get you a 255? Well then... * an exit code of 1 would probably be more appropriate as suggested by http://www.daniweb.com/software-development/python/threads/31226/163923#post163923 * and the feedback message, "FOO is not a valid certificate file. Please use a valid certificate.", should probably be written to stdout
Committed ddad607b1d46795122c57467f6653918e6b16116 In subscription-manager 0.99.4+
The code should now process all arguments but return a 1 if any of the arguments failed validation. E.g. # subscription-manager import --certificate=GOOD --certificate=BAD Successfully imported certificate GOOD BAD is not a valid certificate file. Please use a valid certificate. # echo $? 1
Correction: As of 62c62cc98d2708225444713b61b6067f8555753b (0.99.6+), the code will return a 1 only if *all* arguments fail. This change was made to make the return code behavior consistent with how subscription-manager subscribe works.
Verifying Version... [root@jsefler-r63-server ~]# rpm -q subscription-manager subscription-manager-0.99.7-1.git.0.8137c52.el6.x86_64 [root@jsefler-r63-server ~]# subscription-manager import --certificate=FOO 1>/tmp/stdout 2>/tmp/stderr [root@jsefler-r63-server ~]# echo $? 1 [root@jsefler-r63-server ~]# cat /tmp/stdout FOO is not a valid certificate file. Please use a valid certificate. [root@jsefler-r63-server ~]# cat /tmp/stderr [root@jsefler-r63-server ~]# ^^^^^^^^ VERIFIED - importing a bad cert throws an exit code of 1 with stdout message [root@jsefler-r63-server ~]# subscription-manager import --certificate=/tmp/sm-importEntitlementsDir/6871632671492179691-key.pem --certificate=/tmp/sm-importCertificatesDir/cert.pem --certificate=/tmp/sm-importCertificatesDir/8003202248817161227.pem --certificate=/tmp/nonExistentFile.pem 1>/tmp/stdout 2>/tmp/stderr [root@jsefler-r63-server ~]# echo $? 0 [root@jsefler-r63-server ~]# cat /tmp/stdout 6871632671492179691-key.pem is not a valid certificate file. Please use a valid certificate. cert.pem is not a valid certificate file. Please use a valid certificate. Successfully imported certificate 8003202248817161227.pem nonExistentFile.pem is not a valid certificate file. Please use a valid certificate. [root@jsefler-r63-server ~]# cat /tmp/stderr [root@jsefler-r63-server ~]# ^^^^^^^^ VERIFIED - importing a mix of good/bad certs throws an exit code of 0 (as designed in comment 6) with stdout messages
Since the problem described in this bug report should be resolved in a recent advisory, it has been closed with a resolution of ERRATA. For information on the advisory, and where to find the updated files, follow the link below. If the solution does not work for you, open a new bug report. http://rhn.redhat.com/errata/RHBA-2012-0804.html