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

fix(linux.net): Added check for existing file before iptables restore #4889

Merged
merged 2 commits into from
Oct 18, 2023

Conversation

pierantoniomerlino
Copy link
Contributor

Note: We are using the Conventional Commits convention for our pull request titles. Please take a look at the PR title format document for the supported types and scopes.

This PR adds a check before launching iptables-restore command for testing the file presence.

} catch (IOException e) {
throw new KuraIOException(e, "restore() :: failed to read configuration file");
File iptablesFile = new File(getFirewallConfigFileName());
if (iptablesFile.exists()) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it better to reduce the cognitive complexity to reverse the check?

if (iptablesFile.exists()) {
  //maybe log as it is not the supposed state?
  return;
}
...

Signed-off-by: pierantoniomerlino <[email protected]>
Signed-off-by: pierantoniomerlino <[email protected]>
@MMaiero MMaiero merged commit bc70f76 into develop Oct 18, 2023
@MMaiero MMaiero deleted the fix_iptables_restore branch October 18, 2023 07:08
pierantoniomerlino added a commit that referenced this pull request Oct 20, 2023
…#4889)

* Check for existing file before restore

Signed-off-by: pierantoniomerlino <[email protected]>

* Fixed comment formatting

Signed-off-by: pierantoniomerlino <[email protected]>

---------

Signed-off-by: pierantoniomerlino <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants