-
Notifications
You must be signed in to change notification settings - Fork 349
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
utils: T6975: Add 'vrf' and 'netns' arguments to functions in 'vyos.utils.process' #4253
Conversation
👍 |
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 left a minor suggestion.
Another question is that executing commands in VRFs and network namespace is only available with sudo
at the moment. For now, we should probably add an effective UID check (there's a function for that in utils) and raise a "permission denied" error if it's not 0 (root), rather than expose users to odd error messages.
aeee766
to
95f230f
Compare
wrapper = f'ip vrf exec {vrf} ' | ||
elif netns: | ||
wrapper = f'ip netns exec {netns} ' | ||
if auth: |
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.
What does auth do? Where do we use 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.
auth was added in this PR to prevent showing username and password in error 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.
Looks good now, I left a small suggestion.
python/vyos/utils/process.py
Outdated
# Must be run as root to execute command in VRF or network namespace | ||
if vrf or netns: | ||
if os.getuid() != 0: | ||
raise OSError('Permission denied') |
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.
raise OSError('Permission denied') | |
raise OSError('Permission denied: cannot execute commands in VRF and netns contexts as an unprivileged user') |
Maybe make the error more specific?
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.
Done
CI integration ❌ failed! Details
|
Change Summary
Types of changes
Related Task(s)
Related PR(s)
Component(s) name
vyos.utils
Proposed changes
How to test
Smoketest result
Checklist: