Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 18 additions & 2 deletions client/gpgcheck.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ TDNFGPGCheck(
goto cleanup;
}

#ifndef BUILD_WITH_RPM_6X
uint32_t
ReadGPGKeyFile(
const char* pszFile,
Expand Down Expand Up @@ -105,6 +106,7 @@ ReadGPGKeyFile(
TDNF_SAFE_FREE_MEMORY(pszKeyData);
goto cleanup;
}
#endif

uint32_t
AddKeyFileToKeyring(
Expand Down Expand Up @@ -159,19 +161,30 @@ TDNFImportGPGKeyFile(
)
{
uint32_t dwError = 0;
int nKeys = 0;
#ifdef BUILD_WITH_RPM_6X
const char *argv[] = {pszFile, NULL};
#else
uint8_t* pPkt = NULL;
size_t nPktLen = 0;
char* pszKeyData = NULL;
int nKeyDataSize;
int nKeys = 0;
int nKeyDataSize = 0;
int nOffset = 0;
#endif

if(pTS == NULL || IsNullOrEmptyString(pszFile))
{
dwError = ERROR_TDNF_INVALID_PARAMETER;
BAIL_ON_TDNF_ERROR(dwError);
}

#ifdef BUILD_WITH_RPM_6X
if (rpmcliImportPubkeys(pTS, (ARGV_const_t)argv) != 0) {
dwError = ERROR_TDNF_INVALID_PUBKEY_FILE;
BAIL_ON_TDNF_ERROR(dwError);
}
nKeys = 1;
#else
dwError = ReadGPGKeyFile(pszFile, &pszKeyData, &nKeyDataSize);
BAIL_ON_TDNF_ERROR(dwError);

Expand All @@ -186,14 +199,17 @@ TDNFImportGPGKeyFile(
}
nOffset += nPktLen;
}
#endif

if (nKeys == 0) {
dwError = ERROR_TDNF_INVALID_PUBKEY_FILE;
BAIL_ON_TDNF_ERROR(dwError);
}

cleanup:
#ifndef BUILD_WITH_RPM_6X
TDNF_SAFE_FREE_MEMORY(pszKeyData);
#endif
return dwError;
error:
goto cleanup;
Expand Down
2 changes: 2 additions & 0 deletions client/prototypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,14 @@ TDNFApplyScopeFilter(
);

//gpgcheck.c
#ifndef BUILD_WITH_RPM_6X
uint32_t
ReadGPGKeyFile(
const char* pszFile,
char** ppszKeyData,
int* pnSize
);
#endif

uint32_t
AddKeyFileToKeyring(
Expand Down
Loading