1
0
mirror of https://github.com/pgbackrest/pgbackrest.git synced 2025-07-15 01:04:37 +02:00

Add user-id/group-id to hrnReplaceKey().

This commit is contained in:
David Steele
2019-11-15 17:50:12 -05:00
parent 53a2d04ab0
commit c8db11e65b
2 changed files with 12 additions and 0 deletions

View File

@ -38,7 +38,9 @@ static const char *testPathData = NULL;
static const char *testDataPathData = NULL;
static const char *testRepoPathData = NULL;
static char testUserIdData[32];
static char testUserData[64];
static char testGroupIdData[32];
static char testGroupData[64];
/***********************************************************************************************************************************
@ -69,6 +71,9 @@ hrnInit(
testDataPathData = testDataPath;
testRepoPathData = testRepoPath;
// Set test user id
snprintf(testUserIdData, sizeof(testUserIdData), "%u", getuid());
// Set test user
const char *testUserTemp = getpwuid(getuid())->pw_name;
@ -81,6 +86,9 @@ hrnInit(
strcpy(testUserData, testUserTemp);
// Set test group id
snprintf(testGroupIdData, sizeof(testGroupIdData), "%u", getgid());
// Set test group
const char *testGroupTemp = getgrgid(getgid())->gr_name;
@ -268,7 +276,9 @@ hrnReplaceKey(const char *string)
strcpy(harnessReplaceKeyBuffer, string);
hrnReplaceStr(harnessReplaceKeyBuffer, sizeof(harnessReplaceKeyBuffer), "{[path]}", testPath());
hrnReplaceStr(harnessReplaceKeyBuffer, sizeof(harnessReplaceKeyBuffer), "{[path-data]}", testDataPath());
hrnReplaceStr(harnessReplaceKeyBuffer, sizeof(harnessReplaceKeyBuffer), "{[user-id]}", testUserIdData);
hrnReplaceStr(harnessReplaceKeyBuffer, sizeof(harnessReplaceKeyBuffer), "{[user]}", testUser());
hrnReplaceStr(harnessReplaceKeyBuffer, sizeof(harnessReplaceKeyBuffer), "{[group-id]}", testGroupIdData);
hrnReplaceStr(harnessReplaceKeyBuffer, sizeof(harnessReplaceKeyBuffer), "{[group]}", testGroup());
hrnReplaceStr(harnessReplaceKeyBuffer, sizeof(harnessReplaceKeyBuffer), "{[project-exe]}", testProjectExe());

View File

@ -32,7 +32,9 @@ void hrnFileWrite(const char *fileName, const unsigned char *buffer, size_t buff
//
// {[path]} - the current test path
// {[path-data]} - the current test data path
// {[user-id]} - the current test user id
// {[user]} - the current test user
// {[group-id]} - the current test group id
// {[group]} - the current test group
// {[project-exe]} - the project exe
const char *hrnReplaceKey(const char *string);