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

safer 'install' task #61

Closed
wants to merge 2 commits into from
Closed

safer 'install' task #61

wants to merge 2 commits into from

Conversation

ghost
Copy link

@ghost ghost commented Mar 26, 2017

This pull request is trying to fix a problem about security

When installing something, users take it for granted to give command higher permission. I think most users use sudo xmake install instead of xmake install, because installing will put files into paths like /usr/local and root permission is required.

That is the problem. I found xmake will always build the target before installing even if it has been built before. And the building is a latent danger. For example, a bad man replace the compiler like gcc, and while installing, the fake gcc will get root permission to do something bad.

There are two solutions to avoid this. One is to set permission lower by process self before actual installation. Another is to do least things with high permission. My solution is to let task 'install' avoid building and use 'safe_config' which will not reconfig instead of 'config'. When users directly do task 'install' without building before, they will get a note to do building.

Also, except security, the build by root will generate result files with wrong owner. On my computer, after installation, I couldn't even delete 'build' dir without sudo

My solution may be not perfect enough. Please do not merge easily. But the secure problem must be fixed.

may get high permission when installing
change behavior to avoid dangerous building while installing
now installation will never do building
'safe_config' will never recheck
safer to be used in 'install'
@waruqi
Copy link
Member

waruqi commented Mar 26, 2017

Ok, I'll find a better solution to fix this problem in the next few days.

Thanks. : )

@ghost
Copy link
Author

ghost commented Mar 27, 2017

I have found an example: if run linuxbrew as root, linuxbrew will give a note then stop

$ sudo brew
W: be careful as root.

========================================================================
You may want to update following environments after installed linuxbrew.

  PATH, MANPATH, INFOPATH 

(example: /usr/share/doc/linuxbrew-wrapper/examples/profile)
========================================================================
Don't run this as root!

@waruqi
Copy link
Member

waruqi commented Mar 27, 2017

Ok, thanks for your advice.

I am solving this problem, please wait some time. : )

@waruqi
Copy link
Member

waruqi commented Mar 27, 2017

You can try the lastest commit 235bb96 from dev branch firstly.

And I will continue to improve some details in future.

@waruqi waruqi closed this Mar 29, 2017
@ghost ghost deleted the safe_install branch March 29, 2017 05:24
@ghost
Copy link
Author

ghost commented Mar 29, 2017

Would you add a note displaying like brew?

@waruqi
Copy link
Member

waruqi commented Mar 30, 2017

Ok, I will add it.

@waruqi
Copy link
Member

waruqi commented Mar 30, 2017

I have add it for checking root.

You can see the following tips:

$sudo xmake
error: Running xmake as root is extremely dangerous and no longer supported.
        As xmake does not drop privileges on installation you would be giving all
        build scripts full access to your system.

@ghost
Copy link
Author

ghost commented Mar 30, 2017

I see. Good job! 🍺

@ghost ghost mentioned this pull request May 21, 2017
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

Successfully merging this pull request may close these issues.

2 participants