file_lock: Fix the permission issue of firmware_utility_lock
In flashrom, a firmware_utility_lock file is created. This lock ensures
that only one instance of flashrom runs at a time.
However, if we executes flashrom once with sudo and then again without
sudo, we will get a failure because the lockfile was initially created
by root with permission 0600 (rw for root only). Subsequent commands,
run without root, couldn't open this lockfile.
This change modifies the permissions of the lockfile to 0666 using
fchmod() immediately after creation. This ensures that all users have
the necessary access to acquire and release the lock, regardless of
whether they are running with or without sudo.
BUG=b:350876583
BUG=b:347861737, b:349020118
TEST=sudo flashrom && sudo -u user flashrom
TEST=ls -la /run/lock/firmware_utility_lock
Change-Id: I5c8e9c023bfce416bd664e10161cc7661340e5b3
Signed-off-by: Hsuan Ting Chen <roccochen@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/flashrom/+/5667448
Reviewed-by: Jian-Jia Su <jjsu@chromium.org>
1 file changed