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

ENT-9402: Moved ignore_interfaces.rx to $(sys.workdir) #5357

Merged
merged 4 commits into from
Nov 2, 2023

Conversation

larsewi
Copy link
Contributor

@larsewi larsewi commented Oct 30, 2023

Merge together:

PR includes:

  • Formatted InitIgnoreInterfaces() with clang-format
  • Moved ignore_interfaces.rx to $(sys.workdir)
  • Added error message based on errno to InitIgnoreInterfaces()
  • Fixed infinite loop on error bug while reading interface exception file

Demo:

root@hub:/var/cfengine/inputs# /var/cfengine/bin/cf-agent -KI
 warning: Found interface exception file ignore_interfaces.rx in /var/cfengine/inputs but it should be in /var/cfengine. Please consider moving it to the appropriate location.
 warning: Found interface exception file ignore_interfaces.rx in /var/cfengine/inputs but it should be in /var/cfengine. Please consider moving it to the appropriate location.
root@hub:/var/cfengine/inputs# mv /var/cfengine/inputs/ignore_interfaces.rx /var/cfengine/
root@hub:/var/cfengine/inputs# /var/cfengine/bin/cf-agent -KI
root@hub:/var/cfengine/inputs# 

Ticket: None
Changelog: None
Signed-off-by: Lars Erik Wik <[email protected]>
libenv/unix_iface.c Fixed Show fixed Hide fixed
libenv/unix_iface.c Fixed Show fixed Hide fixed
Copy link
Contributor

@vpodzime vpodzime left a comment

Choose a reason for hiding this comment

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

While you are at this code it would be nice to also add a check of the actual error (errno) and adapt the log messages to its value.

@larsewi larsewi requested a review from vpodzime October 31, 2023 17:07
libenv/unix_iface.c Fixed Show fixed Hide fixed
libenv/unix_iface.c Fixed Show fixed Hide fixed
vpodzime
vpodzime previously approved these changes Nov 1, 2023
Copy link
Contributor

@vpodzime vpodzime left a comment

Choose a reason for hiding this comment

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

Looks good to me either way.

libenv/unix_iface.c Show resolved Hide resolved
Moved expected location of ignore_interfaces.rx from $(sys.inputdir) to
$(sys.workdir). If the file is found in $(sys.inputdir) but not in
$(sys.workdir), we will still process it for backwards compatability,
but issue a warning prompting the user to move it to the appropriate
location.

Ticket: ENT-9402
Changelog: Commit
Signed-off-by: Lars Erik Wik <[email protected]>
Ticket: None
Changelog: None
Signed-off-by: Lars Erik Wik <[email protected]>
@larsewi
Copy link
Contributor Author

larsewi commented Nov 1, 2023

@cf-bottom Jenkins please :)

@larsewi
Copy link
Contributor Author

larsewi commented Nov 1, 2023

We should back-port bug fix 301a764 to 3.21.x and 3.18.x

Fixed bug where the agent may enter an infinite loop while trying to
read the interface exception file. The problem comes from the fact that
the while loop for reading each line in the file checks for end-of-file,
but not error. If an error occurs, end-of-file will never be reached,
hence the loop will never break.

Ticket: None
Changelog: Title
Signed-off-by: Lars Erik Wik <[email protected]>
@larsewi larsewi added the cherry-pick? Fixes which may need to be cherry-picked to LTS branches label Nov 1, 2023
CF_IGNORE_INTERFACES);
assert(ret >= 0 && (size_t) ret < sizeof(filename));

if ((fin = fopen(filename, "r")) == NULL)

Check failure

Code scanning / CodeQL

Uncontrolled data used in path expression

This argument to a file access function is derived from [user input (an environment variable)](1) and then passed to fopen(__filename). This argument to a file access function is derived from [user input (an environment variable)](1) and then passed to fopen(__filename).
CF_IGNORE_INTERFACES);
assert(ret >= 0 && (size_t) ret < sizeof(filename));

if ((fin = fopen(filename, "r")) == NULL)

Check failure

Code scanning / CodeQL

Uncontrolled data used in path expression

This argument to a file access function is derived from [user input (an environment variable)](1) and then passed to fopen(__filename). This argument to a file access function is derived from [user input (an environment variable)](2) and then passed to fopen(__filename). This argument to a file access function is derived from [user input (an environment variable)](1) and then passed to fopen(__filename). This argument to a file access function is derived from [user input (an environment variable)](2) and then passed to fopen(__filename).
Copy link
Contributor

@vpodzime vpodzime left a comment

Choose a reason for hiding this comment

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

ACK

@nickanderson
Copy link
Member

I saw this got merged, so I merged the related PRs:
cfengine/masterfiles#2750
cfengine/documentation#3102

@larsewi larsewi removed the cherry-pick? Fixes which may need to be cherry-picked to LTS branches label Nov 3, 2023
@larsewi
Copy link
Contributor Author

larsewi commented Nov 15, 2023

Back-ported to #5377

@larsewi larsewi deleted the interface branch December 3, 2024 14:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

4 participants