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
tree: 22e341770f882b96d5599c31c7dd9db434848f72
  1. .github/
  2. bindings/
  3. doc/
  4. include/
  5. Makefile.d/
  6. meson_cross/
  7. platform/
  8. scripts/
  9. subprojects/
  10. tests/
  11. util/
  12. .gitattributes
  13. .gitignore
  14. 82802ab.c
  15. action_descriptor.c
  16. action_descriptor.h
  17. amd_imc.c
  18. asm106x.c
  19. at45db.c
  20. atahpt.c
  21. atapromise.c
  22. atavia.c
  23. big_lock.c
  24. big_lock.h
  25. bitbang_spi.c
  26. board_enable.c
  27. buspirate_spi.c
  28. cbtable.c
  29. ch341a_spi.c
  30. ch347_spi.c
  31. chipset_enable.c
  32. cli_classic.c
  33. cli_common.c
  34. cli_getopt.c
  35. cli_output.c
  36. COPYING
  37. cros_ec.c
  38. cros_ec_commands.h
  39. custom_baud.c
  40. custom_baud_darwin.c
  41. custom_baud_linux.c
  42. dediprog.c
  43. developerbox_spi.c
  44. digilent_spi.c
  45. DIR_METADATA
  46. dirtyjtag_spi.c
  47. dmi.c
  48. Doxyfile
  49. drkaiser.c
  50. dummyflasher.c
  51. edi.c
  52. en29lv640b.c
  53. erasure_layout.c
  54. file_lock.c
  55. flashchips.c
  56. flashchips_crosbl.c
  57. flashrom.c
  58. fmap.c
  59. ft2232_spi.c
  60. gfxnvidia.c
  61. helpers.c
  62. helpers_fileio.c
  63. hwaccess_physmap.c
  64. hwaccess_x86_io.c
  65. hwaccess_x86_msr.c
  66. i2c_helper_linux.c
  67. ich_descriptors.c
  68. ichspi.c
  69. internal.c
  70. internal_par.c
  71. ipc_lock.h
  72. it8212.c
  73. it87spi.c
  74. jedec.c
  75. jlink_spi.c
  76. known_boards.c
  77. layout.c
  78. libflashrom.c
  79. libflashrom.map
  80. linux_mtd.c
  81. linux_spi.c
  82. MAINTAINERS
  83. Makefile
  84. Makefile.include
  85. mcp6x_spi.c
  86. mediatek_i2c_spi.c
  87. meson.build
  88. meson_options.txt
  89. mstarddc_spi.c
  90. ni845x_spi.c
  91. nic3com.c
  92. nicintel.c
  93. nicintel_eeprom.c
  94. nicintel_spi.c
  95. nicnatsemi.c
  96. nicrealtek.c
  97. ogp_spi.c
  98. opaque.c
  99. OWNERS
  100. parade_lspcon.c
  101. parallel.c
  102. pcidev.c
  103. pickit2_spi.c
  104. pony_spi.c
  105. power.c
  106. power.h
  107. PRESUBMIT.cfg
  108. print.c
  109. print_wiki.c
  110. printlock.c
  111. processor_enable.c
  112. programmer.c
  113. programmer_table.c
  114. raiden_debug_spi.c
  115. rayer_spi.c
  116. README.chromiumos
  117. README.rst
  118. realtek_mst_i2c_spi.c
  119. s25f.c
  120. satamv.c
  121. satasii.c
  122. sb600spi.c
  123. serial.c
  124. serprog.c
  125. sfdp.c
  126. spi.c
  127. spi25.c
  128. spi25_statusreg.c
  129. spi95.c
  130. sst28sf040.c
  131. sst49lfxxxc.c
  132. sst_fwhub.c
  133. stlinkv3_spi.c
  134. stm50.c
  135. superio.c
  136. test_build.sh
  137. udelay.c
  138. udelay_dos.c
  139. unblocked_terms.txt
  140. usb_device.c
  141. usbblaster_spi.c
  142. usbdev.c
  143. VERSION
  144. w29ee011.c
  145. w39.c
  146. wbsio_spi.c
  147. writeprotect.c
  148. writeprotect_ranges.c