bug with db-time-format local

Glenn Satchell Glenn.Satchell at uniq.com.au
Thu Oct 15 12:44:54 UTC 2009

I switched to db-time-format local and now my leases file looks like this:

lease {
  starts epoch %s; # Sun Oct 11 15:09:56 2009
  ends epoch %s; # Sun Oct 11 19:09:56 2009
  tstp epoch %s; # Sun Oct 11 19:09:56 2009
  cltt epoch %s; # Sun Oct 11 15:09:56 2009
  binding state free;
  hardware ethernet 00:a0:d1:22:4e:ed;
  uid "\001\000\240\321\"N\355";

The culprit is in common/print.c

        if (db_time_format == LOCAL_TIME_FORMAT) {
                if (strftime(buf, sizeof(buf),
                             "epoch %s; # %a %b %d %H:%M:%S %Y",
                             localtime(&t)) == 0)
                        return NULL;

I am using dhcpd 4.1.1b2 on Solaris 10 sparc, there is no %s format in
strftime() on this platform so a literal %s is added to the buffer.
HP-UX B.11.11 also does not have the %s modifier. Linux and AIX 5.1
do. These are the only Unix systems I have access to check. Bummer.

The code probably needs to do use snprintf() to handle the seconds
since epoch and then concatenating the strftime() part? Looks messy.

Glenn Satchell   mailto:glenn.satchell at uniq.com.au | Miss 9: What do you
Uniq Advances Pty Ltd       http://www.uniq.com.au | do at work Dad?
PO Box 70 Paddington NSW Australia 2021            | Miss 6: He just
tel:0409-458-580     fax:02-9380-6416              | types random stuff.

More information about the dhcp-users mailing list