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

dhclient: T5724: run user hooks using run_hookdir #2472

Merged
merged 1 commit into from
Nov 11, 2023
Merged

Conversation

gavol
Copy link
Contributor

@gavol gavol commented Nov 11, 2023

Change Summary

Execute user hooks using run_hookdir instead of run-parts.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Code style update (formatting, renaming)
  • Refactoring (no functional changes)
  • Migration from an old Vyatta component to vyos-1x, please link to related PR inside obsoleted component
  • Other (please describe):

Related Task(s)

Component(s) name

dhcp

Proposed changes

User hooks are executed using run_hookdir (defined in the /sbin/dhclient-script script) instead of run-parts. That allows user hooks to modify variables set by the dhcp client (e.g., the new_routers variable to avoid the installation of the default routes).

How to test

Pre-condition: at least one interface (eth0 for simplicity) receiving IP via dhcp and configured to install the default root.

Add a very simple user hook in /config/scripts/dhcp-client/pre-hooks.d:

RUN="yes"
if [ "$RUN" = "yes" ]; then
    case "$reason" in
        BOUND|RENEW|REBIND|REBOOT)
        new_routers=""
        ;;
    esac
fi

Force a dhcp renewal and then check the content of the /var/lib/dhcp/dhclient_eth0.lease file: the new_routers variable should point to an empty string when reason is BOUND or RENEW or REBIND or REBOOT.

Checklist:

  • I have read the CONTRIBUTING document
  • I have linked this PR to one or more Phabricator Task(s)
  • I have run the components SMOKETESTS if applicable
  • My commit headlines contain a valid Task id
  • My change requires a change to the documentation
  • I have updated the documentation accordingly

User hooks are executed using run_hookdir (defined in the /sbin/dhclient-script script) instead of run-parts. That allows user hooks to modify variables set by the dhcp client (e.g., the new_routers variable to avoid the installation of the default routes).
@vyosbot vyosbot requested review from a team, dmbaturin, sarthurdev and zdc and removed request for a team November 11, 2023 10:17
@c-po c-po merged commit 2ca0ac6 into vyos:current Nov 11, 2023
7 checks passed
@c-po
Copy link
Member

c-po commented Nov 11, 2023

@Mergifyio backport sagitta

Copy link
Contributor

mergify bot commented Nov 11, 2023

backport sagitta

✅ Backports have been created

c-po added a commit that referenced this pull request Nov 11, 2023
dhclient: T5724: run user hooks using run_hookdir (backport #2472)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

Successfully merging this pull request may close these issues.

3 participants