Skip to content

Commit

Permalink
Ensure the keyring directory exists when importing to fs keyring
Browse files Browse the repository at this point in the history
This was previously papered over in the test-suite.
  • Loading branch information
pmatilai committed Oct 10, 2024
1 parent 4168b1f commit 4ed1844
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
10 changes: 8 additions & 2 deletions lib/rpmts.cc
Original file line number Diff line number Diff line change
Expand Up @@ -590,8 +590,13 @@ static rpmRC rpmtsImportFSKey(rpmtxn txn, Header h, rpmFlags flags, int replace)
unlink(tmppath);
}

FD_t fd = Fopen(tmppath ? tmppath : path, "wx");
if (fd) {
if (rpmMkdirs(rpmtsRootDir(txn->ts), "%{_keyringpath}")) {
rpmlog(RPMLOG_ERR, _("failed to create keyring directory %s: %s\n"),
path, strerror(errno));
goto exit;
}

if (FD_t fd = Fopen(tmppath ? tmppath : path, "wx")) {
size_t keylen = strlen(keyval);
if (Fwrite(keyval, 1, keylen, fd) == keylen)
rc = RPMRC_OK;
Expand Down Expand Up @@ -625,6 +630,7 @@ static rpmRC rpmtsImportFSKey(rpmtxn txn, Header h, rpmFlags flags, int replace)
free(keyglob);
}

exit:
free(path);
free(keyval);
free(keyfmt);
Expand Down
1 change: 0 additions & 1 deletion tests/rpmsigdig.at
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,6 @@ AT_SKIP_IF([test x$PGP = xdummy])
RPMTEST_CHECK([
RPMDB_INIT

runroot_other mkdir -p /tmp/kr
runroot rpmkeys \
--define "_keyringpath /tmp/kr" \
--define "_keyring fs" \
Expand Down

0 comments on commit 4ed1844

Please sign in to comment.