-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
check for root privileges to access eeprom on Dell N3248TE-ON #17529
base: master
Are you sure you want to change the base?
Conversation
Confirmed working as expected on the current master branch compiled today. |
@lguohan @zhangyanzhao @prgeor would you mind giving me the ability to assign reviewers to PRs in this repo? I would use this privilege to assign reviewers and approve PRs for Dell platforms. |
In the meantime, please assign reviewers @arunlk-dell @vpsubramaniam @aravindmani-1 |
try: | ||
self.eeprom_data = self.read_eeprom() | ||
except Exception: | ||
self.eeprom_data = "N/A" |
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.
@justindthomas can we keep the default value self.eeprom_data = "N/A"
outside of the if condition at the beginning of the of init?
@arunlk-dell @vpsubramaniam @aravindmani-1 can you please help to review this PR? Thanks. |
@@ -25,12 +25,12 @@ def __init__(self): | |||
self.eeprom_path = f | |||
super(Eeprom, self).__init__(self.eeprom_path, 0, '', True) | |||
self.eeprom_tlv_dict = dict() | |||
self.eeprom_data = "N/A" |
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.
@prgeor is this what you had in mind?
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 is a dependent PR that also needs to be merged along with this PR,
Dependent PR: #17509
Why I did it
Accessing a variety of configuration using
show
involves populating anEeprom
object representing the system eeprom that requires root level privileges to read. The current platform code throws an exception and requires the user to elevate privileges unnecessarily. Here's an example:After adjusting the
eeprom.py
file to check for root privileges on this operation (and to populate the field with "N/A" if unprivileged), the output is as follows:Work item tracking
How I did it
I added these lines to
eeprom.py
, around the section that makes the privileged call:How to verify it
Place the new file at
/usr/local/lib/python3.11/dist-packages/sonic_platform/eeprom.py
on the host and/usr/local/lib/python3.9/dist-packages/sonic_platform/eeprom.py
on thepmon
container and runshow interfaces status
.Tested branch (Please provide the tested image version)
master
Description for the changelog
Require elevated privileges to execute privileged command to read system eeprom.