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

elevate privileges in Windows host if necessary #48

Merged
merged 3 commits into from
Nov 21, 2013
Merged

elevate privileges in Windows host if necessary #48

merged 3 commits into from
Nov 21, 2013

Conversation

pbitty
Copy link
Contributor

@pbitty pbitty commented Nov 4, 2013

This change makes the plugin try to overwrite the hosts file with elevated privileges in a Windows host if it gets an 'access denied' when trying to copy it normally. This allows you to use the plugin in Windows without any permission workarounds.

This has proved useful to me, and I'm wondering if it would be useful to you or anyone else.

Before these changes, I had these options:

  • relax the permissions on the hosts file so it is writable without elevated privileges
    This is not ideal for security reasons as any app running under my user can now edit the hosts file without my knowledge.
  • run vagrant with elevated privileges
    This is inconvenient because VirtualBox can't run with 'regular' privileges and elevated privileges at the same time. If VirtualBox is already running with regular privileges, you can't launch it elevated - and vice-versa. So to manage any VM I have to remember to call 'cmd' with 'Run as admin...'

Are there other workarounds I don't know about?

@smdahlen
Copy link
Contributor

@pbitty Interested in managing this project (with possibly a few others)? I'm tied up for the next few months, and will not find to appropriately review pull requests.

@pbitty
Copy link
Contributor Author

pbitty commented Nov 15, 2013

@smdahlen I would love to do this! It would be my first time in a role like this, so it would be ideal to have others to share the work with and learn from.

@smdahlen
Copy link
Contributor

@pbitty Great! @bdcribbs has also agreed to support. Given my current day commitments, if the two of you could review and test incoming pull requests, I would greatly appreciate it. I have made both of you contributors to the project. When you believe we are ready to cut a new gem, let me know, and I will go ahead and push.

@bdcribbs
Copy link
Collaborator

As a Mac user I can't test the new functionality, but I can confirm that the plugin still behaves correctly on OSX (and presumably other posix systems).

I'll leave the merge to pbitty.

@@ -8,13 +8,13 @@ def update_guest(machine)

if (machine.communicate.test("uname -s | grep SunOS"))
realhostfile = '/etc/inet/hosts'
move_cmd = 'mv'
move_cmd = 'mv'
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm glad you fixed the bad indentation here, it makes the code much more readable.

But it is better if commits to fix indentation / code style are separated from commits that make logical changes to the code.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks @bdcribbs . I agree.

I can re-push this branch without the indentation changes. Would that cause any problems?

Copy link
Collaborator

Choose a reason for hiding this comment

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

It hasn't been merged yet, so you could do that. On the other hand, I was just being pedantic :) It'd be fine to just merge this in as is.

pbitty added a commit that referenced this pull request Nov 21, 2013
elevate privileges in Windows host if necessary
@pbitty pbitty merged commit af19868 into devopsgroup-io:master Nov 21, 2013
@pbitty pbitty deleted the windows_elevate_privileges branch November 21, 2013 04:19
@pbitty pbitty mentioned this pull request Nov 28, 2013
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.

None yet

3 participants