-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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
8272163: Add -version option to keytool and jarsigner #5954
Conversation
👋 Welcome back hchao! A progress list of the required criteria for merging this PR into |
@haimaychao The following labels will be automatically applied to this pull request:
When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing lists. If you would like to change these labels, use the /label pull request command. |
Webrevs
|
/remove label compiler |
/remove label core-libs |
@AlanBateman Unknown command |
@AlanBateman Unknown command |
/label remove core-libs |
@AlanBateman |
/label remove compiler |
@haimaychao |
/csr |
This will also need a CSR so I added the csr label. |
@seanjmullan this pull request will not be integrated until the CSR request JDK-8275174 for issue JDK-8272163 has been approved. |
usageTooManyArg(); | ||
} | ||
doPrintVersion(); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What happens if -version
appears elsewhere?
I tried some other commands. When both -version
and other arguments are provided, java
ignores the others and prints out version info. javac
prints out the version info and compiles as well.
It's possible that user writes a script or alias that always run the tool with some options (Ex: -keystore
, -storepass
, -verbose
). Maybe we should not fail if -version
is used with other options (no matter at the beginning or the end).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed so -version
can be used with other options in jarsigner.
@@ -591,17 +597,30 @@ static void usageNoArg() { | |||
usage(); | |||
} | |||
|
|||
static void usageTooManyArg() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since the method is only for -version
and the printed message also mentions "version", maybe it's better to choose a specific name.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed this method after the change for the comment as above.
@@ -591,17 +597,30 @@ static void usageNoArg() { | |||
usage(); | |||
} | |||
|
|||
static void usageTooManyArg() { | |||
System.out.println(rb.getString( | |||
"Option.should.not.be.specified.for.version")); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Neither arguments not options should be specified here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Method was removed.
.shouldContain("jarsigner") | ||
.shouldHaveExitValue(0); | ||
|
||
SecurityTools.jarsigner("-version -extraopt") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You might want to use some legal arguments here, for example, -version -help
. Otherwise, the error might be because the extra option is not supported. Or, you can check if an expected error message is printed out.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated the test as suggested.
.shouldContain("keytool") | ||
.shouldHaveExitValue(0); | ||
|
||
SecurityTools.keytool("-version -extraopt") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same comment as above.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
For the CSR, is it necessary to list the |
@wangweij Thanks for your review! Regarding your CSR comment if it is necessary to list the |
@@ -308,6 +309,10 @@ public void run(String args[]) { | |||
Event.clearReportListener(Event.ReporterCategory.CRLCHECK); | |||
} | |||
|
|||
if (version) { | |||
doPrintVersion(); | |||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So if both -version
and file.jar
are provided, jarsigner will both sign the jar and print the version. This is probably OK but I prefer the java
style that only prints the version.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, change made to have jarsigner to only print the version and ignore other options.
Approved the PR. Thanks. I have a small comment on the CSR. |
@wangweij Thanks for reviewing the CSR and code changes. |
@wangweij Updated the CSR with your comment. Thanks! |
@haimaychao This change now passes all automated pre-integration checks. ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details. After integration, the commit message for the final commit will be:
You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed. At the time when this comment was updated there had been 146 new commits pushed to the
As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this automatic rebasing, please check the documentation for the /integrate command for further details. ➡️ To integrate this PR with the above commit message to the |
/integrate |
Going to push as commit fec470f.
Your commit was automatically rebased without conflicts. |
@haimaychao Pushed as commit fec470f. 💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored. |
It'd be useful to have a -version option for keytool and jarsigner. Many other JDK tools already have a -version option. This is to add -version option to keytool and jarsigner like jar command does.
CSR review:
https://bugs.openjdk.java.net/browse/JDK-8275174
Progress
Issue
Reviewers
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.java.net/jdk pull/5954/head:pull/5954
$ git checkout pull/5954
Update a local copy of the PR:
$ git checkout pull/5954
$ git pull https://git.openjdk.java.net/jdk pull/5954/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 5954
View PR using the GUI difftool:
$ git pr show -t 5954
Using diff file
Download this PR as a diff file:
https://git.openjdk.java.net/jdk/pull/5954.diff