Control: tags -1 +patch

On Fri, 10 Jan 2025 11:41:25 +0100 Didier 'OdyX' Raboud <o...@debian.org> 
wrote:
> Package: backupninja
> Version: 1.2.2-1
> Severity: important
> Tags: upstream
> 
> Dear Maintainer,
> 
> While wanting to use backupninja to orchestrate restic to backup towards
> Infomaniak's Swissbackup, I noticed that it doesn't support the neededt
> OS_PROJECT_* and other variables needed for keystone v3 authentication.
> This is documented at the restic side here:
> https://restic.readthedocs.io/en/latest/
030_preparing_a_new_repo.html#openstack-swift
> and it looks like a similar issue was reported upstream here:
> https://0xacab.org/liberate/backupninja/-/issues/11331 (but I did not
> manage to get an account there yet).
> 
> Would it be useful to provide a patch here?

Hello there Jérôme,

as discussed yesterday at DebConf, here comes a patch that I have successfully 
tested for Swift Keystone v3 authentication.

I don't have Swift Keystone v2 at hand, but I'm quite confident in the logic I 
wrote (but really happy for a second pair of eyes!).

Anything more I could do to get this integrated?

Best,

  OdyX
>From 7563762321c10c808fa1dc311c98144e11d4e5a1 Mon Sep 17 00:00:00 2001
From: Didier Raboud <o...@debian.org>
Date: Tue, 15 Jul 2025 09:39:49 +0200
Subject: [PATCH] Support Swift v3 in addition to Swift v2

Bug-Upstream: https://0xacab.org/liberate/backupninja/-/issues/11331
Bug-Debian: https://bugs.debian.org/1092640
---
 examples/example.restic | 19 ++++++++++++
 handlers/restic.in      | 64 ++++++++++++++++++++++++++++++++++-------
 2 files changed, 72 insertions(+), 11 deletions(-)

diff --git a/examples/example.restic b/examples/example.restic
index 9fbb124..4507d6a 100644
--- a/examples/example.restic
+++ b/examples/example.restic
@@ -95,6 +95,7 @@ password = secret
 #aws_session_token =
 
 [swift]
+## swift v2 needs:
 
 #os_auth_url =
 
@@ -108,6 +109,24 @@ password = secret
 
 #os_region_name =
 
+## swift v3 needs:
+
+#os_identity_api_version = 3
+
+#os_auth_url =
+
+## One of
+#os_tenant_id =
+#os_tenant_name =
+
+#os_username =
+
+#os_password =
+
+#os_region_name =
+
+#os_user_domain_name =
+
 [b2]
 
 #b2_account_id =
diff --git a/handlers/restic.in b/handlers/restic.in
index 28cf099..9ac8f02 100644
--- a/handlers/restic.in
+++ b/handlers/restic.in
@@ -45,6 +45,8 @@ getconf os_tenant_name
 getconf os_username
 getconf os_password
 getconf os_region_name
+getconf os_identity_api_version
+getconf os_user_domain_name
 
 setsection b2
 
@@ -154,18 +156,58 @@ fi
 # OpenStack Swift repository
 if [ "$(echo "$repository" | @AWK@ -F ':' '{print $1}')" == "swift" ]; then
 
-  (
-    [ -z "$os_auth_url" ] || [ -z "$os_tenant_id" ] || [ -z "$os_tenant_name" ] || \
-    [ -z "$os_username" ] || [ -z "$os_password" ] || [ -z "$os_region_name" ]
-  ) && \
-    fatal "Missing some Swift credentials."
+  # swift v2 needs:
+  ## $os_auth_url
+  ## $os_tenant_id
+  ## $os_tenant_name
+  ## $os_username
+  ## $os_password
+  ## $os_region_name
 
-  export_debug OS_AUTH_URL "$os_auth_url"
-  export_debug OS_TENANT_ID "$os_tenant_id"
-  export_debug OS_TENANT_NAME "$os_tenant_name"
-  export_debug OS_USERNAME "$os_username"
-  export_debug OS_PASSWORD "$os_password"
-  export_debug OS_REGION_NAME "$os_region_name"
+  # swift v3 needs:
+  ## $os_identity_api_version == 3
+  ## $os_auth_url
+  ## $os_tenant_id OR $os_tenant_name
+  ## $os_username
+  ## $os_password
+  ## $os_region_name
+  ## $os_user_domain_name
+
+  if [ -z "$os_identity_api_version" -o "$os_identity_api_version" = "2" ]; then
+    if (
+      [ -z "$os_auth_url" ] || [ -z "$os_tenant_id" ] || [ -z "$os_tenant_name" ] || \
+      [ -z "$os_username" ] || [ -z "$os_password" ] || [ -z "$os_region_name" ]
+    ); then
+      fatal "Missing some Swift v2 credentials."
+    fi
+
+    export_debug OS_AUTH_URL "$os_auth_url"
+    export_debug OS_TENANT_ID "$os_tenant_id"
+    export_debug OS_TENANT_NAME "$os_tenant_name"
+    export_debug OS_USERNAME "$os_username"
+    export_debug OS_PASSWORD "$os_password"
+    export_debug OS_REGION_NAME "$os_region_name"
+
+  elif [ "$os_identity_api_version" = "3" ]; then
+    if (
+      [ -z "$os_auth_url" ] || [ -z "$os_tenant_id" -a -z "$os_tenant_name" ] || \
+      [ -z "$os_username" ] || [ -z "$os_password" ] || [ -z "$os_region_name" ] || \
+      [ -z "$os_user_domain_name" ]
+    ); then
+      fatal "Missing some Swift v3 credentials."
+    fi
+
+    export_debug OS_AUTH_URL "$os_auth_url"
+    if [ -n "$os_tenant_id" ]; then
+      export_debug OS_TENANT_ID "$os_tenant_id"
+    else
+      export_debug OS_TENANT_NAME "$os_tenant_name"
+    fi
+    export_debug OS_USERNAME "$os_username"
+    export_debug OS_PASSWORD "$os_password"
+    export_debug OS_REGION_NAME "$os_region_name"
+    export_debug OS_USER_DOMAIN_NAME "$os_user_domain_name"
+  fi
 
 fi
 
-- 
2.47.2

Attachment: signature.asc
Description: This is a digitally signed message part.

Reply via email to