sonic-buildimage icon indicating copy to clipboard operation
sonic-buildimage copied to clipboard

eliminate dmidecode in component.py because it requires root privileges

Open justindthomas opened this issue 1 year ago • 7 comments

Why I did it

As described in https://github.com/sonic-net/sonic-buildimage/issues/16878, every show command on the N3248TE-ON results in an error about dmidecode not being found. This is because that command is called in the get_bios_version function of component.py, which is used in a lot of places (many which should not require privileged access).

The error message prior to this change:

jdt@sonic:~$ show system-health
failed to import plugin show.plugins.cisco-8000: [Errno 2] No such file or directory: 'dmidecode'
Usage: show system-health [OPTIONS] COMMAND [ARGS]...

  Show system-health information

Work item tracking
  • Microsoft ADO (number only):

How I did it

On this platform, at least, the BIOS version can be obtained from /sys/class/dmi/id/bios_versionwithout requiring root privileges. I adjusted component.py to use that instead of dmidecode.

How to verify it

With that change in place, you can see that commands no longer complain about dmidecode:

jdt@sonic:~$ show system-health
Usage: show system-health [OPTIONS] COMMAND [ARGS]...

  Show system-health information

Options:
  -?, -h, --help  Show this message and exit.

Commands:
  detail           Show system-health detail information
  monitor-list     Show system-health monitored services and devices name...
  summary          Show system-health summary information
  sysready-status  Show system-health system ready status
  • [ ] 201811
  • [ ] 201911
  • [ ] 202006
  • [ ] 202012
  • [ ] 202106
  • [ ] 202111
  • [ ] 202205
  • [ ] 202211
  • [ ] 202305

Tested branch (Please provide the tested image version)

master

Description for the changelog

Removed call to dmidecode for every component command on the N3248TE-ON platform.

justindthomas avatar Dec 14 '23 23:12 justindthomas

@jeff-yin flagging this one too for review by someone at Dell.

justindthomas avatar Dec 14 '23 23:12 justindthomas

@justindthomas please assign @arunlk-dell and @vpsubramaniam as reviewers too, thanks!

jeff-yin avatar Dec 14 '23 23:12 jeff-yin

Is there a meeting I need to attend or something to get things like this merged? This seems like a pretty trivial change, but has a significantly positive usability impact (i.e., operations that shouldn't require privileges no longer error out).

I have 4 PRs that have been sitting for months with some reviews, but apparently not enough. How do I move these forward?

@jeff-yin

justindthomas avatar Mar 20 '24 01:03 justindthomas

@zhangyanzhao @lguohan -- these changes have been approved by Dell staff. Can someone merge?

jeff-yin avatar Mar 20 '24 01:03 jeff-yin

@yxieca can you please help to check this PR to see if we can merge it? Thanks.

zhangyanzhao avatar Apr 10 '24 15:04 zhangyanzhao

@yxieca can you please help to check this PR to see if we can merge it? Thanks.

I think it is okay, @prgeor can you take a quick look?

yxieca avatar Apr 10 '24 15:04 yxieca

/Semgrep

yxieca avatar Apr 10 '24 15:04 yxieca