From: Tom Clegg Date: Thu, 5 May 2022 21:42:46 +0000 (-0400) Subject: 18794: Make "touch restart.txt" recipe work when owned by root. X-Git-Tag: 2.5.0~184^2~2 X-Git-Url: https://git.arvados.org/arvados.git/commitdiff_plain/00542ded608212e8245429001f1a0a0a736f2e71 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 --- 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