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

Issue #9309 - Better jetty.sh integration for start.jar with eye on supporting odd properties #9313

Merged
merged 17 commits into from
Mar 24, 2023

Conversation

joakime
Copy link
Contributor

@joakime joakime commented Feb 3, 2023

When bridging output from start.jar --dry-run to the RUN_CMD in jetty.sh weird properties with various special characters and spaces would mess up the command line that eventually gets executed.

A change to start.jar --dry-run has been made to wrap individual args that have spaces with ' (single-tick quote), and a change in jetty.sh to separate the various args produced by the --dry-run properly for the execution of java and eventually the call to XmlConfiguration.

A minor update to CustomRequestLog exception messages has been pushed here as well.

Signed-off-by: Joakim Erdfelt joakim.erdfelt@gmail.com

Signed-off-by: Joakim Erdfelt <joakim.erdfelt@gmail.com>
@joakime joakime added the Bug For general bugs on Jetty side label Feb 3, 2023
@joakime joakime added this to the 10.0.x milestone Feb 3, 2023
@joakime joakime requested a review from gregw February 3, 2023 16:22
@joakime joakime self-assigned this Feb 3, 2023
gregw
gregw previously approved these changes Feb 6, 2023
Copy link
Contributor

@gregw gregw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Signed-off-by: Joakim Erdfelt <joakim.erdfelt@gmail.com>
…tick when arg has space.

Signed-off-by: Joakim Erdfelt <joakim.erdfelt@gmail.com>
Signed-off-by: Joakim Erdfelt <joakim.erdfelt@gmail.com>
@joakime joakime changed the title Issue #9309 - More comprehensive escaping of command line options Issue #9309 - Better jetty.sh integration for start.jar with eye on supporting odd properties Feb 6, 2023
@joakime joakime linked an issue Feb 6, 2023 that may be closed by this pull request
@jmcc0nn3ll
Copy link
Contributor

I think the usage of xargs in the jetty.sh script should be fine, but if there is a more strictly bash solution available, it may make sense to investigate that down the road if some reports an issue.

gregw
gregw previously requested changes Feb 6, 2023
Copy link
Contributor

@gregw gregw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a couple of quick comments. I need to review in more depth once these are resolved.

Signed-off-by: Joakim Erdfelt <joakim.erdfelt@gmail.com>
@joakime joakime requested a review from gregw February 6, 2023 22:09
@amjaliks
Copy link

With these changes my 10.0.x fails to start as a services. Even before I try to set 'an odd property' (a custom request log format).

A stacktrace:

2023-02-18 13:30:13.328:WARN :oejx.XmlConfiguration:main: Unable to execute XmlConfiguration
java.security.PrivilegedActionException: java.security.UnrecoverableKeyException: Get Key failed: Cannot read the array length because "password" is null
	at java.base/java.security.AccessController.doPrivileged(AccessController.java:573)
	at org.eclipse.jetty.xml.XmlConfiguration.main(XmlConfiguration.java:1818)
Caused by: 
java.security.UnrecoverableKeyException: Get Key failed: Cannot read the array length because "password" is null
	at java.base/sun.security.pkcs12.PKCS12KeyStore.engineGetKey(PKCS12KeyStore.java:450)
	at java.base/sun.security.util.KeyStoreDelegator.engineGetKey(KeyStoreDelegator.java:91)

The same configuration starts normally with 10.0.13.

@joakime
Copy link
Contributor Author

joakime commented Feb 22, 2023

@amjaliks can you include more of the stacktrace on that exception?
It will help me setup a similar jetty.base to you

@amjaliks
Copy link

@joakime I got this fixed by using xargs for calling start-stop-deamon in jetty.sh.

I replaced this (starting line 467):

      start-stop-daemon --start $CH_USER \
       --pidfile "$JETTY_PID" \
       --chdir "$JETTY_BASE" \
       --background \
       --make-pidfile \
       --startas "$JAVA" \
       -- ${RUN_ARGS[@]} start-log-file="$JETTY_START_LOG"

With this:

      echo ${RUN_CMD[*]} start-log-file="$JETTY_START_LOG" | xargs start-stop-daemon --start $CH_USER \
       --pidfile "$JETTY_PID" \
       --chdir "$JETTY_BASE" \
       --background \
       --make-pidfile \
       --startas "$JAVA" \
       --

End even more. I applied similar changes to jetty.sh from 10.0.13 and 11.0.13:

      echo $JETTY_SYS_PROPS ${RUN_ARGS[@]} start-log-file="$JETTY_START_LOG" | xargs start-stop-daemon --start $CH_USER \
       --pidfile "$JETTY_PID" \
       --chdir "$JETTY_BASE" \
       --background \
       --make-pidfile \
       --startas "$JAVA" \
       --

And this fixed #9309.

Signed-off-by: Joakim Erdfelt <joakim.erdfelt@gmail.com>
@amjaliks
Copy link

@joakime You need to update lines 586 and 599, otherwise actions supervise, run, and demo will be broken.

Signed-off-by: Joakim Erdfelt <joakim.erdfelt@gmail.com>
@amjaliks
Copy link

This PR has missed 10.0.14. How about 10.0.15?

Signed-off-by: Joakim Erdfelt <joakim.erdfelt@gmail.com>
@joakime
Copy link
Contributor Author

joakime commented Mar 20, 2023

@amjaliks have you tested this branch on your environment?
@gregw are you ok with this being in Jetty 10.0.15 release? (if so, I need an approval to merge this)

Signed-off-by: Joakim Erdfelt <joakim.erdfelt@gmail.com>
Signed-off-by: Joakim Erdfelt <joakim.erdfelt@gmail.com>
Signed-off-by: Joakim Erdfelt <joakim.erdfelt@gmail.com>
Signed-off-by: Joakim Erdfelt <joakim.erdfelt@gmail.com>
@github-advanced-security
Copy link

You have successfully added a new CodeQL configuration .github/workflows/codeql-analysis.yml:analyze/languages:java. As part of the setup process, we have scanned this repository and found 159 existing alerts. Please check the repository Security tab to see all alerts.

@joakime
Copy link
Contributor Author

joakime commented Mar 21, 2023

I've found a few problems with this branch on Windows that needs to be addressed.

@joakime joakime marked this pull request as draft March 21, 2023 21:17
@joakime joakime marked this pull request as ready for review March 23, 2023 16:22
@joakime
Copy link
Contributor Author

joakime commented Mar 23, 2023

I have finished my testing on Windows.

Other than the usual situation with overly long command lines, this PR appears to be working as intended on the Windows platform.

Signed-off-by: Joakim Erdfelt <joakim.erdfelt@gmail.com>
Signed-off-by: Joakim Erdfelt <joakim.erdfelt@gmail.com>
sbordet
sbordet previously approved these changes Mar 23, 2023
Signed-off-by: Joakim Erdfelt <joakim.erdfelt@gmail.com>
@joakime joakime requested a review from sbordet March 23, 2023 22:08
@joakime
Copy link
Contributor Author

joakime commented Mar 23, 2023

@sbordet need a fresh approval, had to fix a build issue with javadoc

@joakime joakime merged commit a9bae8e into jetty-10.0.x Mar 24, 2023
@joakime joakime deleted the fix/jetty-10.0.x/jetty-sh-start-properties branch March 24, 2023 13:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug For general bugs on Jetty side
Projects
None yet
Development

Successfully merging this pull request may close these issues.

jetty.sh cannot handle complex Jetty properties from start.d/*.ini
5 participants