[Bug 1205260] [NEW] netcfg does not set netcfg/dhcp_ntp_servers

Simon Kuhn 1205260 at bugs.launchpad.net
Fri Jul 26 09:34:13 UTC 2013


Public bug reported:

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';
                }
            }
        }
    }

** Affects: netcfg (Ubuntu)
     Importance: Undecided
         Status: New

-- 
You received this bug notification because you are a member of Ubuntu
Foundations Bugs, which is subscribed to netcfg in Ubuntu.
https://bugs.launchpad.net/bugs/1205260

Title:
  netcfg does not set netcfg/dhcp_ntp_servers

Status in “netcfg” package in Ubuntu:
  New

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 manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/netcfg/+bug/1205260/+subscriptions




More information about the foundations-bugs mailing list