site_linux_router: truncate (not delete) uma-events
We're removing this file, but that can confuse other daemons, which may
then accidentally re-create the file with different owners/permissions,
locking out non-root daemons.
Rather than tease out the expected permissions or force all system
daemons to configure the correct owners/permissions, let's just avoid
deleting the file -- we can truncate it instead, which will retain its
original permissions.
Noticed in b:131906820, where shill is repeatedly complaining:
ERR shill[646]: [ERROR:serialization_utils.cc(290)] /var/lib/metrics/uma-events: cannot open: Permission denied
BUG=none
TEST=run network_WiFi_* test; watch size, permissions of .../uma-events
Change-Id: I8096917d385bab44444c8252acf702eab7a18407
Reviewed-on: https://chromium-review.googlesource.com/1600456
Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com>
Tested-by: Brian Norris <briannorris@chromium.org>
Reviewed-by: Brian Norris <briannorris@chromium.org>
Reviewed-by: Harpreet Grewal <harpreet@chromium.org>
diff --git a/server/site_linux_router.py b/server/site_linux_router.py
index e8b492a..cfab7cc 100644
--- a/server/site_linux_router.py
+++ b/server/site_linux_router.py
@@ -119,6 +119,8 @@
_RNG_AVAILABLE = '/sys/class/misc/hw_random/rng_available'
_RNG_CURRENT = '/sys/class/misc/hw_random/rng_current'
+ _UMA_EVENTS = '/var/lib/metrics/uma-events'
+
def get_capabilities(self):
"""@return iterable object of AP capabilities for this system."""
caps = set()
@@ -188,7 +190,9 @@
# TODO(crbug.com/839164): some routers fill their stateful partition
# with uncollected metrics.
- self.host.run('rm -f /var/lib/metrics/uma-events', ignore_status=True)
+ if self.host.path_exists(self._UMA_EVENTS):
+ self.host.run('truncate -s 0 %s' % self._UMA_EVENTS,
+ ignore_status=True)
# Log the most recent message on the router so that we can rebuild the
# suffix relevant to us when debugging failures.