From 83d6f50cc4845a2f5154f9041a2d33cb2110f0ba Mon Sep 17 00:00:00 2001 From: Matthias Leutenegger Date: Mon, 1 Jun 2020 19:38:08 +0200 Subject: [PATCH 1/6] Update restic_access_Linux.j2 --- templates/restic_access_Linux.j2 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/templates/restic_access_Linux.j2 b/templates/restic_access_Linux.j2 index 8c52cdc..554073d 100644 --- a/templates/restic_access_Linux.j2 +++ b/templates/restic_access_Linux.j2 @@ -4,12 +4,12 @@ # Source this file to work with restic on this host export RESTIC_REPOSITORY={{ restic_repos[item.repo].location }} -export RESTIC_PASSWORD={{ restic_repos[item.repo].password }} +export RESTIC_PASSWORD="{{ restic_repos[item.repo].password | regex_escape() }}" {% if restic_repos[item.repo].aws_access_key is defined %} export AWS_ACCESS_KEY_ID={{ restic_repos[item.repo].aws_access_key }} {% endif %} {% if restic_repos[item.repo].aws_secret_access_key is defined %} -export AWS_SECRET_ACCESS_KEY={{ restic_repos[item.repo].aws_secret_access_key }} +export AWS_SECRET_ACCESS_KEY="{{ restic_repos[item.repo].aws_secret_access_key | regex_escape() }}" {% endif %} {% if restic_repos[item.repo].aws_default_region is defined %} export AWS_DEFAULT_REGION={{ restic_repos[item.repo].aws_default_region }} From d4ee01a305ff5a4f80d307325fe4e3d82fe36d48 Mon Sep 17 00:00:00 2001 From: Matthias Leutenegger Date: Mon, 1 Jun 2020 19:39:47 +0200 Subject: [PATCH 2/6] CHANGE: use regex_escape() --- templates/restic_script_Linux.j2 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/templates/restic_script_Linux.j2 b/templates/restic_script_Linux.j2 index 8374200..df46df3 100644 --- a/templates/restic_script_Linux.j2 +++ b/templates/restic_script_Linux.j2 @@ -4,13 +4,13 @@ # Use this file to create a Backup and prune existing data with one execution. export RESTIC_REPOSITORY={{ restic_repos[item.repo].location }} -export RESTIC_PASSWORD={{ restic_repos[item.repo].password }} +export RESTIC_PASSWORD="{{ restic_repos[item.repo].password | regex_escape() }}" BACKUP_NAME={{ item.name }} {% if restic_repos[item.repo].aws_access_key is defined %} export AWS_ACCESS_KEY_ID={{ restic_repos[item.repo].aws_access_key }} {% endif %} {% if restic_repos[item.repo].aws_secret_access_key is defined %} -export AWS_SECRET_ACCESS_KEY={{ restic_repos[item.repo].aws_secret_access_key }} +export AWS_SECRET_ACCESS_KEY="{{ restic_repos[item.repo].aws_secret_access_key | regex_escape() }}" {% endif %} {% if restic_repos[item.repo].aws_default_region is defined %} export AWS_DEFAULT_REGION={{ restic_repos[item.repo].aws_default_region }} From 3559119fee083cbe150e913499e7c6a68ac2084c Mon Sep 17 00:00:00 2001 From: Matthias Leutenegger Date: Mon, 1 Jun 2020 19:41:45 +0200 Subject: [PATCH 3/6] CHANGE: update changelog --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 412cd18..329e7e9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,9 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm and [human-readable changelog](https://keepachangelog.com/en/1.0.0/). ## Unreleased +### Changed +* Password now use `regex_escape()` filter in templates + ## [0.2.4] - 2020-06-01 ### Added * `aws_default_region` for repos From 60b29a64a74e525e268c5bdb32fda4f9e225a560 Mon Sep 17 00:00:00 2001 From: Matthias Leutenegger Date: Wed, 3 Jun 2020 08:52:02 +0200 Subject: [PATCH 4/6] CHANGE: use solution proposed by @alt4 --- templates/restic_access_Linux.j2 | 2 +- templates/restic_script_Linux.j2 | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/templates/restic_access_Linux.j2 b/templates/restic_access_Linux.j2 index 554073d..ca0c313 100644 --- a/templates/restic_access_Linux.j2 +++ b/templates/restic_access_Linux.j2 @@ -4,7 +4,7 @@ # Source this file to work with restic on this host export RESTIC_REPOSITORY={{ restic_repos[item.repo].location }} -export RESTIC_PASSWORD="{{ restic_repos[item.repo].password | regex_escape() }}" +export RESTIC_PASSWORD='{{ restic_repos[item.repo].password | regex_replace('\'', '\'\\\'\'') }}' {% if restic_repos[item.repo].aws_access_key is defined %} export AWS_ACCESS_KEY_ID={{ restic_repos[item.repo].aws_access_key }} {% endif %} diff --git a/templates/restic_script_Linux.j2 b/templates/restic_script_Linux.j2 index df46df3..e6f42ea 100644 --- a/templates/restic_script_Linux.j2 +++ b/templates/restic_script_Linux.j2 @@ -4,7 +4,7 @@ # Use this file to create a Backup and prune existing data with one execution. export RESTIC_REPOSITORY={{ restic_repos[item.repo].location }} -export RESTIC_PASSWORD="{{ restic_repos[item.repo].password | regex_escape() }}" +export RESTIC_PASSWORD='{{ restic_repos[item.repo].password | regex_replace('\'', '\'\\\'\'') }}' BACKUP_NAME={{ item.name }} {% if restic_repos[item.repo].aws_access_key is defined %} export AWS_ACCESS_KEY_ID={{ restic_repos[item.repo].aws_access_key }} From a563473b58bbfadc2c3780e44a15304b2b5c846f Mon Sep 17 00:00:00 2001 From: Matthias Leutenegger Date: Wed, 3 Jun 2020 22:45:20 +0200 Subject: [PATCH 5/6] CHANGE: update all vars --- templates/restic_access_Linux.j2 | 2 +- templates/restic_script_Linux.j2 | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/templates/restic_access_Linux.j2 b/templates/restic_access_Linux.j2 index ca0c313..9c35506 100644 --- a/templates/restic_access_Linux.j2 +++ b/templates/restic_access_Linux.j2 @@ -9,7 +9,7 @@ export RESTIC_PASSWORD='{{ restic_repos[item.repo].password | regex_replace('\'' export AWS_ACCESS_KEY_ID={{ restic_repos[item.repo].aws_access_key }} {% endif %} {% if restic_repos[item.repo].aws_secret_access_key is defined %} -export AWS_SECRET_ACCESS_KEY="{{ restic_repos[item.repo].aws_secret_access_key | regex_escape() }}" +export AWS_SECRET_ACCESS_KEY="{{ restic_repos[item.repo].aws_secret_access_key | regex_replace('\'', '\'\\\'\'') }}" {% endif %} {% if restic_repos[item.repo].aws_default_region is defined %} export AWS_DEFAULT_REGION={{ restic_repos[item.repo].aws_default_region }} diff --git a/templates/restic_script_Linux.j2 b/templates/restic_script_Linux.j2 index e6f42ea..00f153b 100644 --- a/templates/restic_script_Linux.j2 +++ b/templates/restic_script_Linux.j2 @@ -10,7 +10,7 @@ BACKUP_NAME={{ item.name }} export AWS_ACCESS_KEY_ID={{ restic_repos[item.repo].aws_access_key }} {% endif %} {% if restic_repos[item.repo].aws_secret_access_key is defined %} -export AWS_SECRET_ACCESS_KEY="{{ restic_repos[item.repo].aws_secret_access_key | regex_escape() }}" +export AWS_SECRET_ACCESS_KEY="{{ restic_repos[item.repo].aws_secret_access_key | regex_replace('\'', '\'\\\'\'') }}" {% endif %} {% if restic_repos[item.repo].aws_default_region is defined %} export AWS_DEFAULT_REGION={{ restic_repos[item.repo].aws_default_region }} From 9bc6c06debb1896da3f278885c41db71e06f5471 Mon Sep 17 00:00:00 2001 From: Matthias Leutenegger Date: Thu, 4 Jun 2020 19:22:47 +0200 Subject: [PATCH 6/6] CHANGE: use single quotes --- templates/restic_access_Linux.j2 | 2 +- templates/restic_script_Linux.j2 | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/templates/restic_access_Linux.j2 b/templates/restic_access_Linux.j2 index 9c35506..f9b62dd 100644 --- a/templates/restic_access_Linux.j2 +++ b/templates/restic_access_Linux.j2 @@ -9,7 +9,7 @@ export RESTIC_PASSWORD='{{ restic_repos[item.repo].password | regex_replace('\'' export AWS_ACCESS_KEY_ID={{ restic_repos[item.repo].aws_access_key }} {% endif %} {% if restic_repos[item.repo].aws_secret_access_key is defined %} -export AWS_SECRET_ACCESS_KEY="{{ restic_repos[item.repo].aws_secret_access_key | regex_replace('\'', '\'\\\'\'') }}" +export AWS_SECRET_ACCESS_KEY='{{ restic_repos[item.repo].aws_secret_access_key | regex_replace('\'', '\'\\\'\'') }}' {% endif %} {% if restic_repos[item.repo].aws_default_region is defined %} export AWS_DEFAULT_REGION={{ restic_repos[item.repo].aws_default_region }} diff --git a/templates/restic_script_Linux.j2 b/templates/restic_script_Linux.j2 index 00f153b..5f90e10 100644 --- a/templates/restic_script_Linux.j2 +++ b/templates/restic_script_Linux.j2 @@ -10,7 +10,7 @@ BACKUP_NAME={{ item.name }} export AWS_ACCESS_KEY_ID={{ restic_repos[item.repo].aws_access_key }} {% endif %} {% if restic_repos[item.repo].aws_secret_access_key is defined %} -export AWS_SECRET_ACCESS_KEY="{{ restic_repos[item.repo].aws_secret_access_key | regex_replace('\'', '\'\\\'\'') }}" +export AWS_SECRET_ACCESS_KEY='{{ restic_repos[item.repo].aws_secret_access_key | regex_replace('\'', '\'\\\'\'') }}' {% endif %} {% if restic_repos[item.repo].aws_default_region is defined %} export AWS_DEFAULT_REGION={{ restic_repos[item.repo].aws_default_region }}