[ntp:hackers] Replacement of hardcoded file paths.

todd glassey tglassey at earthlink.net
Fri Jul 29 14:21:17 UTC 2011

On 7/28/2011 2:52 PM, Brian Utterback wrote:
> As you may know, Solaris has a few paths that are slightly different
> than the standard paths used in the distro.
FreeBSD too...
> For instance, the default
> location for ntp.conf is /etc/inet and the ntpstats directory is in
> /var/ntp rather than /var/NTP.
yes /var/NTP is a pain and something that should be changed for 
consistency to /var/ntp IMHO ...
> In the past I have created patch files
> that are applied before building as part of the Solaris Userland build
> procedure (see http://hg.openindiana.org/userland-gate/ )
The real issue is that in production time-servers there is so much 
logging data generated that it makes sense to mount a disk partition 
here to prevent lock-up if the /var partition fills up. This means 
really that from an operating practice that logging can go anywhere. We 
keep it in /var/log/ntp on our systems...
> Anyway, everytime I update a rev, I have to regenerate the patch files.
Yes based on the current installer model.
> Now, some of these paths are already defined as preprocessor macros and
> the ones that are not could easily be changed to match.
So yes obviously this works but you should be able to override these 
from the command line, and also you can build links them so that a 
flattened installer practice is possible...
> This would allow
> them to be easily set by simply setting -D flags on the compiler command
> line (although /etc/inet should follow the configure flag sysconfdir,
> but it does not currently.)
FreeBSD uses /etc/ntp for its default config and keys directory and many 
Admins just use /etc/ntp/ntp.conf or link it (-s) to /etc/ntp.conf for 
their local management practices too.
> One problem I ran into is that the macros are all currently defined to
> include the quotes around the string:
> #  define NTP_VAR "/var/NTP/"                /* NOTE the trailing '/' */
Yes this is a problem and it should be changed.
> This means that simply setting the value in -d does not work because the
> quotes are missing or stripped out, depending on how you do it.
> Setting the macro to not use the quotes does not work because doing this:
> #define NTP_VAR /var/NTP/
> char statsdir[MAXFILENAME] = "NTP_VAR";
> because the preprocessor does not expand macros in quotes.
> The usual way to do this is to use the pre-processor "#" operator, which
> automatically places quotes around the argument. You need to use two
> levels of expansion to make sure the argument expands properly:
> #define XSTR(a) #a
> #define STR(a) XSTR(a)
> #define NTP_VAR /var/NTP
> char statsdir[MAXFILENAME] = STR(NTP_VAR)
> The question I have is, does anybody know any reason not to do this,
> like do we support a compiler that does not support this idiom? Or, does
> anybody know a better way to accomplish this?

Todd S. Glassey
This is from my personal email account and any materials from this account come with personal disclaimers.

Further I OPT OUT of any and all commercial emailings.

More information about the hackers mailing list