-
Notifications
You must be signed in to change notification settings - Fork 8
Add explicit privilege prompt to improve sudo UX #138
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
Conversation
Corrected a few more references to rig, and elaborated the build script.
Release 1.2.0
1.2.1 release
1.2.2 Release
1.2.3 Release
Version 1.3.0
Version 1.3.1
1.3.2 Release
2.0.0 release
So I would simply say https://www.dropbox.com/s/m8twc771il6llhq/Screenshot%202018-01-29%2013.25.10.png?dl=0 And then once again, immediately, while I still had privs.... https://www.dropbox.com/s/vtx768cuhep9xk2/Screenshot%202018-01-29%2013.25.52.png?dl=0 It gave me "please enter your password" even though it just blasted right past it. Claiming privs needed is a good plan and it gives us the newline needed for an unobscured prompt. Claiming they are needed and blowing past it is really just a heads up and it is not confusing. |
Simplification helped tremendously. This is ready for final review. I would appreciate if someone took it for a spin to confirm the timing issues are not still lurking. My test has been: ./build/darwin/rig dns |
util/logger.go
Outdated
// This newline ensures the last status before escallation is preserved | ||
// on-screen. | ||
fmt.Println() | ||
log.Spin("Evaluating administrative action...") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just noting that things go by so quickly on my machine I never see the "Evaluating administrative action..." message.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wouldn't expect it to. I need the log.Spin() to start the spinner and the log.Warning() for the real message... let me test just using the same message for both, since that would avoid coder confusion.
util/slices.go
Outdated
|
||
// IndexOfString is a general utility function that can find the index of a value | ||
// present in a string slice. The second value is true if the item is found. | ||
func IndexOfString(slice []string, value string) (int, bool) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is probably due to general newness to go and it's structures and syntax but it took me a while to realize that this was testing for the presence of an element in a collection of elements rather than the presence of a substring within a string. Probably baggage from character arrays and the concept of a slice of a string from Perl combined with previous indexOf type functions. I don't think it has to change I just thought I'd mention it.
This is relevant because commands of the form of util.Command("bash", "-c", fmt.Sprintf("echo 'nameserver %s' | sudo tee /etc/resolver/vm", bridgeIP)).Run()
on 178 of dns.go would fail this check. It's not really an issue for Macs because that one is guaranteed to be proceeded by a command which will already trigger the Password prompt and stop the spinner (line 175 of dns.go). I think it might affect Linux however as the configureLinuxResolver function has no such preceding command.
I've attached an example of what this looks like on Linux.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One potential avenue around this would be to import the strings package and change the conditional on line 7 to something like
if elem == value || strings.Contains(elem, value + " ") {
This appears to function properly for both mac and linux though it changes the nature of this function such that you'll probably want to rename it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's a convention with exec.Cmd that the tokens all be individual array elements. I see that subshell situations might be different. Will adjust.
In addition to addressing CJ's feedback, I took the following steps:
|
I'm getting prompt overlap on Using |
Prompt overlap is only when stopping a running machine. If I stop an already stopped machine, the prompt works fine. |
I haven't found a way to crack the rig stop spinner yet. It appears that the Should I output an extra message on rig stop to provide instruction on dealing with the confusion? |
I could go with proceeding if it is just the stop portion that overlap is wonky on. If it's something with route would an initial |
cat /dev/null seems to have helped. Will need to research the implications of that trick. |
* Add explicit privilege prompt to improve sudo UX (#138) * Explicitly prompt for privilege escallation * Remove password prompt part of privilege message * Expand sudo detection. * Tidy up timing issues. * Consolidate messaging and avoid newline in verbose. * Cleanup ToString, sudo contains, cover more exec methods. * Lint does not catch all of fmt. * Remove unnecessary password prompt from networking cleanup. * Remove color reset and cat /dev/null to clear route text. * trying a different approach to requesting for admin privs (#144)
Fixes #134
This change identifies that we need to sudo and adjusts logging/spinning behaviors accordingly. Needs some more testing (e.g., with verbose) and a bit more smarts in sudo detection, hence the WIP flag. Also some UI issues around the asynchronous nature of the spinner.
I am pausing here for approach feedback.
Here's what it looks like when it operates as intended:
Paused for Input
Success!