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

userHome can get overridden even if process UID is not root #1827

Closed
mattlqx opened this issue Nov 14, 2016 · 2 comments
Closed

userHome can get overridden even if process UID is not root #1827

mattlqx opened this issue Nov 14, 2016 · 2 comments

Comments

@mattlqx
Copy link

mattlqx commented Nov 14, 2016

Do you want to request a feature or report a bug?
Bug under a certain use-case.

What is the current behavior?
When running Yarn from another process like Chef that can specify UID and doesn't spawn under a new shell, userHome gets overridden even though the effective UID of Yarn is not root. This can lead to Yarn trying to create directories in /usr/local/share even though it may not have permissions to do so.

Result of #1344

This is pretty easy to workaround by simply specifying a USER environment variable (instead of letting it be root, which Chef runs as) in the execute statement, but I think the conditional to override userHome could be improved.

If the current behavior is a bug, please provide the steps to reproduce.

  1. Run yarn in a Chef execute statement with a non-root user attribute.

This will fail because the non-root user likely won't have permissions to write to /usr/local/share.

What is the expected behavior?
Run normally and with the user home dir specified by the HOME variable.

Please mention your node.js, yarn and operating system version.
6.9.1, 0.17.0, Ubuntu 16.04

@sebmck
Copy link
Contributor

sebmck commented Nov 15, 2016

We don't do this detection ourselves, we use the user-home package. Source is here. I'd recommend opening an issue over there.

@sebmck sebmck closed this as completed Nov 15, 2016
@wyze wyze removed the needs triage label Nov 15, 2016
@mattlqx
Copy link
Author

mattlqx commented Nov 15, 2016

It actually is overridden somewhat by Yarn here:

yarn/src/constants.js

Lines 4 to 6 in 91267dc

if (process.platform === 'linux' && process.env.USER === 'root') {
userHome = path.resolve('/usr/local/share');
}

That's where the issue stems from.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants