Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rec: delete temp file on failure to dump RPZ file #15033

Merged
merged 2 commits into from
Jan 13, 2025

Conversation

omoerbeek
Copy link
Member

Short description

Checklist

I have:

  • read the CONTRIBUTING.md document
  • compiled this code
  • tested this code
  • included documentation (including possible behaviour changes)
  • documented the code
  • added or modified regression test(s)
  • added or modified unit test(s)

@omoerbeek omoerbeek added the rec label Jan 13, 2025
@omoerbeek omoerbeek added this to the rec-5.3.0 milestone Jan 13, 2025
Copy link
Contributor

@miodvallat miodvallat left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

SLOG(g_log << Logger::Warning << "Error while moving the content of the RPZ zone " << zoneName << " to the dump file: " << stringerror() << endl,
logger->error(Logr::Error, errno, "Error while moving the content of the RPZ", "destination_file", Logging::Loggable(dumpZoneFileName)));
return false;
}

tempFile->clear(); // file is renamed, no need to unlink
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
tempFile->clear(); // file is renamed, no need to unlink
tempFile->clear(); // file has been renamed, no need to unlink

std::string temp = dumpZoneFileName + "XXXXXX";
int fileDesc = mkstemp(&temp.at(0));
auto tempFile = UniqueFilenameDeleterPtr(new string(dumpZoneFileName + "XXXXXX"));
int fileDesc = mkstemp(tempFile->data());
if (fileDesc < 0) {
SLOG(g_log << Logger::Warning << "Unable to open a file to dump the content of the RPZ zone " << zoneName << endl,
logger->error(Logr::Error, errno, "Unable to create temporary file"));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might make sense to clear the filename in this case as well, because we know it doesn't exist yet.

@omoerbeek omoerbeek force-pushed the rec-rpz-tmp-file-deleter branch from 15b0e4e to a472992 Compare January 13, 2025 13:40
@coveralls
Copy link

coveralls commented Jan 13, 2025

Pull Request Test Coverage Report for Build 12750666660

Details

  • 10 of 13 (76.92%) changed or added relevant lines in 1 file are covered.
  • 25 unchanged lines in 8 files lost coverage.
  • Overall coverage increased (+0.02%) to 64.91%

Changes Missing Coverage Covered Lines Changed/Added Lines %
pdns/recursordist/rpzloader.cc 10 13 76.92%
Files with Coverage Reduction New Missed Lines %
pdns/recursordist/test-syncres_cc1.cc 1 89.6%
pdns/dnsdistdist/dnsdist-crypto.cc 1 76.01%
pdns/dnsdistdist/dnsdist-backend.cc 1 66.73%
pdns/misc.cc 2 64.57%
pdns/recursordist/test-syncres_cc2.cc 3 88.85%
pdns/packethandler.cc 3 72.53%
pdns/remote_logger.cc 6 52.47%
pdns/recursordist/ext/luawrapper/include/LuaContext.hpp 8 14.15%
Totals Coverage Status
Change from base Build 12745616875: 0.02%
Covered Lines: 126339
Relevant Lines: 163810

💛 - Coveralls

@omoerbeek omoerbeek force-pushed the rec-rpz-tmp-file-deleter branch from 10a3c02 to 9817dc5 Compare January 13, 2025 15:36
@omoerbeek omoerbeek merged commit ffbd64b into PowerDNS:master Jan 13, 2025
81 checks passed
@omoerbeek omoerbeek deleted the rec-rpz-tmp-file-deleter branch January 13, 2025 16:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants