execute: don't fail if we create the runtime directory from two processes simultaneously
authorLennart Poettering <lennart@poettering.net>
Thu, 6 Aug 2015 11:53:15 +0000 (14:53 +0300)
committerLennart Poettering <lennart@poettering.net>
Thu, 6 Aug 2015 11:56:20 +0000 (14:56 +0300)
commit6bfe5c28cad4716ed3ff6667c1546b5e180391fb
tree7111d9c6e833312e4dee535da209905f8881b9ad
parent5df0997459fef2a3d3e15fcb1f4aa8d0643231aa
execute: don't fail if we create the runtime directory from two processes simultaneously

If a service has both ExecStart= and ExecStartPost= set with
Type=simple, then it might happen that we have two children create the
runtime directory of a service (as configured with RuntimeDirectory=) at
the same time. Previously we did this with mkdir_safe() which will
create the dir only if it is missing, but if it already exists will at
least verify the access mode and ownership to match the right values.
This is problematic in this case, since it creates and then adjusts the
settings, thus it might happen that one child creates the directory with
root owner, another one then verifies it, and only afterwards the
directory ownership is fixed by the original child, while the second
child already failed.

With this change we'll now always adjust the access mode, so that we
know that it is right. In the worst case this means we adjust the
mode/ownership even though its unnecessary, but this should have no
negative effect.

https://bugzilla.redhat.com/show_bug.cgi?id=1226509
src/core/execute.c