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

utils: T6975: Add 'vrf' and 'netns' arguments to functions in 'vyos.utils.process' #4253

Merged
merged 1 commit into from
Jan 7, 2025

Conversation

natali-rs1985
Copy link
Contributor

Change Summary

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Code style update (formatting, renaming)
  • Refactoring (no functional changes)
  • Migration from an old Vyatta component to vyos-1x, please link to related PR inside obsoleted component
  • Other (please describe):

Related Task(s)

Related PR(s)

Component(s) name

vyos.utils

Proposed changes

How to test

Smoketest result

Checklist:

  • I have read the CONTRIBUTING document
  • I have linked this PR to one or more Phabricator Task(s)
  • I have run the components SMOKETESTS if applicable
  • My commit headlines contain a valid Task id
  • My change requires a change to the documentation
  • I have updated the documentation accordingly

Copy link

github-actions bot commented Dec 23, 2024

👍
No issues in PR Title / Commit Title

Copy link
Member

@dmbaturin dmbaturin left a 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.

python/vyos/utils/process.py Outdated Show resolved Hide resolved
@natali-rs1985 natali-rs1985 force-pushed the T6975 branch 2 times, most recently from aeee766 to 95f230f Compare December 24, 2024 13:14
wrapper = f'ip vrf exec {vrf} '
elif netns:
wrapper = f'ip netns exec {netns} '
if auth:
Copy link
Member

@c-po c-po Dec 24, 2024

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?

Copy link
Contributor Author

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

python/vyos/utils/process.py Show resolved Hide resolved
Copy link
Member

@dmbaturin dmbaturin left a 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.

# 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')
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
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?

Copy link
Contributor Author

@natali-rs1985 natali-rs1985 Jan 6, 2025

Choose a reason for hiding this comment

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

Done

Copy link

github-actions bot commented Jan 6, 2025

CI integration ❌ failed!

Details

CI logs

  • CLI Smoketests (no interfaces) ❌ failed
  • CLI Smoketests (interfaces only) ❌ failed
  • Config tests 👍 passed
  • RAID1 tests 👍 passed
  • TPM tests 👍 passed

@dmbaturin dmbaturin merged commit 8b517e2 into vyos:current Jan 7, 2025
13 of 16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

Successfully merging this pull request may close these issues.

3 participants