Skip to content

Commit 0e9d191

Browse files
committed
hw-mgmt: scripts: Fix permissions of files generated by VPD parser
Make files generated by VPD parser readable by everyone, not just the owner. Bug: 4838638 Signed-off-by: Felix Radensky <fradensky@nvidia.com>
1 parent cad3563 commit 0e9d191

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

usr/usr/bin/hw-management-vpd-parser.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/usr/bin/python
22
#
33
# SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES
4-
# Copyright (c) 2020-2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
4+
# Copyright (c) 2020-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
55
# SPDX-License-Identifier: GPL-2.0-only
66
#
77
# This program is free software; you can redistribute it and/or modify it
@@ -79,13 +79,15 @@
7979
#############################
8080
import sys
8181
import argparse
82+
import os
8283
import os.path
8384
import subprocess
8485
import struct
8586
import binascii
8687
import zlib
8788
import tempfile
8889
import shutil
90+
import stat
8991

9092

9193
#############################
@@ -761,8 +763,12 @@ def save_fru(fru_dict, out_filename):
761763
else:
762764
tmp_file.write("{}\n".format(str(item[1]).rstrip()))
763765

766+
# Set permissions on temporary file to allow read access for all users (rw-r--r--)
767+
# This must be done before rename to maintain atomicity
768+
os.chmod(tmp_filename, stat.S_IRUSR | stat.S_IWUSR | stat.S_IRGRP | stat.S_IROTH)
769+
764770
# Atomically rename the temporary file to the target filename
765-
# On POSIX systems, this is an atomic operation
771+
# On POSIX systems, this is an atomic operation that preserves permissions
766772
os.replace(tmp_filename, out_filename)
767773

768774
except (IOError, OSError) as err:

0 commit comments

Comments
 (0)