netcfg does not set netcfg/dhcp_ntp_servers

Bug #1205260 reported by Simon Kuhn
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
netcfg (Ubuntu)
New
Undecided
Unassigned

Bug Description

netcfg in precise no longer has logic to set netcfg/dhcp_ntp_servers in debconf. This causes clock-setup to fail to run rdate against the first provided NTP server to set the time during install (which can lead to other problems). This is a regression from lucid's behavior which correctly passed DHCP-provided NTP servers into clock-setup.

netcfg-1.51ubuntu3 in lucid has the following logic in dhcp.c:

                /*
                 * Record any ntp server information from DHCP for later
                 * verification and use by clock-setup
                 */
                if ((d = fopen(NTP_SERVER_FILE, "r")) != NULL) {
                    char ntpservers[DHCP_OPTION_LEN + 1] = { 0 };
                    fgets(ntpservers, DHCP_OPTION_LEN, d);
                    fclose(d);
                    unlink(NTP_SERVER_FILE);

                    if (!empty_str(ntpservers)) {
                        debconf_set(client, "netcfg/dhcp_ntp_servers",
                                    ntpservers);
                    }
                }

netcfg-1.68ubuntu14 in precise has the following, which never calls debconf_set:

    /*
     * Record any ntp server information from DHCP for later
     * verification and use by clock-setup
     */
    if ((d = fopen(NTP_SERVER_FILE, "r")) != NULL) {
        char ntpservers[DHCP_OPTION_LEN + 1] = { 0 }, *ptr, *srv;
        int i;

        di_debug("Reading NTP servers from DHCP info");

        if (fgets(ntpservers, DHCP_OPTION_LEN, d) == NULL) {
            /* ignore errors; we check for empty strings later */
        }
        rtrim(ntpservers);
        fclose(d);
        unlink(NTP_SERVER_FILE);

        if (!empty_str(ntpservers)) {
            ptr = ntpservers;
            for (i = 0; i < NETCFG_NTPSERVERS_MAX; i++) {
                srv = strtok_r(ptr, " \n\t", &ptr);
                if (srv) {
                    di_debug("Read NTP server %s", srv);
                    strncpy(interface->ntp_servers[i], srv, NETCFG_ADDRSTRLEN);
                } else {
                    *(interface->ntp_servers[i]) = '\0';
                }
            }
        }
    }

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.