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
Abort the module execution when running w/o enough privileges #583
Conversation
When catch an Errno::EACCES trying to read the grub.cfg file.
984ae49
to
3701667
Compare
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 a working in progress pull request yet. However, I would like to have earlier opinions or suggestions. See my self pre-review / request for comments.
src/modules/Bootloader.rb
Outdated
@@ -166,8 +166,14 @@ def Read | |||
|
|||
::Bootloader::BootloaderFactory.current = ::Bootloader::BootloaderFactory.proposed | |||
::Bootloader::BootloaderFactory.current.propose | |||
rescue ::Bootloader::InsufficientPrivileges => e |
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.
A self pre-review / Request for comments
I added this new exception just to follow the pattern used here (I mean, rescuing its own exception). But, to be honest, I'm not sure if
- I like it
- It is a good idea
Another way to do it without a custom exception is to rescue the Errno::ACCES
here directly.
...
rescue Errno::ACCES
error_msg = _(
"The module is running without enough privileges to perform all possible actions.\n\n" \
"Cannot continue. Please, try again as root."
)
Yast2::Popup.show(error_msg, headline: :error)
return false
end
...
Shorter than the previous option but, again, I'm not sure if
- I like it
- It is a good idea
What do you think? Do you have any other suggestions?
Thanks in advance for your input!
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 agree there is no need to invent a new type of exception that is only used to directly replace Errno::ACCESS
.
The current custom exceptions defined in yast2-bootloader exist because they actually describe a pretty specific circumstance that is not covered by the standard ruby. But that's not the case with that new (and unnecessary) InsufficientPrivileges
class.
Based on a code review comment: https://github.com/yast/yast-bootloader/pull/583/files#r350677467 Basically, catch the Errno:EACCES exception direclty in Bootloader.Read
a2c90c4
to
1f45550
Compare
Thinking about this more widely, I wonder whether we should just use I'd say that's what most traditional YaST modules do. |
I didn't know about And what I'd like to do is abort the execution. To me, it makes no sense to
or even worst
Am I missing something? Sorry for the noise :( |
Yes, you are right. The approach you implemented makes more sense from a user POV. But, please add a comment in that |
Suggested during the review. See #583 (comment)
Tue Nov 26 12:22:50 UTC 2019 - David Diaz <dgonzalez@suse.com> | ||
|
||
- Abort the execution when the module run without enough | ||
permissions (related to bsc#1137688). |
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.
It's actually hard to see the relationship with bsc#1137688, but I trust you ;-)
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.
Yes, it's hard also to me. It's what I said in a comment in the Trello card 🤷♂️
src/modules/Bootloader.rb
Outdated
# wizard/client is not enough since it allows continue. | ||
|
||
Yast2::Popup.show( | ||
# TRANSLATORS: warn to the user that is running the module without enough permissions |
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.
Is really that useful to have a message to the translators to tell them what is already said in the string itself?
Something like TRANSLATORS: pop-up message, beware the line breaks
would actually be useful, but the current one...
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.
Answer: actually no.
Thanks for the suggestion :)
Suggested during the review. See #583 (comment)
931d6b1
to
cf778fa
Compare
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.
LGTM
✔️ Public Jenkins job #40 successfully finished |
✔️ Internal Jenkins job #14 successfully finished |
Problem
When
yast-bootloader
module is executed without enough privileges/permissions, it crash because anErrno::EACCES
error when trying access to the grub.cfg file.Click to show/hide an screenshot
Solution
Abort the execution nicely, giving human readable information to the user.
💡 Proposed message:
Tests