Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 554332 - net-misc/dhcp: /etc/init.d/dhcpd configtest does not use correct config file
Summary: net-misc/dhcp: /etc/init.d/dhcpd configtest does not use correct config file
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] Server (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Gentoo's Team for Core System packages
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-07-09 14:47 UTC by pwojke
Modified: 2015-07-13 03:16 UTC (History)
0 users

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description pwojke 2015-07-09 14:47:13 UTC
I have added a second dhcpd for DHCPv6 with symlinking /etc/init.d/dhcpd6 to /etc/init.d/dhcpd and specifying appropriate options in /etc/conf.d/dhcpd6. When testing different configs I notices that /etc/init.d/dhcpd6 configtest does not check against the configuration file specified in /etc/conf.d/dhcpd6 but against /etc/dhcp/dhcpd.conf.

Looking at the init script I noticed that configtest does not get the correct config path like start does.

Reproducible: Always

Steps to Reproduce:
1. create a correct dhcp configuration at /etc/dhcp/dhcpd.conf
2. create a broken dhcp configuration at /etc/dhcp/dhcpd_broken.conf
3. configure dhcp to use the second configuration with DHCPD_CONF=/etc/dhcp/dhcpd_broken.conf in /etc/conf.d/dhcpd
4. run /etc/init.d/dhcpd configtest
Actual Results:  
configtest reports no errors because it checks against /etc/dhcp/dhcpd.conf

Expected Results:  
configtest should report error in /etc/dhcp/dhcpd_broken.conf

For a fix I copied the block that extracts the config path from function start to function configtest:

configtest() {
    local chroot=${DHCPD_CHROOT%/}

    # Work out our cffile if it's in our DHCPD_OPTS
    case " ${DHCPD_OPTS} " in
        *" -cf "*)
            DHCPD_CONF=" ${DHCPD_OPTS} "
            DHCPD_CONF="${DHCPD_CONF##* -cf }"
            DHCPD_CONF="${DHCPD_CONF%% *}"
            ;;
        *)  DHCPD_OPTS="${DHCPD_OPTS} -cf ${DHCPD_CONF}"
            ;;
    esac

    if [ -n "${chroot}" ] ; then
        # the config test want's these to exist
        mkdir -p \
            "${chroot}"/var/run/dhcp \
            "${chroot}"/var/lib/dhcp \
            "${chroot}"/etc/dhcp
    fi

    # see comment in get_var() above
    if [ ! -f "${chroot}${DHCPD_CONF}" ] ; then
        eerror "${chroot}${DHCPD_CONF} does not exist"
        return 1
    fi

    ebegin "Checking ${SVCNAME} configuration"
    checkconfig
    eend $?
}
Comment 1 SpanKY gentoo-dev 2015-07-13 03:16:05 UTC
should be all set now in the tree; thanks for the report!

Commit message: Unify DHCPD_xxx var set up between start and configtest
http://sources.gentoo.org/net-misc/dhcp/files/dhcpd.init5?r1=1.6&r2=1.7