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

Run TRSS server as non-root #1327

Closed
sxa opened this issue May 13, 2020 · 21 comments
Closed

Run TRSS server as non-root #1327

sxa opened this issue May 13, 2020 · 21 comments
Assignees
Labels
Milestone

Comments

@sxa
Copy link
Member

sxa commented May 13, 2020

At the moment (discovered while looking at request #1326) the TRSS server is running as root through forever and started by the TRSS* scripts in /etc/init.d. Running such services as root unnecessarily is undesirable from a security standpoint so we should look at reworking this to run as a non-root user and manage access accordingly.

@karianna karianna added the bug label May 14, 2020
@sxa sxa added this to the June 2020 milestone Jun 1, 2020
@Haroon-Khel Haroon-Khel modified the milestones: June 2020, July 2020 Jul 3, 2020
@Haroon-Khel Haroon-Khel modified the milestones: July 2020, August 2020 Aug 18, 2020
@Haroon-Khel Haroon-Khel modified the milestones: August 2020, October 2020 Oct 5, 2020
@Haroon-Khel
Copy link
Contributor

Did this get solved during the recent restart of TRSS?

@sxa
Copy link
Member Author

sxa commented Dec 17, 2020

Did this get solved during the recent restart of TRSS?

Unlikely IMHO

@smlambert
Copy link
Contributor

smlambert commented Feb 16, 2022

What alternatives are you aware of, can systemd or something else replace this functionality (that forever service provides)?

@sxa
Copy link
Member Author

sxa commented Feb 16, 2022

Perhaps, although systemd also runs as root. I really need someone to convince me of why forever isn't an option - I've only heard anecdotal reasons so far :-)

I've just tested a basic forever test with a simple app and it works fine as non-root, so I feel there's another underlying reason why we're running as root at the moment which I'd like to understand.

@smlambert
Copy link
Contributor

@llxia - were there other reasons that you are aware of (re: #1327 (comment))?

@Haroon-Khel
Copy link
Contributor

Haroon-Khel commented Feb 17, 2022

When running the forever-service commands as a non root user, I get an error asking for them to be run as root

image

@sxa sxa modified the milestones: Backlog, 2022-02 (February) Feb 17, 2022
@sxa sxa pinned this issue Feb 17, 2022
@sxa sxa self-assigned this Feb 17, 2022
@Haroon-Khel
Copy link
Contributor

Haroon-Khel commented Feb 21, 2022

To summarise a lengthy slack thread, I found that the TestResultSummaryService can be started and stopped with the forever tool by a non root user.

forever start backend.js
forever start frontend.js

Both are commands to start up the service, and not the client. Concerning the react client, I am not sure where on the server it is running, so I do not yet know if that can be stopped and started by a non root user

@aixtools
Copy link
Contributor

aixtools commented Feb 26, 2022

No idea how forever works, but could the forever service, running as root, start the trss "application" as it does now, except prefix it with su -c username

@llxia
Copy link

llxia commented Mar 1, 2022

I am not sure what was changed in your experiment. From TRSS perspective, we do not need to "start" the client. It is a static pre-compiled web client.

IMO, the key problem here is that we need root permission to start a service (i.e., forever-service in this case). And we need the ability to restart the service to pick up new code changes.
Note: the forever command or node server does not need root permission.

I think we can use --watch forever option to watch file changes. If it can auto-restart based on the TRSS file changes, then we do not need the ability to restart the service. Therefore, TRSS can be added as a regular Jenkins node. No special permission is needed.

@Haroon-Khel
Copy link
Contributor

Haroon-Khel commented Mar 2, 2022

From TRSS perspective, we do not need to "start" the client. It is a static pre-compiled web client.

That clears things up. Thanks

@zdtsw
Copy link
Contributor

zdtsw commented Jun 1, 2022

according to usage: https://github.com/zapty/forever-service/blame/master/README.md#L117
we can use --runAsUser to set run from Jenkins user if we are on a different OS, but *Experimental* Run service as a specific user, defaults to root (No ubuntu support yet)

I think there are some misunderstanding in the above comments:

@llxia
Copy link

llxia commented Jun 1, 2022

Thanks @zdtsw for investigating this.
To clarify, there are 3 levels here - forever service, forever cmd, and TRSS server. Both forever cmd and TRSS server do NOT need root permission. Permission is needed for restarting the service in general. Also, currently, the TRSS server is on an Ubuntu machine, so the --runAsUser flag does not apply atm.

Anyway, we already have a solution and it is up and running internally. We are using the --watch forever option to watch file changes. And TRSS runs as a regular Jenkins user. Related: adoptium/aqa-test-tools#654

@sxa
Copy link
Member Author

sxa commented Feb 6, 2023

And TRSS runs as a regular Jenkins user.

I believe this is complete. If anyone disagrees or believes additional work is required then it can be reopened.

@sxa sxa closed this as completed Feb 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

7 participants