I have a process, which generates a file with configuration data and then calls a subprocess with this data as parameter. I'd like to override the configuration data, which is passed. The problem is, that I have no control over that process.I've tried to make the file immutable using chattr +i so that my changes get untouched from the process, but the process creating the file returns an error.So is there another option, that I can use?EDIT:More specific:processA deletes settings.ovpn and then creates it again with the new content. Then it calls openvpn --settings settings.opvn. I want to override settings.ovpn, because it is generated wrong.
Ignore file changes
shell;files;filesystems
It should be possible to replace the subprocess binary with a wrapper script (at least within a separate name space).#! /bin/bash: replace the file or change the config file argumentexec /real/binary $config_fileIf that is not possible then the file could be replaced by something special (if it is allowed to exist when the main process starts):With a loop device, device mapper, the target flakey and the option drop_writesyou can create a block device which discards writes:https://www.kernel.org/doc/Documentation/device-mapper/dm-flakey.txtIf the process creates a bigger file than the intended one then you may have to make the DM device as big. Just put empty lines, comments lines or the like at the end.Maybe it works to make the file a FIFO. Probably the configuration file is written consecutively from start to end i.e. without seeks within the file, just appending. A script would read from that FIFO (would have to be started first:#! /bin/bashread -n 1 dummy# replace the file, i.e. by replacing a symlink which switches # between the FIFO and the real file. The open file descriptor # is not affected by that but the subprocess will open the file # instead of the FIFOcat >/dev/null # throw the input away