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

Cannot run x.py under sudo as non-root user #93344

Closed
chbaker0 opened this issue Jan 26, 2022 · 5 comments · Fixed by #95671
Closed

Cannot run x.py under sudo as non-root user #93344

chbaker0 opened this issue Jan 26, 2022 · 5 comments · Fixed by #95671
Assignees
Labels
C-bug Category: This is a bug. E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. E-help-wanted Call for participation: Help is requested to fix this issue. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)

Comments

@chbaker0
Copy link
Contributor

chbaker0 commented Jan 26, 2022

I am trying to build Rust from source on my project's continuous integration system. I see the following error:

info: looks like you are running this command under `sudo`
      and so in order to preserve your $HOME this will now
      use vendored sources by default.
error: vendoring required, but vendor directory does not exist.
       Run `cargo vendor` without sudo to initialize the vendor directory.

Looking at the message and #40108 it seems the intent is to prevent putting root-owned files in a non-root user's home directory.

Our CI builders use sudo to step down from root to a sandboxed user. See https://logs.chromium.org/logs/chromium/buildbucket/cr-buildbucket/8823996676604838337/+/u/build_rust/execution_details for an example environment. I believe it should be safe to build without vendoring in this case.

bootstrap.py should skip the check if SUDO_USER is not root, or an option to bypass this check should be provided.

@chbaker0 chbaker0 added the C-bug Category: This is a bug. label Jan 26, 2022
@Mark-Simulacrum Mark-Simulacrum added the T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) label Jan 26, 2022
@Mark-Simulacrum
Copy link
Member

If the implementation for this is relatively straightforward, a PR is likely to be accepted.

aarongable pushed a commit to chromium/chromium that referenced this issue Jan 28, 2022
x.py was failing due to the use of sudo on builders (see
rust-lang/rust#93344). Enabling vendoring
bypasses this check and prepares us for future vendoring of dependency
sources, which we will likely want to do.

The build still touches $HOME/.cargo which is undesirable but a fix
will be in a later change.

Bug: 1245714
Change-Id: Ic6d2027289ebdbcf82a03b6bc571167245acb398
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3417957
Reviewed-by: Adrian Taylor <adetaylor@chromium.org>
Commit-Queue: Collin Baker <collinbaker@chromium.org>
Cr-Commit-Position: refs/heads/main@{#964667}
@jyn514
Copy link
Member

jyn514 commented Mar 30, 2022

@rustbot label; +E-easy +E-help-wanted

@rustbot
Copy link
Collaborator

rustbot commented Mar 30, 2022

Error: Parsing relabel command in comment failed: ...'tbot label' | error: a label delta at >| '; +E-easy '...

Please let @rust-lang/release know if you're having trouble with this bot.

@jyn514
Copy link
Member

jyn514 commented Mar 30, 2022

@rustbot label: +E-easy +E-help-wanted

@rustbot rustbot added E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. E-help-wanted Call for participation: Help is requested to fix this issue. labels Mar 30, 2022
@gimbling-away
Copy link
Contributor

@rustbot claim

Dylan-DPC added a commit to Dylan-DPC/rust that referenced this issue Apr 10, 2022
feat: Allow usage of sudo [while not accessing root] in x.py

# Fixes
This PR should fix rust-lang#93344
# Info
Allows usage of sudo (while not accessing root) in x.py
Dylan-DPC added a commit to Dylan-DPC/rust that referenced this issue Apr 11, 2022
feat: Allow usage of sudo [while not accessing root] in x.py

# Fixes
This PR should fix rust-lang#93344
# Info
Allows usage of sudo (while not accessing root) in x.py
Dylan-DPC added a commit to Dylan-DPC/rust that referenced this issue Apr 11, 2022
feat: Allow usage of sudo [while not accessing root] in x.py

# Fixes
This PR should fix rust-lang#93344
# Info
Allows usage of sudo (while not accessing root) in x.py
@bors bors closed this as completed in ae068e7 Apr 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug. E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. E-help-wanted Call for participation: Help is requested to fix this issue. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants