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

A Cargo.toml file in parent directory which you cannot delete prevents cargo from building anything #12080

Closed
cbeuw opened this issue May 3, 2023 · 3 comments
Labels
C-bug Category: bug S-triage Status: This issue is waiting on initial triage.

Comments

@cbeuw
Copy link
Contributor

cbeuw commented May 3, 2023

Problem

On a shared system, there is a directory (weirdly, but it could've been a file) named Cargo.toml under $HOME/... It is owned by root with 000 permission. As the parent directory still has r permission, a cargo project under $HOME cannot be built as cargo will detect the bad Cargo.toml, attempt to access it and then error out with permission denied.

A root user could put a Cargo.toml under / which acts a system-wide DoS against cargo for other users.

I know this recursive look up is expected behaviour, but it doesn't really play well with file permissions on shared systems. This is unlike .cargo/config.toml where each user can override the parent directory with a more specific one.

Steps

No response

Possible Solution(s)

Add a flag, say --workspace-lookup-depth=n, to prevent cargo from looking more than n levels up the file system

Notes

No response

Version

No response

@cbeuw cbeuw added C-bug Category: bug S-triage Status: This issue is waiting on initial triage. labels May 3, 2023
@weihanglo
Copy link
Member

Thanks for describing the scenario well!

This looks like effectively what rust-lang/rfcs#3279 tries to address. There are some open pull requests for it:

They got stale for a while. Hope we can move them forward someday.

Going to close this in favor of things above. Thank you.

@weihanglo weihanglo closed this as not planned Won't fix, can't repro, duplicate, stale May 3, 2023
@epage
Copy link
Contributor

epage commented May 3, 2023

A workaround would be to add the [workspace] table to the Cargo.toml

Something we might explore for rust-lang/rfcs#3424 is modifying package.workspace to support package.workspace = false to disable workspace lookup. I wonder if we would ever consider making package.workspace = false the default, requiring workspace members to set package.workspace = true.

@RalfJung
Copy link
Member

RalfJung commented May 4, 2023

Also maybe cargo should treat 'Cargo.toml is a directory or we have insufficient permissions' as 'Cargo.toml does not exist'?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: bug S-triage Status: This issue is waiting on initial triage.
Projects
None yet
Development

No branches or pull requests

4 participants