Ge Hu c79d786f51 DHCP: Delete redundant codes, enhance code security
tool inclusion
category: bugfix
bugzilla:https://gitee.com/openeuler/ub-dhcp/issues/IALX53
CVE: NA

----------------------------------------------------------------------

1.Delete redundant codes.
2.Add const to read-only data.
3.Check the return value of the get_addr function.
4.The log level is changed from log_fatal to log_error.

Signed-off-by: Ge Hu huge4@huawei.com
(cherry picked from commit c5af2b6246a998394874a35f1162daa0cb02c6ee)
2024-08-29 09:17:32 +08:00
2023-10-25 15:57:43 +08:00
2023-10-25 15:57:43 +08:00
2023-10-25 15:57:43 +08:00
2023-10-25 15:57:43 +08:00
2023-10-25 15:57:43 +08:00

The /etc/ub-dhcp/ub-dhclient.d directory allows other packages and system
administrators to create application-specific option handlers for ub-dhclient.

When ub-dhclient is run, any option listed in the dhcp-options(5) man page can
be requested.  ub-dhclient-script does not handle every option available
because doing so would make the script unmaintainable as the components
using those options might change over time.  The knowledge of how to handle
those options should be under the responsibility of the package maintainer
for that component (e.g., NTP options belong in a handler in the ntp
package).

To make maintenance easier, application specific DHCP options can be handled
by creating a bash script with two functions and placing it in /etc/ub-dhcp/
ub-dhclient.d

The script must follow a specific form:

(1) The script must be named NAME.sh.  NAME can be anything, but it makes
    sense to name it for the service it handles.  e.g., ntp.sh

(2) The script must provide a NAME_config() function to read the options and
    do whatever it takes to put those options in place.

(3) The script must provide a NAME_restore() function to restore original
    configuration state when ub-dhclient stops.

(4) The script must be 'chmod +x' or ub-dhclient-script will ignore it.

The scripts execute in the same environment as ub-dhclient-script.  That means
all of the functions and variables available to it are available to your
NAME.sh script.  Things of note:

    ${SAVEDIR} is where original configuration files are saved.  Save your
    original configuration files here before you take the DHCP provided
    values and generate new files.

    Variables set in /etc/sysconfig/network, /etc/sysconfig/networking/network,
    and /etc/sysconfig/network-scripts/ifcfg-$interface are available to
    you.

See the scripts in /etc/ub-dhcp/ub-dhclient.d for examples.

NOTE:  Do not use functions defined in /usr/sbin/ub-dhclient-script.  Consider
ub-dhclient-script a black box.  This script may change over time, so the
ub-dhclient.d scripts should not be using functions defined in it.

-- 
David Cantrell <dcantrell@redhat.com>
Description
No description provided
Readme 58 MiB
Languages
Shell 100%