URL: https://github.com/SSSD/sssd/pull/5643
Author: justin-stephenson
 Title: #5643: SECRETS: Resolve mkey path correctly
Action: opened

PR body:
"""
Use the correct master key path for the secrets database,
fixing an issue on upgrade.
"""

To pull the PR as Git branch:
git remote add ghsssd https://github.com/SSSD/sssd
git fetch ghsssd pull/5643/head:pr5643
git checkout pr5643
From 820376e3a54a053b1f98bc67e03b8e282b16ac96 Mon Sep 17 00:00:00 2001
From: Justin Stephenson <[email protected]>
Date: Wed, 19 May 2021 10:54:52 -0400
Subject: [PATCH] SECRETS: Resolve mkey path correctly

Use the correct master key path for the secrets database,
fixing an issue on upgrade.
---
 src/util/secrets/secrets.c | 10 ++++++----
 src/util/secrets/secrets.h |  1 +
 2 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/src/util/secrets/secrets.c b/src/util/secrets/secrets.c
index 42df14aa9c..2801eb2426 100644
--- a/src/util/secrets/secrets.c
+++ b/src/util/secrets/secrets.c
@@ -634,13 +634,13 @@ static int generate_master_key(const char *filename, size_t size)
 }
 
 static errno_t lcl_read_mkey(TALLOC_CTX *mem_ctx,
-                             const char *dbpath,
+                             const char *mkeypath,
                              struct sss_sec_data *master_key)
 {
     int mfd;
     ssize_t size;
     errno_t ret;
-    const char *mkey = dbpath;
+    const char *mkey = mkeypath;
 
     master_key->data = talloc_size(mem_ctx, MKEY_SIZE);
     if (master_key->data == NULL) {
@@ -703,6 +703,7 @@ static int set_quotas(struct sss_sec_ctx *sec_ctx,
 errno_t sss_sec_init_with_path(TALLOC_CTX *mem_ctx,
                                struct sss_sec_hive_config **config_list,
                                const char *dbpath,
+                               const char *mkeypath,
                                struct sss_sec_ctx **_sec_ctx)
 {
     struct sss_sec_ctx *sec_ctx;
@@ -746,7 +747,7 @@ errno_t sss_sec_init_with_path(TALLOC_CTX *mem_ctx,
         goto done;
     }
 
-    ret = lcl_read_mkey(sec_ctx, dbpath, &sec_ctx->master_key);
+    ret = lcl_read_mkey(sec_ctx, mkeypath, &sec_ctx->master_key);
     if (ret != EOK) {
         DEBUG(SSSDBG_OP_FAILURE, "Cannot get the master key\n");
         goto done;
@@ -764,9 +765,10 @@ errno_t sss_sec_init(TALLOC_CTX *mem_ctx,
                      struct sss_sec_ctx **_sec_ctx)
 {
     const char *dbpath = SECRETS_DB_PATH"/secrets.ldb";
+    const char *mkeypath = SECRETS_DB_PATH"/.secrets.mkey";
     errno_t ret;
 
-    ret = sss_sec_init_with_path(mem_ctx, config_list, dbpath, _sec_ctx);
+    ret = sss_sec_init_with_path(mem_ctx, config_list, dbpath, mkeypath, _sec_ctx);
     if (ret != EOK) {
         DEBUG(SSSDBG_CRIT_FAILURE, "Failed to initialize secdb [%d]: %s\n",
                                    ret, sss_strerror(ret));
diff --git a/src/util/secrets/secrets.h b/src/util/secrets/secrets.h
index a15b99ffec..958f0824b5 100644
--- a/src/util/secrets/secrets.h
+++ b/src/util/secrets/secrets.h
@@ -83,6 +83,7 @@ errno_t sss_sec_init(TALLOC_CTX *mem_ctx,
 errno_t sss_sec_init_with_path(TALLOC_CTX *mem_ctx,
                                struct sss_sec_hive_config **config_list,
                                const char *dbpath,
+                               const char *mkeypath,
                                struct sss_sec_ctx **_sec_ctx);
 
 errno_t sss_sec_new_req(TALLOC_CTX *mem_ctx,
_______________________________________________
sssd-devel mailing list -- [email protected]
To unsubscribe send an email to [email protected]
Fedora Code of Conduct: 
https://docs.fedoraproject.org/en-US/project/code-of-conduct/
List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines
List Archives: 
https://lists.fedorahosted.org/archives/list/[email protected]
Do not reply to spam on the list, report it: 
https://pagure.io/fedora-infrastructure

Reply via email to