From 00542ded608212e8245429001f1a0a0a736f2e71 Mon Sep 17 00:00:00 2001 From: Tom Clegg Date: Thu, 5 May 2022 17:42:46 -0400 Subject: [PATCH] 18794: Make "touch restart.txt" recipe work when owned by root. If root has done "touch {tmp}/restart.txt", then the www-data user cannot utime() or write() the existing file, but can remove it and create a new one. Arvados-DCO-1.1-Signed-off-by: Tom Clegg --- apps/workbench/config/initializers/reload_config.rb | 3 +++ services/api/config/initializers/reload_config.rb | 3 +++ 2 files changed, 6 insertions(+) diff --git a/apps/workbench/config/initializers/reload_config.rb b/apps/workbench/config/initializers/reload_config.rb index 259f54732c..58949c5e93 100644 --- a/apps/workbench/config/initializers/reload_config.rb +++ b/apps/workbench/config/initializers/reload_config.rb @@ -54,6 +54,9 @@ else begin File.utime(touchtime, touchtime, restartfile) rescue + # remove + re-create works even if the existing file is + # owned by root, provided the tempdir is writable. + File.unlink(restartfile) rescue nil File.open(restartfile, 'w') {} end # Even if passenger doesn't notice that we hit restart.txt diff --git a/services/api/config/initializers/reload_config.rb b/services/api/config/initializers/reload_config.rb index 65f02e07a4..1582855bfb 100644 --- a/services/api/config/initializers/reload_config.rb +++ b/services/api/config/initializers/reload_config.rb @@ -50,6 +50,9 @@ else begin File.utime(touchtime, touchtime, restartfile) rescue + # remove + re-create works even if the existing file is + # owned by root, provided the tempdir is writable. + File.unlink(restartfile) rescue nil File.open(restartfile, 'w') {} end # Even if passenger doesn't notice that we hit restart.txt -- 2.30.2