Skip to content
This repository was archived by the owner on Nov 24, 2025. It is now read-only.

Run CDN in a Box for Developers services as unprivileged users#7142

Merged
ocket8888 merged 20 commits intoapache:masterfrom
zrhoffman:dev-ciab-unprivileged
Nov 11, 2022
Merged

Run CDN in a Box for Developers services as unprivileged users#7142
ocket8888 merged 20 commits intoapache:masterfrom
zrhoffman:dev-ciab-unprivileged

Conversation

@zrhoffman
Copy link
Copy Markdown
Member

@zrhoffman zrhoffman commented Oct 17, 2022

This PR makes it so that when the CDN in a Box for Developers services create new files (from npm ci, building debug binaries, creating Traffic Router DBs, etc.), the files are owned by the user who owns the repository directory, rather than being owned by root.


Which Traffic Control components are affected by this PR?

  • CDN in a Box - for Developers

What is the best way to verify this PR?

  1. Remove generated files and directories:

    rm -rf dev/traffic_router/db experimental/traffic-portal/node_modules traffic_monitor/__debug_bin traffic_ops/traffic_ops_golang/__debug_bin traffic_portal/node_modules
  2. Build the CDN in a Box for Developers:

    docker-compose build
  3. Start the Dev CiaB:

    docker-compose up
  4. Verify that the generated files and directories are owned by you

ls -ld dev/traffic_router/db experimental/traffic-portal/node_modules traffic_monitor/__debug_bin traffic_ops/traffic_ops_golang/__debug_bin traffic_portal/node_modules

PR submission checklist

@zrhoffman zrhoffman added improvement The functionality exists but it could be improved in some way. dev-ciab Related to CDN in a Box for Developers labels Oct 17, 2022
@zrhoffman zrhoffman force-pushed the dev-ciab-unprivileged branch from 43d96f0 to a191575 Compare October 19, 2022 21:51
@ocket8888 ocket8888 self-assigned this Oct 20, 2022
@ocket8888 ocket8888 added the low impact affects only a small portion of a CDN, and cannot itself break one label Oct 20, 2022
@ocket8888
Copy link
Copy Markdown
Contributor

This is something I've wanted for the dev environment since its inception, but I can't test it because of a bug in the TP/TPv2 containers that prevents them from fetching a resource from npm. I've had another developer confirm that the issue is not specific to my machine, but I still have no idea why that's happening.

@zrhoffman zrhoffman force-pushed the dev-ciab-unprivileged branch from 1d8666d to 2401344 Compare November 7, 2022 22:53
@zrhoffman
Copy link
Copy Markdown
Member Author

Rebased onto master to get #7164

Comment thread dev/tpv2/run.sh
Copy link
Copy Markdown
Contributor

@ocket8888 ocket8888 left a comment

Choose a reason for hiding this comment

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

Most things appear to be working, but it seems that the Go binaries it generates are still owned by root:

$ ls -lR . | grep -v "$(whoami)" | grep -vE '^\..*:$' | grep -vE '^$' | grep -vE '^total [0-9]+$'
-rwxr-xr-x 1 root      root      6881051 Nov  9 10:57 t3c
-rwxr-xr-x 1 root      root      9965720 Nov  9 10:57 t3c-apply
-rwxr-xr-x 1 root      root      6876971 Nov  9 10:57 t3c-check
-rwxr-xr-x 1 root      root      6958591 Nov  9 10:57 t3c-check-refs
-rwxr-xr-x 1 root      root      6854750 Nov  9 10:57 t3c-check-reload
-rwxr-xr-x 1 root      root      6958920 Nov  9 10:57 t3c-diff
-rwxr-xr-x 1 root      root      8375868 Nov  9 10:57 t3c-generate
-rwxr-xr-x 1 root      root      6960525 Nov  9 10:57 t3c-preprocess
-rwxr-xr-x 1 root      root      10250226 Nov  9 10:57 t3c-request
-rwxr-xr-x 1 root      root      7076256 Nov  9 10:57 t3c-tail
-rwxr-xr-x 1 root      root      9794976 Nov  9 10:57 t3c-update
-rwxr-xr-x 1 root      root      11172798 Nov  9 10:57 tc-health-client
-rwxr-xr-x 1 root      root      7106164 Nov  9 10:56 admin

Comment thread docker-compose.yml
- 6443:443
- 6444:6444
sysctls:
- net.ipv4.ip_unprivileged_port_start=0
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Maybe should be changed to 23 so ssh port isnt exposed?

Copy link
Copy Markdown
Member Author

@zrhoffman zrhoffman Nov 9, 2022

Choose a reason for hiding this comment

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

This isn't which ports are exposed, it's which ports a non-root user is allowed to listen on.

Docker itself includes net.ipv4.ip_unprivileged_port_start = 0, just not containerd yet.

@zrhoffman
Copy link
Copy Markdown
Member Author

Oops, the condition checking if t3c's run.sh was being run as root was always checking the unprivileged user's UID instead. Fixed in 0150a22

@zrhoffman zrhoffman requested a review from ocket8888 November 10, 2022 22:53
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

dev-ciab Related to CDN in a Box for Developers improvement The functionality exists but it could be improved in some way. low impact affects only a small portion of a CDN, and cannot itself break one

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants