]> git.ipfire.org Git - thirdparty/ntp.git/commitdiff
[Bug 542] Tolerate missing directory separator at EO statsdir
authorHarlan Stenn <stenn@ntp.org>
Wed, 25 Apr 2007 06:45:35 +0000 (02:45 -0400)
committerHarlan Stenn <stenn@ntp.org>
Wed, 25 Apr 2007 06:45:35 +0000 (02:45 -0400)
bk: 462ef90fdrX7qiGSNTj98JUJ97pQkA

ChangeLog
Makefile.am
configure.ac
m4/ntp_dir_sep.m4 [new file with mode: 0644]
ntpd/ntp_util.c
ports/winnt/include/config.h

index 1b9fe7ded5e9e49466e6e56d4067b3165ec8eece..f1cc1366901960f5ba84c22ad98f4d388faec077 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,4 @@
+* [Bug 542] Tolerate missing directory separator at EO statsdir.
 * [Bug 812] ntpd should drop supplementary groups.
 * [Bug 815] Fix warning compiling 4.2.5p22 under Windows with VC6.
 * [Bug 740] Fix kernel/daemon startup drift anomaly.
index 37513c3d9238bded726a5c8640488e03d99ab341..68c9fbac3736b05ab46a0612c8b10c2ee48a0b0b 100644 (file)
@@ -79,6 +79,7 @@ EXTRA_DIST =          \
        conf            \
        html            \
        libisc          \
+       m4              \
        ports           \
        \
        bincheck.mf     \
index cd62ce368f25e449236144637eab300117cc5569..ea742cfae1b52bf0476044d9f36e55ec526f3690 100644 (file)
@@ -68,6 +68,7 @@ case "$host" in
 esac
 
 AMU_OS_CFLAGS
+NTP_DIR_SEP
 
 # NTP has (so far) been relying on leading-edge autogen.
 # Therefore, by default:
diff --git a/m4/ntp_dir_sep.m4 b/m4/ntp_dir_sep.m4
new file mode 100644 (file)
index 0000000..6c0d50b
--- /dev/null
@@ -0,0 +1,18 @@
+dnl ######################################################################
+dnl What directory path separator do we use?
+AC_DEFUN([NTP_DIR_SEP], [
+AC_CACHE_CHECK([for directory path separator], ac_cv_dir_sep,
+[
+  case "$ac_cv_dir_sep" in
+   '')
+    case "$target_os" in
+      *djgpp | *mingw32* | *emx*) ac_cv_dir_sep='"\\"' ;;
+      *) ac_cv_dir_sep='"/"' ;;
+    esac
+    ;;
+  esac
+])
+AC_DEFINE_UNQUOTED(DIR_SEP,$ac_cv_dir_sep,dnl
+   [Directory separator, usually / or \\])dnl
+])
+dnl ======================================================================
index 91ff8a64f76d0e986b6a6195d662c9593045d335..1934a5c6bf948f8b2353a0d1c1dd8f4d01f92969 100644 (file)
@@ -358,15 +358,34 @@ stats_config(
                break;
        
            case STATS_STATSDIR:
+               /* HMS: the following test is insufficient:
+                * - value may be missing the DIR_SEP
+                * - we still need the filename after it
+                */
                if (strlen(value) >= sizeof(statsdir)) {
                        msyslog(LOG_ERR,
                            "value for statsdir too long (>%d, sigh)",
                            (int)sizeof(statsdir)-1);
                } else {
                        l_fp now;
+                       int add_dir_sep;
+                       int value_l = strlen(value);
+
+                       /* We do not want a DIR_SEP if we have no prefix */
+                       if (value_l == 0)
+                               add_dir_sep = 0;
+                       else
+                               add_dir_sep = strcmp(DIR_SEP,
+                                       value + value_l - strlen(DIR_SEP));
+
+                       if (add_dir_sep)
+                           snprintf(statsdir, sizeof(statsdir),
+                               "%s%s", value, DIR_SEP);
+                       else
+                           snprintf(statsdir, sizeof(statsdir),
+                               "%s", value);
 
                        get_systime(&now);
-                       strcpy(statsdir,value);
                        if(peerstats.prefix == &statsdir[0] &&
                            peerstats.fp != NULL) {
                                fclose(peerstats.fp);
index 6bab3598baa9521456d92c9f136113da0ede79a6..0bf51161cd6290ad7e48578593fa92196e7ffa53 100644 (file)
@@ -57,7 +57,7 @@ typedef unsigned int  uintptr_t;
 
 /*
  * The type of the socklen_t defined for getnameinfo() and getaddrinfo()
- * is int for VS compilers on Windows but the type is already declared 
+ * is int for VS compilers on Windows but the type is already declared
  */
 #define GETSOCKNAME_SOCKLEN_TYPE socklen_t
 /*
@@ -89,7 +89,7 @@ typedef unsigned int  uintptr_t;
 
 /* Prevent inclusion of winsock.h in windows.h */
 #ifndef _WINSOCKAPI_
-#define _WINSOCKAPI_  
+#define _WINSOCKAPI_
 #endif
 
 #ifndef __RPCASYNC_H__
@@ -108,9 +108,9 @@ typedef unsigned int        uintptr_t;
 #endif
 
 #define OPEN_BCAST_SOCKET      1 /* for        ntp_io.c */
-#define TYPEOF_IP_MULTICAST_LOOP BOOL                                                                                          
+#define TYPEOF_IP_MULTICAST_LOOP BOOL
 #define SETSOCKOPT_ARG_CAST (const char *)
-#define HAVE_RANDOM 
+#define HAVE_RANDOM
 #define MAXHOSTNAMELEN 64
 #define AUTOKEY
 
@@ -180,7 +180,7 @@ int NT_set_process_priority(void);  /* Define this function */
 # define REFCLOCK                      /* from ntpd.mak */
 
 # define CLOCK_LOCAL                   /* from ntpd.mak */
-//# define CLOCK_PARSE 
+//# define CLOCK_PARSE
 /* # define CLOCK_ATOM */
 /* # define CLOCK_SHM  */               /* from ntpd.mak */
 # define CLOCK_HOPF_SERIAL     /* device 38, hopf DCF77/GPS serial line receiver  */
@@ -196,7 +196,7 @@ int NT_set_process_priority(void);  /* Define this function */
 # define NTP_POSIX_SOURCE
 
 # define SYSLOG_FILE                   /* from libntp.mak */
-# define SYSV_TIMEOFDAY                /* for ntp_unixtime.h */
+# define SYSV_TIMEOFDAY                        /* for ntp_unixtime.h */
 
 # define SIZEOF_SIGNED_CHAR 1
 # define SIZEOF_INT 4                  /* for ntp_types.h */
@@ -228,7 +228,10 @@ int NT_set_process_priority(void); /* Define this function */
 
 # define NEED_S_CHAR_TYPEDEF
 
-# define USE_PROTOTYPES                /* for ntp_types.h */                                                                                                           
+# define USE_PROTOTYPES                /* for ntp_types.h */
+
+/* Directory separator, usually / or \ */
+#define DIR_SEP "\\"
 
 #define ULONG_CONST(a) a ## UL