tarsnap service: fix escaping (#150802)

This commit is contained in:
Nikolay Amiantov 2021-12-16 16:53:59 +03:00 committed by GitHub
parent 1e2a8a674d
commit 759f4afc65
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -320,21 +320,22 @@ in
${optionalString cfg.explicitSymlinks "-H"} \
${optionalString cfg.followSymlinks "-L"} \
${concatStringsSep " " cfg.directories}'';
cachedir = escapeShellArg cfg.cachedir;
in if (cfg.cachedir != null) then ''
mkdir -p ${cfg.cachedir}
chmod 0700 ${cfg.cachedir}
mkdir -p ${cachedir}
chmod 0700 ${cachedir}
( flock 9
if [ ! -e ${cfg.cachedir}/firstrun ]; then
if [ ! -e ${cachedir}/firstrun ]; then
( flock 10
flock -u 9
${tarsnap} --fsck
flock 9
) 10>${cfg.cachedir}/firstrun
) 10>${cachedir}/firstrun
fi
) 9>${cfg.cachedir}/lockf
) 9>${cachedir}/lockf
exec flock ${cfg.cachedir}/firstrun ${run}
exec flock ${cachedir}/firstrun ${run}
'' else "exec ${run}";
serviceConfig = {
@ -356,22 +357,23 @@ in
tarsnap = ''tarsnap --configfile "/etc/tarsnap/${name}.conf"'';
lastArchive = "$(${tarsnap} --list-archives | sort | tail -1)";
run = ''${tarsnap} -x -f "${lastArchive}" ${optionalString cfg.verbose "-v"}'';
cachedir = escapeShellArg cfg.cachedir;
in if (cfg.cachedir != null) then ''
mkdir -p ${cfg.cachedir}
chmod 0700 ${cfg.cachedir}
mkdir -p ${cachedir}
chmod 0700 ${cachedir}
( flock 9
if [ ! -e ${cfg.cachedir}/firstrun ]; then
if [ ! -e ${cachedir}/firstrun ]; then
( flock 10
flock -u 9
${tarsnap} --fsck
flock 9
) 10>${cfg.cachedir}/firstrun
) 10>${cachedir}/firstrun
fi
) 9>${cfg.cachedir}/lockf
) 9>${cachedir}/lockf
exec flock ${cfg.cachedir}/firstrun ${run}
exec flock ${cachedir}/firstrun ${run}
'' else "exec ${run}";
serviceConfig = {