Skip to content

Commit 75123c7

Browse files
committed
Set the eeprom cache permissions to 755
Issue and Root Cause: The issue arises because, after a system reboot, the permissions of /var/cache/sonic/decode-syseeprom/ or its file /var/cache/sonic/decode-syseeprom/syseeprom_cache may be incorrectly set. This misconfiguration can cause the Platform API to require root privileges for access. This problem has been observed in various platforms, such as the AS7326_56X, where running show platform syseeprom results in errors due to permission issues. Solution: To address this, it's essential to ensure that the cache directory and its files have the correct permissions set upon system startup. Implementing a fix that adjusts these permissions appropriately can prevent the Platform API from requiring root privileges, thereby resolving the issue.
1 parent cb5564c commit 75123c7

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

sonic_platform_base/sonic_eeprom/eeprom_base.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -295,9 +295,21 @@ def write_cache(self, e):
295295
if self.cache_name:
296296
F = None
297297
try:
298+
# Ensure the directory exists
299+
directory = os.path.dirname(self.cache_name)
300+
301+
if not os.path.exists(directory):
302+
os.makedirs(directory)
303+
304+
# Set directory permissions to 755
305+
os.chmod(directory, 0o755)
306+
298307
F = open(self.cache_name, "wb")
299308
F.seek(self.s)
300309
F.write(e)
310+
311+
# Set file permissions to 755
312+
os.chmod(self.cache_name, 0o755)
301313
except IOError as e:
302314
raise IOError("Failed to write cache : %s" % (str(e)))
303315
finally:

0 commit comments

Comments
 (0)