]> git.tuebingen.mpg.de Git - dss.git/commit
Fix --config-file for relative paths. master
authorAndre Noll <maan@tuebingen.mpg.de>
Tue, 19 Sep 2023 14:31:49 +0000 (16:31 +0200)
committerAndre Noll <maan@tuebingen.mpg.de>
Tue, 7 Nov 2023 14:11:55 +0000 (15:11 +0100)
commitcac14c7d96355a9ca02f69627f01ddebe699afcc
tree4b110e9c5ec0608b2dc2823bef0e334feb414718
parentbf0f03c00f6de518d01b6cb1e94c1d447e5cd3b1
Fix --config-file for relative paths.

The dss lock works by first turning the given config file path
argument into a canonical absolute path using dss_realpath(), then
hashing this absolute path to obtain a key ID for semget(2).

If the given path is relative, we have to compute the ID before
changing to the destination directory because dss_realpath() needs to
call stat(2) to detect symlinks, and this system call will fail if the
current working directory has changed. This is currently not the case
as we change to the destination directory early in check_config().

If dss_realpath() fails, we silently use the unmodified path argument
for hashing to deal with the case that the default config does not
exist. As a result, if relative paths are given, the key ID depends
on whether or not change_to_dest_dir() was called. This is the case
for the run subcommanmd, but not for the kill subcommand. Thus the
kill subcommand does not work as expected if a relative path is given.

Fix this by grabbing the lock before changing the working directory
in all cases.
dss.c