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

Jetty.sh start does not work when run as root #7095

Closed
chiralsoftware opened this issue Nov 10, 2021 · 4 comments
Closed

Jetty.sh start does not work when run as root #7095

chiralsoftware opened this issue Nov 10, 2021 · 4 comments
Labels
Bug For general bugs on Jetty side

Comments

@chiralsoftware
Copy link

Jetty version(s)

Java 17

Java version/vendor (use: java -version)

openjdk version "17" 2021-09-14
OpenJDK Runtime Environment (build 17+35-2724)
OpenJDK 64-Bit Server VM (build 17+35-2724, mixed mode, sharing)

OS type/version

Ubuntu 20.04.3 LTS

Description

Jetty does not run when started using jetty.sh when that is run as root.

How to reproduce?

% md5sum *.gz
c523f8893a36eb7d92801e8812b44917  jetty-home-10.0.7.tar.gz
5d1e9bc9be1570768485df4ff665821d  openjdk-17_linux-x64_bin.tar.gz

% tar xf jetty-home-10.0.7.tar.gz
% tar xf openjdk-17_linux-x64_bin.tar.gz
% export JAVA=`pwd`/jdk-17/bin/java
% $JAVA -version
openjdk version "17" 2021-09-14
OpenJDK Runtime Environment (build 17+35-2724)
OpenJDK 64-Bit Server VM (build 17+35-2724, mixed mode, sharing)
% mkdir jetty-base
% cd jetty-base
% export JETTY_BASE=`pwd`
% $JAVA -jar ../jetty-home-10.0.7/start.jar --create-start-d
% $JAVA -jar ../jetty-home-10.0.7/start.jar --add-modules=http
% find .
.
./start.d
./start.d/http.ini
./resources
./resources/jetty-logging.properties
% cd ..
% sudo -s
# export JETTY_BASE=`pwd`/jetty-base
# export JAVA=`pwd`/jdk-17/bin/java
# $JAVA -version
openjdk version "17" 2021-09-14
OpenJDK Runtime Environment (build 17+35-2724)
OpenJDK 64-Bit Server VM (build 17+35-2724, mixed mode, sharing)
# ./jetty-home-10.0.7/bin/jetty.sh start
Starting Jetty: FAILED Wed 10 Nov 2021 01:20:28 PM PST

This seems like the simplest possible installation of Jetty and it should "just work". I also tried it with JDK 17.0.1 and same result. The strange thing is when I run it as my own user, not as root, it works fine. Note that adding the setuid module doesn't help. Here it is, running as non-root:

Starting Jetty: 2021-11-10 13:25:11.534:INFO :oejs.Server:main: jetty-10.0.7; built: 2021-10-06T19:34:02.766Z; git: da8a4553af9dd84080931fa0f8c678cd2d60f3d9; jvm 17+35-2724

I also tried running it as non-root first and then running it as root, and same result.

To fix it, edit jetty-home-10.0.7/bin/jetty.sh, go to line 468 and remove the quote marks around the $RUN_ARGS[@].

Then it works as root or not, although I don't think this is really the correct bash-way to fix it.

This was really a painful thing to debug, why it was all working when I ran it with jetty.sh supervise but not with jetty.sh start, and therefore why my systemd unit was failing.

I'm not really sure why the start-stop-daemon handling of spaces in parameters is different between root user and non-root user but somehow it seems that it is. I've tried this on two different ubuntu 20.04 machines so far.

@chiralsoftware chiralsoftware added the Bug For general bugs on Jetty side label Nov 10, 2021
@joakime
Copy link
Contributor

joakime commented Nov 10, 2021

This feels like a duplicate of #7008

Can you try the fix listed in there?

Namely the version of jetty.sh from https://github.com/eclipse/jetty.project/blob/c89866682c14ca1da0ce482eeca0953375b25da8/jetty-home/src/main/resources/bin/jetty.sh

@chiralsoftware
Copy link
Author

Thanks Joakime. I simply replaced my jetty.sh file with https://raw.githubusercontent.com/eclipse/jetty.project/jetty-10.0.x/jetty-home/src/main/resources/bin/jetty.sh and it all worked. This was really a confusing situation but it seems to work now.

@joakime
Copy link
Contributor

joakime commented Nov 10, 2021

@chiralsoftware we are starting the process of the next Jetty 9/10/11 releases. Expect a new Jetty 10 release with this fix in it before the end of the month.

@joakime
Copy link
Contributor

joakime commented Nov 10, 2021

Closing, as fixed.

@joakime joakime closed this as completed Nov 10, 2021
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

No branches or pull requests

2 participants