Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

apps/openssl: error messages for unknown command line options are inconsistent #10773

Closed
mspncp opened this issue Jan 7, 2020 · 8 comments
Closed
Labels
triaged: refactor The issue/pr requests/implements refactoring

Comments

@mspncp
Copy link
Contributor

mspncp commented Jan 7, 2020

The error messages for unknown command line options are very inconsistent. Here is an incomplete list of examples, taken from #10132 (comment):

msp@msppc:~/src/openssl$ for cmd in cms ocsp s_client smime ts; do openssl $cmd -verbose ; done

cms: Unrecognized flag verbose
ocsp: Unrecognized flag verbose
ocsp: Use -help for summary.
s_client: Option unknown option -verbose
s_client: Use -help for summary.
smime: Unrecognized flag verbose
smime: Use -help for summary.
ts: Unrecognized flag verbose
ts: Use -help for summary.
@mspncp mspncp added the triaged: refactor The issue/pr requests/implements refactoring label Jan 7, 2020
@mspncp
Copy link
Contributor Author

mspncp commented Jan 7, 2020

A more systematic check using the two scripts

./unknown-args

#!/bin/bash

for cmd in asn1parse ca ciphers cms crl crl2pkcs7 dgst dhparam dsa dsaparam ec ecparam enc engine errstr fipsinstall gendsa genpkey genrsa info kdf list mac nseq ocsp passwd pkcs12 pkcs7 pkcs8 pkey pkeyparam pkeyutl prime provider rand rehash req rsa rsautl s_client s_server s_time sess_id smime speed spkac srp storeutl ts verify version x509 ; do

	util/shlib_wrap.sh apps/openssl $cmd -foobar
done

respectively

./unknown-args-unique

#!/bin/bash

(
	for cmd in asn1parse ca ciphers cms crl crl2pkcs7 dgst dhparam dsa dsaparam ec ecparam enc engine errstr fipsinstall gendsa genpkey genrsa info kdf list mac nseq ocsp passwd pkcs12 pkcs7 pkcs8 pkey pkeyparam pkeyutl prime provider rand rehash req rsa rsautl s_client s_server s_time sess_id smime speed spkac srp storeutl ts verify version x509 ; do

		util/shlib_wrap.sh apps/openssl $cmd -foobar |&  sed "s/\<$cmd\>/cmd/g"
	done
) | sort | uniq

yields that essentially

  1. there are two different types of messages
cmd: Option unknown option -foobar
cmd: Unrecognized flag foobar
  1. the help line is not printed in all cases
cmd: Use -help for summary.

@richsalz
Copy link
Contributor

richsalz commented Jan 7, 2020

This might be more flexible: openssl list --commands -1
:)

@mspncp
Copy link
Contributor Author

mspncp commented Jan 7, 2020

This might be more flexible: openssl list --commands -1
:)

Thanks for the hint, looks much nicer now:

./unknown-args

#!/bin/bash

openssl="util/shlib_wrap.sh apps/openssl"

for cmd in $($openssl list -commands); do
	$openssl $cmd -foobar
done

./unknown-args-unique

#!/bin/bash

openssl="util/shlib_wrap.sh apps/openssl"

(
	for cmd in $($openssl list -commands); do
	$openssl $cmd -foobar |&  sed "s/\<$cmd\>/cmd/g"
	done
) | sort | uniq

@richsalz
Copy link
Contributor

richsalz commented Jan 7, 2020

Adding "-c" to the unique shows 35 "unknown option" and 17 "unrecognized flag"

@mspncp
Copy link
Contributor Author

mspncp commented Jan 7, 2020

I prefer "option", too. But note that the current formulation is not grammatically correct:

cmd: Option unknown option -foobar

My suggestion:

cmd: unknown option: -foobar

@richsalz
Copy link
Contributor

richsalz commented Jan 7, 2020

I figured it out! It's from the places that try to parse an option as a cipher or digest name! Look at the opt_cipher or opt_md and the places that call it! I think just fixing those functions is the way to fix this.

@mspncp
Copy link
Contributor Author

mspncp commented Jan 7, 2020

I think just fixing those functions is the way to fix this.

Cool! I'll wait for your pr ;-)

@richsalz
Copy link
Contributor

richsalz commented Jan 7, 2020

Done: #10774 :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
triaged: refactor The issue/pr requests/implements refactoring
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants