Index: /branches/rel_apv_10_7/tools/update/ustacksystem.ks
===================================================================
--- /branches/rel_apv_10_7/tools/update/ustacksystem.ks	(revision 38800)
+++ /branches/rel_apv_10_7/tools/update/ustacksystem.ks	(working copy)
@@ -397,6 +397,8 @@
 libaio.x86_64
 oracle-instantclient-basic-21.5.0.0.0-1.x86_64
 oracle-instantclient-devel-21.5.0.0.0-1.x86_64
+unbound-libs-1.4.20-26.el7.x86_64
+ldns-1.6.16-7.el7.x86_64
 %end
 
 %post --nochroot --interpreter ./tools/image-minimizer
@@ -433,6 +435,14 @@
 rpm -ivh http://192.168.100.11/arrayepel.72/libnghttp2-1.33.0-1.1.el7.x86_64.rpm --force --nodeps
 rpm -ivh http://192.168.100.11/arrayepel.72/curl-7.58.0-1.el7.x86_64.rpm --force --nodeps
 
+# chrony package
+rpm -ivh http://192.168.100.11/arrayepel.72/gmp-6.3.0-0.x86_64.rpm --force --nodeps
+rpm -ivh http://192.168.100.11/arrayepel.72/m4-1.4.19-0.x86_64.rpm --force --nodeps
+rpm -ivh http://192.168.100.11/arrayepel.72/p11-kit-0.23.12-0.x86_64.rpm --force --nodeps
+rpm -ivh http://192.168.100.11/arrayepel.72/nettle-3.10-0.x86_64.rpm --force --nodeps
+rpm -ivh http://192.168.100.11/arrayepel.72/gnutls-3.7.11-0.x86_64.rpm --force --nodeps
+rpm -ivh http://192.168.100.11/arrayepel.72/chrony-4.6-0.x86_64.rpm --force --nodeps
+
 # install azure-mgmt-compute azure-mgmt-network azure-identity azure-mgmt-resource psutil 
 LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:/ca/lib/ pip3 install -i http://192.168.100.11/pypirepo/py3/simple azure-mgmt-compute azure-mgmt-network azure-identity azure-mgmt-resource psutil --trusted-host 192.168.100.11
 
Index: /branches/rel_apv_10_7/usr/click/bin/backend/ntp.h
===================================================================
--- /branches/rel_apv_10_7/usr/click/bin/backend/ntp.h	(revision 38800)
+++ /branches/rel_apv_10_7/usr/click/bin/backend/ntp.h	(working copy)
@@ -1,37 +1,29 @@
-#if (defined(BSD) && (BSD >= 199103))
-#define NTP_PID_FILE "/var/run/ntp.pid"
-#else
-#define NTP_PID_FILE "etc/ntp.pid"
-#endif
 
-#define NTP_CONF_FILE   "/etc/ntp.conf"
-#define TMP_NTP_CONF_FILE		"/etc/.ntp.conf.tmp"
-
-#define NTP_TYPE_NTPD   0
-#define NTP_TYPE_NTPDATE        1
-
-#if defined(__linux__)
-#ifdef UOS_X86
-#define NTPD_PATH       "/sbin/ntpd"
-#define NTPQ_PATH      "/usr/bin/ntpq"
-#define NTPDC_PATH	"/usr/bin/ntpdc"
-#elif KYLIN
-#define NTPD_PATH       "/sbin/ntpd"
-#define NTPQ_PATH      "/usr/sbin/ntpq"
-#define NTPDC_PATH	"/usr/sbin/ntpdc"
-#else
-#define NTPD_PATH       "/usr/local/sbin/ntpd"
-#define NTPQ_PATH      "/usr/local/sbin/ntpq"
-#define NTPDC_PATH	"/usr/sbin/ntpdc"
-#endif
-
-#define NTPD_START_CMD "/usr/local/sbin/ntpd -g -p /var/run/ntp.pid"
-
-#else
-/* Bug 17345, Porting a new ntpd instead of the original one */
-#define NTPD_PATH       "/usr/sbin/ntpd"
-#define NTPQ_PATH      "/usr/bin/ntpq"
-
-
-#define NTPD_START_CMD "/usr/sbin/ntpd -g -p /var/run/ntp.pid"
-#endif
+#define NTP_PID_FILE            "/var/run/ntp.pid"
+#define CHRONYD_PID_FILE        "/var/run/chrony/chronyd.pid"
+#define CHRONY_CONF_FILE        "/ca/conf/chrony/chrony.conf"
+#define CHRONY_CONF_DEFAULT     "/ca/conf/chrony/chrony.conf.default"
+#define CHRONY_CONF_TMP         "/ca/conf/chrony/chrony.conf.tmp"
+#define CHRONY_KEYS_FILE        "/ca/conf/chrony/chrony.keys"
+#define CHRONY_KEYS_DEFAULT     "/ca/conf/chrony/chrony.keys.default"
+#define CHRONY_KEYS_TMP         "/ca/conf/chrony/chrony.keys.tmp"
+
+#define CHRONYD_START_CMD       "/usr/bin/systemctl start chronyd"
+#define CHRONYD_STOP_CMD        "/usr/bin/systemctl stop chronyd"
+#define RSYSLOG_RESTART_CMD     "/usr/bin/systemctl restart rsyslog"
+#define CHRONYC_SOURCES_CMD     "LD_LIBRARY_PATH=/usr/local/lib:/usr/local/lib64 /ca/bin/chronyc sources"
+#define CHRONYC_AUTH_CMD        "LD_LIBRARY_PATH=/usr/local/lib:/usr/local/lib64 /ca/bin/chronyc authdata"
+#define CHRONYC_ADD_SRV_CMD     "LD_LIBRARY_PATH=/usr/local/lib:/usr/local/lib64 /ca/bin/chronyc add"
+#define CHRONYC_DEL_SRV_CMD     "LD_LIBRARY_PATH=/usr/local/lib:/usr/local/lib64 /ca/bin/chronyc delete"
+#define CHRONYC_RELOAD_SRC_CMD  "LD_LIBRARY_PATH=/usr/local/lib:/usr/local/lib64 /ca/bin/chronyc reload sources"
+#define CHRONYC_SYNC_TIME_CMD   "LD_LIBRARY_PATH=/usr/local/lib:/usr/local/lib64 /ca/bin/chronyc makestep"
+#define CHRONYC_TRACKING_CMD    "LD_LIBRARY_PATH=/usr/local/lib:/usr/local/lib64 /ca/bin/chronyc tracking"
+#define CHRONYC_RESET_CMD       "LD_LIBRARY_PATH=/usr/local/lib:/usr/local/lib64 /ca/bin/chronyc reset sources"
+#define CHRONYC_REKEY_CMD       "LD_LIBRARY_PATH=/usr/local/lib:/usr/local/lib64 /ca/bin/chronyc rekey"
+
+#define TIME_STATE_FILE         "/var/lib/rsyslog/imjournal.state"
+#define NTP_ENCRYPTED_FLAG      "ENCRYPTED"
+#define NTP_MAX_AUTH_KEY_LEN    32
+#define NTP_MIN_AUTH_KEY_ID     1
+#define NTP_MAX_AUTH_KEY_ID     65535
+#define NTP_ENCRYPTED_LEN       129
Index: /branches/rel_apv_10_7/usr/click/bin/backend/ntp.c
===================================================================
--- /branches/rel_apv_10_7/usr/click/bin/backend/ntp.c	(revision 38800)
+++ /branches/rel_apv_10_7/usr/click/bin/backend/ntp.c	(working copy)
@@ -1,8 +1,8 @@
 
 /*-----------------------------------------------------------------------
  *
- * Copyright (C) 2001
- * ClickArray Inc. All rights reserved.
+ * Copyright (C) 2024
+ * ArrayNetworks Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification is not permitted unless authorized in writing by a duly 
@@ -15,988 +15,650 @@
  *-----------------------------------------------------------------------
  */
 
-#if defined(__linux__)
-#include <bsd/bsd.h>
-#endif
-#include <sys/types.h>
-#include <sys/param.h>
-#include <sys/wait.h>
-#include <sys/mount.h>
-#include <sys/socket.h>
-#include <sys/stat.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>
-#if !defined(__linux__)
-#include <sys/callout.h>
-#endif
-#include <click/kern/click_callout.h>
-#include <sys/sysctl.h>
-
-#include <ctype.h>
-#include <fcntl.h>
-#include <libgen.h>
-#include <resolv.h>
-#include <setjmp.h>
-#include <signal.h>
 #include <stdio.h>
 #include <stdlib.h>
-#include <strings.h>
-#include <string.h>
-#include <time.h>
 #include <string.h>
 #include <time.h>
 #include <unistd.h>
-#include <sys/ioctl.h>
-#include <termios.h>
 #include <errno.h>
-#if defined(__linux__)
-#include <bsd/libutil.h>
-#else
-#include <libutil.h>
-#endif
-#include <signal.h>
-
+#include <sys/stat.h>
 
-#if !defined(__linux__)
-#include <fetch.h>
-#endif
-#include "suppress_print.h"
-#include "import_export.h"
-#include "fastlog.h"
-#include "englog.h"
-#include "ip.h"
-#include "node_sys.h"
-#include <click/app/proxy/proxy_errs.h>
-#include "sysmonIf.h"
-#include "userWrapper.h"
-#include "sysmonIf.h"
-#include "version.h"
-#include "ca_ui.h"
-#include "sys_tool.h"
 #include "ntp.h"
-#include "ca_util.h"
+#include "fastlog.h"
+
+typedef struct 
+{
+    int key;
+    char type[10];
+    char value[NTP_MAX_AUTH_KEY_LEN];
+} chronyKey;
+
+extern int encrypt_secret(const unsigned char *secret_in, unsigned char *secret_out);
+extern int decrypt_secret(const unsigned char *secret_in, unsigned char *secret_out);
+
+static int delete_ntpsrv_conf(char* host)
+{
+    FILE *fp, *fp_tmp;
+    char linebuf[2048] = {0};
+    char prefix[1024] = {0};
+    int found = 0;
+
+    if (access(CHRONY_CONF_FILE, F_OK)) {
+        printf("Access %s error\n", CHRONY_CONF_FILE);
+        return 0;
+    }
+
+    fp = fopen(CHRONY_CONF_FILE, "r");
+    if (!fp) {
+        printf("Open %s error\n", CHRONY_CONF_FILE);
+        return 0;
+    }
+
+    fp_tmp = fopen(CHRONY_CONF_TMP, "w+");
+    if (!fp_tmp) {
+        fclose(fp);
+        printf("Open %s error\n", CHRONY_CONF_TMP);
+        return 0;
+    }
+
+    snprintf(prefix, sizeof(prefix), "server %s", host);
+
+    while (fgets(linebuf, sizeof(linebuf), fp)) {
+        if (strncmp(linebuf, prefix, strlen(prefix)) == 0 &&
+            (linebuf[strlen(prefix)] == '\0' || 
+             linebuf[strlen(prefix)] == ' ' || 
+             linebuf[strlen(prefix)] == '\n')) {
+            found = 1;
+            continue;
+        } else {
+            fputs(linebuf, fp_tmp);
+        }
+    }
+
+    fclose(fp);
+    fclose(fp_tmp);
+
+    unlink(CHRONY_CONF_FILE);
+    rename(CHRONY_CONF_TMP, CHRONY_CONF_FILE);
+
+    return found;
+}
+
+static void add_ntpkey_conf(int id, char *key) 
+{
+    FILE *fp, *fp_tmp;
+    char linebuf[1024] = {0}, id_str[6] = {0}, cfg[128] = {0};;
+    int found = 0;
+
+    if (access(CHRONY_KEYS_FILE, F_OK)) {
+        printf("Access %s error\n", CHRONY_KEYS_FILE);
+        return;
+    }
+
+    fp = fopen(CHRONY_KEYS_FILE, "r");
+    if (!fp) {
+        printf("Open %s error\n", CHRONY_KEYS_FILE);
+        return;
+    }
+
+    fp_tmp = fopen(CHRONY_KEYS_TMP, "w+");
+    if (!fp_tmp) {
+        fclose(fp);
+        printf("Open %s error\n", CHRONY_KEYS_TMP);
+        return;
+    }
+
+    snprintf(id_str, sizeof(id_str), "%d", id);
+
+    while (fgets(linebuf, sizeof(linebuf), fp)) {
+        if (strncmp(linebuf, id_str, strlen(id_str)) == 0 && linebuf[strlen(id_str)] == ' ') {
+            continue;
+        } else {
+            fputs(linebuf, fp_tmp);
+        }
+    }
+
+    sprintf(cfg, "%d MD5 %s\n", id, key);
+    fputs(cfg, fp_tmp);
+
+    fclose(fp);
+    fclose(fp_tmp);
+
+    unlink(CHRONY_KEYS_FILE);
+    rename(CHRONY_KEYS_TMP, CHRONY_KEYS_FILE);
+}
+
+static int delete_ntpkey_conf(int key_id)
+{
+    FILE *fp, *fp_tmp;
+    char linebuf[2048], id_str[6] = {0};
+    int found = 0;
+
+    if (access(CHRONY_KEYS_FILE, F_OK)) {
+        printf("Access %s error\n", CHRONY_KEYS_FILE);
+        return 0;
+    }
+
+    fp = fopen(CHRONY_KEYS_FILE, "r");
+    if (!fp) {
+        printf("Open %s error\n", CHRONY_KEYS_FILE);
+        return 0;
+    }
+
+    fp_tmp = fopen(CHRONY_KEYS_TMP, "w+");
+    if (!fp_tmp) {
+        fclose(fp);
+        printf("Open %s error\n", CHRONY_KEYS_TMP);
+        return 0;
+    }
 
-typedef void timeout_t __P((void *));
-struct  callout_handle timeout __P((timeout_t *, void *, int));
-void    untimeout __P((timeout_t *, void *, struct callout_handle));
-#define NTP_BUFFLEN 1024 
-#if 0
-
-#if (defined(BSD) && (BSD >= 199103))
-#define NTP_PID_FILE "/var/run/ntp.pid"
-#else
-#define NTP_PID_FILE "etc/ntp.pid"
-#endif
-
-#define NTP_CONF_FILE   "/etc/ntp.conf"
-#define NTPD_PATH       "/usr/sbin/ntpd"
-#define NTPDC_PATH      "/usr/sbin/ntpdc"
-
-#endif
-
-extern int vaTouchLine(char*);
-extern int invalid_ip_check(void* ip, int isipv6, int skip);
-
-struct ntpsrv_info
-{
-	unsigned int version;
-	union ntp_addr{
-		struct in_addr	in_4;
-		struct in6_addr in_6;
-	}in;
-	int isipv6;
-};
-
-static char *get_ntpserver_ips(char* servers);
-
-static int is_ntpsrv_ipv4_exist(struct in_addr *ip, unsigned int version);
-static int is_ntpsrv_ipv6_exist(struct in6_addr *ip, unsigned int version);
-static int get_ntpsrv_info(const char *info,struct ntpsrv_info *ntpinfo);
-static int update_ntpsrv_conf(char* ip, unsigned int version);
-static int get_conf_file_size(const char *filename);
-static int is_ntp_service_active();
-
-static int
-is_ntpsrv_ipv6_exist(struct in6_addr *ip,unsigned int version)
-{
-	FILE *f;
-	char buf[NTP_BUFFLEN];
-	struct ntpsrv_info ntpinfo;
-	int ret;
-
-	f = fopen(NTP_CONF_FILE,"r");
-	if(f) {
-		while(fgets(buf,sizeof(buf),f)) {
-			get_ntpsrv_info(buf,&ntpinfo);			
-			if((ntpinfo.version == version)&&(IN6_ARE_ADDR_EQUAL(ip,&(ntpinfo.in.in_6)))) {
-				fclose(f);
-				return 1;
-			}
-		}
-		fclose(f);
-		ret = 0;
-	} else {
-		ret = 0;
-	}
-	
-	return ret;	
-}
-
-static int
-is_ntpsrv_ipv4_exist(struct in_addr *ip,unsigned int version)
-{
-	FILE *f;
-	char buf[NTP_BUFFLEN];
-	struct ntpsrv_info ntpinfo;
-	int ret;
-
-	f = fopen(NTP_CONF_FILE,"r");
-	if(f) {
-		while(fgets(buf,sizeof(buf),f)) {
-			get_ntpsrv_info(buf,&ntpinfo);			
-			if((ntpinfo.version == version)&&(ip->s_addr == ntpinfo.in.in_4.s_addr)) {
-				fclose(f);
-				return 1;
-			}
-		}
-		fclose(f);
-		ret = 0;
-	} else {
-		ret = 0;
-	}
-	
-	return ret;	
-}
-
-
-static int
-get_ntpsrv_info(const char *info,struct ntpsrv_info *ntpinfo)
-{
-	char buf[NTP_BUFFLEN];
-	char *sep = " ";
-	char *word,*brkt;
-	int index;
-	
-	strcpy(buf,info);
-	
-	for(word=strtok_r(buf,sep,&brkt),index=0;word;word=strtok_r(NULL,sep,&brkt),index++) {
-		if(index==1) {
-			if(IS_IP4_ADDRESS(word)) {
-				inet_pton(AF_INET,word,&(ntpinfo->in.in_6));
-				ntpinfo->isipv6 = 0;
-			}else {
-				inet_pton(AF_INET6,word,&(ntpinfo->in.in_4));
-				ntpinfo->isipv6 = 1;
-			}
-		}
-		
-		if(index==3) {
-			ntpinfo->version = atoi(word);
-		}
-	}
-	
-	return 0;
-}
-
-static int
-update_ntpsrv_conf(char* ip, unsigned int version)
-{
-	FILE	*f;
-	char linebuf[NTP_BUFFLEN*2];	
-	int ret,len;
-
-	if(access(NTP_CONF_FILE, F_OK) ) {
-		f = fopen(NTP_CONF_FILE,"ab+");
-		len = snprintf(linebuf,sizeof(linebuf),"restrict default ignore\n");
-		snprintf(linebuf+len,sizeof(linebuf) -len,"restrict 127.0.0.1\n");
-		fputs(linebuf,f);
-		fclose(f);
-	}
-	
-	f = fopen(NTP_CONF_FILE,"ab+");
-	if(f) {
-		len = snprintf(linebuf,sizeof(linebuf),"server %s version %d\n",ip,version);
-		snprintf(linebuf+len,sizeof(linebuf) -len,"restrict %s kod nomodify notrap nopeer noquery\n",ip);
-		fputs(linebuf,f);
-		fclose(f);
-		ret = 1;
-	} else {
-		ret = 0;
-	}
-		
-	return ret;
-}
-
-
-static int
-get_conf_file_size(const char *filename)
-{
-	struct stat statbuf;
-	int	ret = 0;
-	
-	memset((void *)&statbuf, 0, sizeof(statbuf));
-	ret = stat(filename,&statbuf);
-	if(ret == 0) {
-		return (statbuf.st_size);	
-	} else {
-		syslog(LOG_ERR, " stat faield, errno=%d\n", errno);
-		return 0;
-	}
-}
-
-static int
-isntpon()
-{
-	size_t len = 4;
-	int ntp_type;
-	int ntpdate_enable;
-	
-	if (sysctlbyname("net.inet.clicktcp.ntp_type", &ntp_type, &len, NULL, 0)) {
-		perror("error retrieving ntp information");
-		return 0;
-	}
-	
-	if (ntp_type == NTP_TYPE_NTPDATE) {
-		/*use ntpdate*/
-		if (sysctlbyname("net.inet.clicktcp.ntpdate_enable", &ntpdate_enable, &len, NULL, 0)) {
-			perror("error retrieving ntp information");
-			return 0;
-		}
-		return ntpdate_enable;
-	} else {
-		int ret = system("systemctl -q is-active ntpd");
-		return ret == 0;
-	}
-}
-
-static char *
-getcfg(char *name)
-{
-	static char	buf[NTP_BUFFLEN];
-	FILE    	*ntpconf;
-	char    	tmp[NTP_BUFFLEN], *retval;
-	int		len;
-
-	name	= name ? name : "";
-	tmp[0]	= 0;
-	retval	= NULL;
-	len	= strlen(name);
-
-	ntpconf	= fopen(NTP_CONF_FILE, "r");
-	if (ntpconf) {
-		while (fgets(tmp, NTP_BUFFLEN, ntpconf)) {
-			if (!strncmp(tmp, name, len)) {
-				strtok(&tmp[len], "\n");
-				strcpy(buf, &tmp[len]);
-				retval = &buf[0];
-			}
-		}
-		fclose(ntpconf);
-	}
-
-	return (retval);
-}
-
-static char *
-get_ntpversion()
-{
-	return (getcfg("version "));
-}
-
-static char *
-get_ntpserver()
-{
-	return (getcfg("server "));
-}
-
-static int
-update_ntp_conf(int ntpkey, int ntpversion, char *ntpserver)
-{
-	FILE	*ntpconf;
-	char	*tmp, wbuf[NTP_BUFFLEN];
-	int	n, fd;
-
-	n	= 0;
-	wbuf[0]	= 0;
-
-	if (ntpserver)
-		n += sprintf(&wbuf[n], "server %s\n", ntpserver);
-
-	if (ntpversion && ntpversion != 4)
-		n += sprintf(&wbuf[n], "version %d\n", ntpversion);
-
-	ntpconf = fopen(NTP_CONF_FILE, "r");
-	if (ntpconf) {
-		fclose(ntpconf);
-		tmp = get_ntpserver();
-		if (tmp && !ntpserver)
-			n += sprintf(&wbuf[n], "server %s\n", tmp);
-
-		tmp = get_ntpversion();
-		if (tmp && !ntpversion)
-			n += sprintf(&wbuf[n], "version %s\n", tmp);
-	}
-	fd = open(NTP_CONF_FILE, O_CREAT|O_RDWR|O_TRUNC, 0644);
-	if (fd >= 0) {
-		write(fd, wbuf, strlen(wbuf));
-		close(fd);
-	}
-	else {
-		perror("open");
-	}
-
-	return (0);
-}
-
-extern int removeProcess(int,char*);
-int
-ui_ntpoff()
-{
-	size_t len = 4;
-	int ntpdate_enable = 0;
-	int ntp_type;
-	struct stat s;
-	int ret;
-	
-	if (sysctlbyname("net.inet.clicktcp.ntp_type", &ntp_type, &len, NULL, 0)) {
-		printf("Error ntp off\n");
-		return -1;
-	}
-	
-	if (ntp_type == NTP_TYPE_NTPD) {
-#ifndef UOS_X86
-		system("systemctl stop ntpdate");
-#endif
-		if (system("systemctl stop ntpd") != 0) {
-			printf("Failed to turn NTP off\n" );
-		}
-	} else if (ntp_type == NTP_TYPE_NTPDATE) {
-		if (sysctlbyname("net.inet.clicktcp.ntpdate_enable", NULL, NULL, &ntpdate_enable, sizeof(ntpdate_enable))) {
-			printf("Error ntp off\n");
-			return -1;
-		}
-		bzero(&s, sizeof(s));
-		if(stat("/var/crash/cron_ntp", &s) == 0 && S_ISREG(s.st_mode)){
-			system("cat /dev/null > /var/crash/cron_ntp");
-		}
-		ret = system("systemctl -q is-active ntpd");
-		if (ret == 0) {
-			if (system("systemctl stop ntpd") != 0) {
-				printf("Failed to turn NTP off\n" );
-			}
-		}	
-	} else {
-		printf("Error ntp off\n");
-		return -1;
-	}
-	return (0);
-}
-
-static char *
-get_ntpserver_ips(char* servers)
-{
-    char buf[NTP_BUFFLEN + 64] = {0};
-    char cmd[] = "awk '{if($1==\"server\"){print $2}}' /etc/ntp.conf | tr '\\n' ' '";
-    FILE *fp = popen(cmd, "r");
+    sprintf(id_str, "%d", key_id);
+
+    while (fgets(linebuf, sizeof(linebuf), fp)) {
+        if (strncmp(linebuf, "#", 1) && 
+            strncmp(linebuf, id_str, strlen(id_str)) == 0 &&
+            linebuf[strlen(id_str)] == ' ') {
+            found = 1;
+            continue;
+        } else {
+            fputs(linebuf, fp_tmp);
+        }
+    }
+
+    fclose(fp);
+    fclose(fp_tmp);
+
+    unlink(CHRONY_KEYS_FILE);
+    rename(CHRONY_KEYS_TMP, CHRONY_KEYS_FILE);
+
+    return found;
+}
+
+static void print_ntp_servers() {
+    FILE *fp = NULL;
+    char buffer[1024];
+
+    fp = fopen(CHRONY_CONF_FILE, "r");
     if (fp) {
-        if (fgets(buf, NTP_BUFFLEN + 64, fp)) {
-            if (strlen(buf) > NTP_BUFFLEN) {
-                char* begin = buf + NTP_BUFFLEN;
-                for (; *begin != ' '; --begin);
-                *begin = 0;
-                ++begin;
-                char* end = buf + NTP_BUFFLEN + 1;
-                for (; *end != ' '; ++end);
-                *end = 0;
-                printf("With too many NTP servers configured, ntpdate will ignore server %s and subsequent servers.\n", begin);
-            } else {
-                buf[strlen(buf) - 1] = 0;
+        printf("\n");
+        while (fgets(buffer, sizeof(buffer), fp)) {
+            if(strncmp(buffer, "server", 6) == 0) {
+                printf("%s", buffer);
             }
         }
-        pclose(fp);
+        printf("\n");
     }
-    return strcpy(servers, buf);
+
+    fclose(fp);
 }
 
-static int 
-is_ntp_service_active() {
-    char command[256];
-    snprintf(command, sizeof(command), "systemctl is-active ntpd");
+static int compare_keys(const void *a, const void *b) 
+{
+    chronyKey *key1 = (chronyKey *)a;
+    chronyKey *key2 = (chronyKey *)b;
+    return key1->key - key2->key;
+}
 
-    FILE *fp = popen(command, "r");
-    if (fp == NULL) {
-        perror("popen");
-        return -1;
+static int get_conf_file_size(const char *filename)
+{
+    struct stat statbuf;
+    int	ret = 0;
+
+    memset((void *)&statbuf, 0, sizeof(statbuf));
+    ret = stat(filename,&statbuf);
+    if(ret == 0) {
+        return (statbuf.st_size);	
+    } else {
+        syslog(LOG_ERR, " stat faield, errno=%d\n", errno);
+        return 0;
+    }
+}
+
+static int isntpon()
+{
+    return access(CHRONYD_PID_FILE, F_OK) == 0;
+}
+
+static void add_ntpsrv_conf(char *host, char *cfg) 
+{
+    FILE *fp, *fp_tmp;
+    char linebuf[2048] = {0}, prefix[1024] = {0};
+    int found = 0;
+
+    if (access(CHRONY_CONF_FILE, F_OK)) {
+        printf("Access %s error\n", CHRONY_CONF_FILE);
+        return 0;
     }
 
-    char result[128];
-    if (fgets(result, sizeof(result), fp) == NULL) {
-        pclose(fp);
+    fp = fopen(CHRONY_CONF_FILE, "r");
+    if (!fp) {
+        printf("Open %s error\n", CHRONY_CONF_FILE);
         return 0;
     }
 
-    pclose(fp);
+    fp_tmp = fopen(CHRONY_CONF_TMP, "w+");
+    if (!fp_tmp) {
+        fclose(fp);
+        printf("Open %s error\n", CHRONY_CONF_TMP);
+        return 0;
+    }
+
+    snprintf(prefix, sizeof(prefix), "server %s", host);
+
+    while (fgets(linebuf, sizeof(linebuf), fp)) {
+        if (strncmp(linebuf, prefix, strlen(prefix)) == 0 &&
+            (linebuf[strlen(prefix)] == '\0' || 
+             linebuf[strlen(prefix)] == ' ' || 
+             linebuf[strlen(prefix)] == '\n')) {
+            continue;
+        } else {
+            fputs(linebuf, fp_tmp);
+        }
+    }
+
+    fputs(cfg, fp_tmp);
+    fputs("\n", fp_tmp);
+
+    fclose(fp);
+    fclose(fp_tmp);
+
+    unlink(CHRONY_CONF_FILE);
+    rename(CHRONY_CONF_TMP, CHRONY_CONF_FILE);
+}
+
+int ui_ntpoff()
+{
+    int ntp_enable = 0;
+
+    if (sysctlbyname("net.inet.clicktcp.ntp_enable", NULL, NULL, &ntp_enable, sizeof(ntp_enable))) {
+        printf("Error ntp off\n");
+        return -1;
+    }
+
+    system(CHRONYD_STOP_CMD);
+
+    return 0;
+}
+
+int ui_ntpon()
+{
+    int ntp_enable = 1;
+    time_t tm, to_atcp_tm;
+    struct tm *lt;
+
+    if (sysctlbyname("net.inet.clicktcp.ntp_enable", NULL, NULL, &ntp_enable, sizeof(ntp_enable))) {
+        printf("Error ntp on\n");
+        return -1;
+    }
+
+    system(CHRONYD_START_CMD);
+    sleep(1);
+
+    /* Change time may cause rsyslog donnot work normally, so delete imjournal.state and restart rsyslog */
+    unlink(TIME_STATE_FILE);
+    system(RSYSLOG_RESTART_CMD);
+
+    time(&tm);
+    lt = localtime(&tm);
+    to_atcp_tm = mktime(lt);
+    kern_set_timer(&to_atcp_tm, sizeof(to_atcp_tm));
+
+    settimezone();
+    sysmon_touch();
+
+    return (0);
+}
+
+int crontab_ntp_on()
+{
+    char cmd[256];
+    time_t  tm, to_atcp_tm;
+    struct tm *lt;
+
+    /* Sync time by crontab */
+    system(CHRONYC_SYNC_TIME_CMD);
+
+    /* Write tracking status to cron_ntp */
+    snprintf(cmd, sizeof(cmd), "%s >> /var/crash/cron_ntp && echo \"\" >> /var/crash/cron_ntp", CHRONYC_TRACKING_CMD);
+    system(cmd);
+
+    time(&tm);
+    lt = localtime(&tm);
+    to_atcp_tm = mktime(lt);
+    kern_set_timer(&to_atcp_tm, sizeof(to_atcp_tm));
+
+    settimezone();
+
+    return 0;
+}
+
+int crontab_ntp_sync_systime()
+{
+    time_t  tm, to_atcp_tm;
+    struct tm *lt;
+
+    if(isntpon()) {
+        time(&tm);
+        lt = localtime(&tm);
+        to_atcp_tm = mktime(lt);
+        kern_set_timer(&to_atcp_tm, sizeof(to_atcp_tm));
+        settimezone();
+        sysmon_touch();
+    }
+
+    return 0;
+}
+
+int ui_ntpserver(char *host, char *option, int key_id) 
+{
+    char srv_config[1024] = {0}, cmd[1024], copy[256] = {0};
+    char *token, *support_options[] = {"nts", "iburst"};
+    int cases = sizeof(support_options) / sizeof(support_options[0]);
+    int i, support = 0;
+    FILE *fp = NULL;
+
+    /* Check input hostname */
+    if (host == NULL || *host == '\0') {
+        printf("Invalid hostname, hostname is not allowed to be empty\n");
+        return -1;
+    }
+
+    if (host != NULL && strchr(host, ' ')) {
+        printf("Invalid hostname, space is not permited\n");
+        return -1;
+    }
+
+    /* Check input options */
+    if (!option || option[0] == '\0') {
+        snprintf(srv_config, sizeof(srv_config), "server %s", host);
+    } else {
+        strncpy(copy, option, sizeof(copy)-1);
+        token = strtok(copy, " ");
+        while (token != NULL) {
+            for (i = 0; i < cases; i++) {
+                if (strcmp(token, support_options[i]) == 0) {
+                    support = 1;
+                    break;
+                }
+            }
+            if(!support) {
+                printf("Invalid option found\n");
+                return -1;
+            }
+            token = strtok(NULL, " ");
+            support = 0;
+        }
+        snprintf(srv_config, sizeof(srv_config), "server %s %s", host, option);
+    }
+
+    /* Append the key if key_id is provided */
+    if(key_id) {
+        snprintf(srv_config + strlen(srv_config), sizeof(srv_config) - strlen(srv_config), " key %d", key_id);
+    }
+
+    /* Add server config into chrony.conf */
+    add_ntpsrv_conf(host, srv_config);
+
+    /* Dynamically add to chrony if daemon is running */
+    if(isntpon()) {
+        sprintf(cmd, "%s %s", CHRONYC_ADD_SRV_CMD, srv_config);
+        system(cmd);
+    }
+
+    return 0;
+}
+
+int ui_no_ntpserver(char *host)
+{
+    char cmd[256] = {0};
+
+    if(!delete_ntpsrv_conf(host)) {
+        printf("The NTP server %s does not exist\n", host);
+        return 1;
+    }
+
+    /* Dynamically delete to chrony if daemon is running */
+    if(isntpon()) {
+        sprintf(cmd, "%s %s", CHRONYC_DEL_SRV_CMD, host);
+        system(cmd);
+        system(CHRONYC_RESET_CMD);
+    }
 
-    return strncmp(result, "active", 6) == 0;
+    return 0;
 }
 
-int
-ui_ntpon(int ntp_type)
+int ui_ntp_auth_key(int key_id, char *key_str, char *encrypted_flag) 
 {
-	char	server[NTP_BUFFLEN] = {0};
-	char	ntpdate_cmd[2048];
-	size_t len = 4;
-	int ntpdate_enable = 1;
-        time_t  tm, to_atcp_tm;
-        struct tm *lt;
-
-	if (ntp_type != NTP_TYPE_NTPD && ntp_type != NTP_TYPE_NTPDATE) {
-		printf("Invalid synchronization software index. Please input 0 or 1.\n");
-		return 0;
-	}
-
-	get_ntpserver_ips(server);
-	if(strlen(server) == 0) {
-		printf("Please configure NTP server first\n");
-		return 0;
-	}
-
-	if (sysctlbyname("net.inet.clicktcp.ntp_type", NULL, NULL, &ntp_type, sizeof(ntp_type))) {
-		printf("Error ntp on\n");
-		return -1;
-	}
-
-	ui_ntpoff();
-	 
-	if (ntp_type == NTP_TYPE_NTPD) {
-#ifdef UOS_X86
-		snprintf(ntpdate_cmd, 2048, "/usr/sbin/ntpdate %s", server);
-		system(ntpdate_cmd);
-#else
-		system("systemctl start ntpdate");
-#endif
-		/* In an HA bootup sync environment, starting ntpd returns non-zero for unknown reasons, 
-		   but the service is running fine. Add a workaround to check if ntpd is not running 
-		   before handling the error. */
-		if (system("systemctl start ntpd") != 0 && !is_ntp_service_active()) {
-			system("systemctl stop ntpd");
-			printf("Failed to turn NTP on\n");
-			return -1;
-		}
-	} else if (ntp_type == NTP_TYPE_NTPDATE) {
-		if (sysctlbyname("net.inet.clicktcp.ntpdate_enable", NULL, NULL, &ntpdate_enable, sizeof(ntpdate_enable))) {
-			printf("Error ntp on\n");
-			return -1;
-		}
-		
-		snprintf(ntpdate_cmd, 2048, "/usr/sbin/ntpdate %s >> /var/crash/cron_ntp", server);
-		int ntp_ret = system(ntpdate_cmd);
-		if (ntp_ret == -1 || !WIFEXITED(ntp_ret) || WEXITSTATUS(ntp_ret)) {
-			ntpdate_enable = 2;
-			sysctlbyname("net.inet.clicktcp.ntpdate_enable", NULL, NULL, &ntpdate_enable, sizeof(ntpdate_enable));
-		}
-	}
-
-	time(&tm);
-	lt = localtime(&tm);
-	to_atcp_tm = mktime(lt);
-	kern_set_timer(&to_atcp_tm, sizeof(to_atcp_tm));
-
-	settimezone();
-	sysmon_touch();
-	
-	return (0);
-}
-#if 0
-int
-ui_ntpon_back()
-{
-        sigset_t        new, saved;
-        char    buf[BUFSIZ];
-        FILE    *fp;
-        int             pstat;
-        pid_t           pid;
-	char		argment[100];
-        /*signal(SIGALRM,ui_ntpwdttouch);*/
-	printf("WARNING: DUE TO THE FACT THAT SOME TM FUNCTIONS DEPEND ON SYSTEM TIME, TURNING\n"); 
-	printf("ON NTP SERVICE MAY CAUSE SYSTEM REBOOT IF THE DIFFERENCE BETWEEN THE SYSTEM\n"); 
-	printf("CURRENT TIME AND THE NTP SERVER TIME IS BIG. TO AVOID THIS PROBLEM FROM\n"); 
-	printf("HAPPENING, WE STRONGLY SUGGEST DO THE FOLLOWING:\n\n");
-	printf("1. USE THE SYSTEM COMMAND TO AJDUST THE SYSTEM TIME TO BE AS CLOSE TO THE NTP \n");
-	printf("   TIME AS POSSIBLE\n");
-	printf("2. REBOOT THE TM\n");
-	printf("3. TURN ON THE NTP SERVICE\n");
-	printf("Continue to turn on NTP (ANY KEY FOR YES AND YOU CAN INPUT \"NO\" TO CANCEL)?");
-
-        if (!challange_user("NO\n")) {
-                printf("ntpd has been turned on! \n");
-        }
-	else{
-                printf("ntp on aborted by user\n");
-		return -1;
-	}
-
-        ui_ntpoff();
-
-        sigemptyset(&new);
-        sigprocmask(SIG_SETMASK, &new, &saved); /* get the current mask */
-
-        pid = fork();
-        switch (pid) {
-                case   0:
-                        execl(NTPD_PATH, "ntpd", "-g", "-p", NTP_PID_FILE, NULL);
-                        perror("execl");
-                        _exit(1);
-                        break;
-                case  -1:
-                        perror("fork");
-                        break;
-                default :
-                        break;
-        }
-
-	while(1){
-        	fp = fopen(NTP_PID_FILE, "r");
-        	if (!fp)
-        	       sleep(1);
-		else
-		       break; 
-	}
-
-        if (fgets(buf, BUFSIZ, fp)) {
-                pid = atoi(buf);
-                if (pid > 0) {
-			printf("the pid is %d \n",pid);
+    char md5_key[NTP_MAX_AUTH_KEY_LEN] = {0};
+    char *tmp;
+
+    /* Check key id range */
+    if(key_id < NTP_MIN_AUTH_KEY_ID || key_id > NTP_MAX_AUTH_KEY_ID) {
+        printf("The key ID range must be between %d and %d\n", NTP_MIN_AUTH_KEY_ID, NTP_MAX_AUTH_KEY_ID);
+        return 1;
+    }
+
+    /* If key string is encrypted, decrypt first */
+    if(strcmp(encrypted_flag, NTP_ENCRYPTED_FLAG) == 0) {
+        decrypt_secret(key_str, md5_key);
+    } else {
+        /* Check length of key string not exceed */
+        if(strlen(key_str) > NTP_MAX_AUTH_KEY_LEN) {
+            printf("Maximum key string length is %d.\n", NTP_MAX_AUTH_KEY_LEN);
+            return 1;
+        }
+
+        /* Check key can't be null */
+        if(strlen(key_str) == 0) {
+            printf("Not allowed empty key string.\n");
+            return 1;
+        }
+
+        /* Check key string is valid */
+        tmp = key_str;
+        while(*tmp) {
+            if((*tmp >= 'A' && *tmp <= 'Z') || (*tmp >= 'a' && *tmp <= 'z') ||
+                (*tmp >= '0' && *tmp <= '9') || (*tmp == '_')) {
+                tmp++;
+            } else {
+                printf("value can only contain the following characters: A\-Z, a\-z, 0\-9, and underscore (_).\n");
+                return 1;
+            }
+        }
+
+        strcpy(md5_key, key_str);
+    }
+
+    /* Add key to chrony.keys */
+    add_ntpkey_conf(key_id, md5_key);
+
+    /* Dynamically add to chrony if daemon is running */
+    if(isntpon()) {
+        system(CHRONYC_REKEY_CMD);
+        system(CHRONYC_RELOAD_SRC_CMD);
+    }
+
+    return 0;
+}
+
+int ui_no_ntp_auth_key(int key_id)
+{
+    if(!delete_ntpkey_conf(key_id)) {
+        printf("NTP authentication key not found\n");
+        return 1;
+    }
+
+    /* Dynamically remove to chrony if daemon is running */
+    if(isntpon()) {
+        system(CHRONYC_REKEY_CMD);
+        system(CHRONYC_RELOAD_SRC_CMD);
+    }
+
+    return 0;
+}
+
+char *write_ntp(char *segment)
+{
+    char *buf;
+    char linebuf[1024];
+    char key_str[NTP_MAX_AUTH_KEY_LEN];
+    char encrypt_key[NTP_ENCRYPTED_LEN];
+    char server[512], option[10], algorithm[10];
+    int i = 0, size = 0, key_id = 0;
+    FILE *fp = NULL;
+
+    size = get_conf_file_size(CHRONY_CONF_FILE) + get_conf_file_size(CHRONY_KEYS_FILE) + strlen("ntp off\n");
+    buf = calloc(size, sizeof(char));
+
+    fp = fopen(CHRONY_KEYS_FILE, "r");
+    while(fgets(linebuf, sizeof(linebuf), fp)) {
+        if(linebuf[0] != '#' && linebuf[0] != '\n') {
+            sscanf(linebuf, "%d %s %s", &key_id, algorithm, key_str);
+            encrypt_secret(key_str, encrypt_key);
+            i += snprintf(buf + i, size - i, "ntp key %d \"%s\" \"%s\"\n", key_id, encrypt_key, NTP_ENCRYPTED_FLAG);
+        }
+    }
+    fclose(fp);
+
+    fp = fopen(CHRONY_CONF_FILE, "r");
+    while(fgets(linebuf, sizeof(linebuf), fp)) {
+        if (strstr(linebuf, "server")){
+            char *copy = strdup(linebuf);
+            char *token;
+
+            copy[strlen(copy)-1] = '\0';
+
+            memset(server, '\0', sizeof(server));
+            memset(option, '\0', sizeof(option));
+            key_id = 0;
+
+            token = strtok(copy, " ");
+            token = strtok(NULL, " ");
+            if (token) {
+                strcpy(server, token);
+            }
+
+            while ((token = strtok(NULL, " ")) != NULL) {
+                if (strcmp(token, "key") == 0) {
+                    token = strtok(NULL, " ");
+                    if (token) {
+                        key_id = atoi(token);
+                    }
+                } else {
+                    strcpy(option, token);
                 }
+            }
+
+            if(key_id) {
+                i += snprintf(buf + i, size - i, "ntp server \"%s\" \"%s\" %d\n", server, option, key_id);
+            } else if (strcmp(option, "key") == 0) {
+                i += snprintf(buf + i, size - i, "ntp server \"%s\" %d\n", server, key_id);
+            } else if (strcmp(option, "") == 0) {
+                i += snprintf(buf + i, size - i, "ntp server \"%s\"\n", server);
+            } else {
+                i += snprintf(buf + i, size - i, "ntp server \"%s\" \"%s\"\n", server, option);
+            }
+
+            free(copy);
         }
-	sprintf(argment,"/ca/bin/sysmon -c%s -g -p%s -I%d",NTPD_PATH,NTP_PID_FILE,pid); 
-	fastlog_logex( CLI_L_1, 0 );
-	system(argment);  
-	fastlog_logex( CLI_L_2, 0 );
-        /*alarm(60);
-        waitpid(pid, &pstat, 0);*/
-        sigprocmask(SIG_SETMASK, &saved, NULL); /*restore back to original mask*/ 
-        /*alarm(1);*/
-        waitpid(pid, &pstat, 0);
-        return (0);
-}
-#endif
-
-int 
-crontab_ntp_on()
-{
-	size_t len = 4;
-	int ntpdate_enable;
-	char server[NTP_BUFFLEN] = {0};
-	char ntpdate_cmd[2048];
-	time_t  tm, to_atcp_tm;
-	struct tm *lt;
-	
-	if (sysctlbyname("net.inet.clicktcp.ntpdate_enable", &ntpdate_enable, &len, NULL, 0)) {
-		return -1;
-	}
-	
-	if (ntpdate_enable) {
-		get_ntpserver_ips(server);
-		if(strlen(server) == 0) {
-			return 0;
-		} 
-		snprintf(ntpdate_cmd, 2048, "/usr/sbin/ntpdate %s >> /var/crash/cron_ntp", server);
-		int ntp_ret = system(ntpdate_cmd);
-		if (ntp_ret == -1 || !WIFEXITED(ntp_ret) || WEXITSTATUS(ntp_ret)) {
-			ntpdate_enable = 2;
-			sysctlbyname("net.inet.clicktcp.ntpdate_enable", NULL, NULL, &ntpdate_enable, sizeof(ntpdate_enable));
-		}
-
-		time(&tm);
-		lt = localtime(&tm);
-		to_atcp_tm = mktime(lt);
-		kern_set_timer(&to_atcp_tm, sizeof(to_atcp_tm));
-
-		settimezone();
-		return 0;
-	} else {
-		return 0;
-	}
-}
-
-int 
-crontab_ntp_sync_systime()
-{
-	time_t  tm, to_atcp_tm;
-	struct tm *lt;
-	size_t len = 4;
-        int ntpdate_enable;
+    }
+    fclose(fp);
 
-        if (sysctlbyname("net.inet.clicktcp.ntpdate_enable", &ntpdate_enable, &len, NULL, 0)) {
-                return -1;
+    if(isntpon()){
+        i += snprintf(buf + i, size - i, "ntp on\n");
+    }else{
+        i += snprintf(buf + i, size - i, "ntp off\n");
+    }
+
+    return buf;
+}
+
+int ui_showntp()
+{
+    char line[1024];
+    FILE *fp;
+
+    if(isntpon()) {
+        printf("Chrony daemon is running.\n");
+
+        print_ntp_servers();
+
+        printf("Chrony Sources:\n");
+        fp = popen(CHRONYC_SOURCES_CMD, "r");
+        while (fgets(line, sizeof(line), fp) != NULL) {
+            printf("%s", line);
         }
 
-	if(isntpon() && (ntpdate_enable == 0)) {
-		time(&tm);
-		lt = localtime(&tm);
-		to_atcp_tm = mktime(lt);	
-		kern_set_timer(&to_atcp_tm, sizeof(to_atcp_tm));
-		
-		settimezone();
-		sysmon_touch();
-
-	}
-	return 0;
-}
-
-int
-ui_ntpversion(int version)
-{
-	if (version > 4 || version < 1) {
-		printf("Valid values are between 1 and 4 (default 4)\n");
-		return (0);
-	}
-	update_ntp_conf(0, version, NULL);
-
-	return (0);
-}
-
-int
-ui_ntpserver(char* ip, unsigned int version)
-{
-	int ret,isipv6;
-	struct in6_addr addr_6;
-	struct in_addr  addr_4;
-	
-	if(IS_IP6_ADDRESS(ip)) {
-		ret = inet_pton(AF_INET6, ip, &addr_6);
-		if(ret != 1) {
-			printf(("Address format error\n"));
-			return -1;
-		}
-		
-		if(invalid_ip_check(&addr_6, 1, 0)) {
-			printf(("Please use a global unicast IPv6 address\n"));
-			return -1;
-		}
-		isipv6 = 1;
-	} else {
-		ret = inet_pton(AF_INET, ip, &addr_4);
-		if(ret != 1) {
-			printf(("Address format error\n"));
-			return -1;
-		}
-		if(invalid_ip_check(&addr_4.s_addr, 0, 0)) {
-			printf(("Please use a legal unicast IPv4 address\n"));
-			return -1;
-		}
-		isipv6 = 0;
-	} 
-		
-	if (isntpon()) {
-		printf("ntp server can be configured only when ntp is off\n");
-		return 0;
-	}
-
-	if (version > 4 || version < 1) {
-		printf("Valid values are between 1 and 4 (default 4)\n");
-		return 0;
-	}
-
-	if(isipv6) {
-		if(is_ntpsrv_ipv6_exist(&addr_6,version)) {
-			printf("server %s %d is already configured.\n",ip,version);
-			return 0;
- 		}
-	} else {
-		if(is_ntpsrv_ipv4_exist(&addr_4,version)) {
-			printf("server %s %d is already configured.\n",ip,version);
-			return 0;
-		}
-	}
-			
-	if(!update_ntpsrv_conf(ip,version)) {
-		printf("Fail to update ntp server configuration file.\n");
-	}
-	return (0);
-}
-
-static int
-delete_ntpsrv_conf(char* ip, unsigned int version)
-{
-	FILE *fp, *fp_tmp;
-	char linebuf[NTP_BUFFLEN * 2];
-	char *p;
-
-	if (access(NTP_CONF_FILE, F_OK)) {
-		printf("Access %s error\n", NTP_CONF_FILE);
-		return 0;
-	}
-
-	fp = fopen(NTP_CONF_FILE, "r");
-	if (!fp) {
-		printf("Open %s error\n", NTP_CONF_FILE);
-		return 0;
-	}
-
-	fp_tmp = fopen(TMP_NTP_CONF_FILE, "w+");
-	if (!fp_tmp) {
-		fclose(fp);
-		printf("Open %s error\n", TMP_NTP_CONF_FILE);
-		return 0;
-	}
-
-	while (fgets(linebuf, sizeof(linebuf), fp)) {
-		if (strstr(linebuf, "server") && strstr(linebuf, ip)) {
-			 p = strstr(linebuf, "version");
-			 if (p && atoi(p + strlen("version")) == version) {
-				if (fgets(linebuf, sizeof(linebuf), fp) &&
-					!strstr(linebuf, ip)) {
-					fputs(linebuf, fp_tmp);
-				}
-			 } else {
-				fputs(linebuf, fp_tmp);
-			 }
-		} else {
-			fputs(linebuf, fp_tmp);
-		}
-	}
-
-	fclose(fp);
-	fclose(fp_tmp);
-
-	if (unlink(NTP_CONF_FILE)) {
-		printf("Unlink %s error\n", NTP_CONF_FILE);
-	}
-
-	if (rename(TMP_NTP_CONF_FILE, NTP_CONF_FILE)) {
-		printf("Rename %s to %s error\n",
-			   TMP_NTP_CONF_FILE, NTP_CONF_FILE);
-		return 0;
-	}
-
-	return 1;
-}
-
-int
-ui_no_ntpserver(char* ip, unsigned int version)
-{
-	int ret, isipv6;
-	struct in6_addr addr_6;
-	struct in_addr  addr_4;
-
-	if (IS_IP6_ADDRESS(ip)) {
-		ret = inet_pton(AF_INET6, ip, &addr_6);
-		if (ret != 1) {
-			printf("Address format error\n");
-			return -1;
-		}
-		isipv6 = 1;
-	} else {
-		ret = inet_pton(AF_INET, ip, &addr_4);
-		if (ret != 1) {
-			printf("Address format error\n");
-			return -1;
-		}
-		isipv6 = 0;
-	}
-
-	if (isntpon()) {
-		printf("The NTP server can be configured only when ntp is off\n");
-		return 0;
-	}
-
-	if (isipv6) {
-		if (is_ntpsrv_ipv6_exist(&addr_6, version)) {
-			if (!delete_ntpsrv_conf(ip, version)) {
-				return 1;
-			}
- 		} else {
-			printf("The NTP server %s %d does not exist\n", ip, version);
-			return 0;
-		}
-	} else {
-		if (is_ntpsrv_ipv4_exist(&addr_4, version)) {
-			if (!delete_ntpsrv_conf(ip, version)) {
-				return 1;
-			}
-		} else {
-			printf("The NTP server %s %d does not exist\n", ip, version);
-			return 0;
-		}
-	}
-
-	return (0);
-}
-
-static int
-print_ntppeers()
-{
-	if (!isntpon())
-		return (-1);
-
-#if defined(__linux__)
-	/* definitely tell ntpdc to use IPv4 */
-#if defined(UOS_X86) || defined(KYLIN)
-	return (ptyrun("ntp", NTPQ_PATH, "ntpq", "-4", "-n", "-c", "peers", NULL));
-#else
-	return (ptyrun("ntp", NTPDC_PATH, "ntpdc", "-4", "-n", "-c", "peers", NULL));
-#endif
-#else
-	return (ptyrun("ntp", NTPQ_PATH, "ntpq", "-n", "-c", "peers", NULL));
-#endif
-}
-
-static int
-print_ntpstat()
-{
-	if (!isntpon())
-		return (-1);
-
-#if defined(__linux__)
-	/* definitely tell ntpdc to use IPv4 */
-#if defined(UOS_X86) || defined(KYLIN)
-	return (ptyrun("ntp", NTPQ_PATH, "ntpq", "-4", "-c", "sysstats", NULL));
-#else
-	return (ptyrun("ntp", NTPDC_PATH, "ntpdc", "-4", "-c", "sysstats", NULL));
-#endif
-#else
-	return (ptyrun("ntp", NTPQ_PATH, "ntpq", "-c", "sysstats", NULL));
-#endif
-}
-
-
-char *
-write_ntp(char *segment)
-{
-	char *buf;
-	char linebuf[NTP_BUFFLEN];
-	char tmp_ip[INET6_ADDRSTRLEN];
-	int size;
-	int	idx = 0;
-	FILE	*f;
-	struct ntpsrv_info ntpinfo;
-	size_t len = 4;
-	int ntpdate_enable;
-	int ntp_type;
-	int ntp_cfg_file_size = 0;
-	int ntp_status_len = 0;
-	
-	if (sysctlbyname("net.inet.clicktcp.ntp_type", &ntp_type, &len, NULL, 0)) {
-		perror("error retrieving ntp information");
-		return NULL;
-	}
-
-	ntp_cfg_file_size = get_conf_file_size(NTP_CONF_FILE);
-	
-	ntp_status_len =  strlen("ntp on 0\n");
-	
-	size = ntp_cfg_file_size + ntp_status_len ;
-	buf = malloc(size);
-	if(!buf) {
-		syslog(LOG_CRIT, "failed to malloc memory, errno=%d\n", errno);
-		return buf;
-	}
-	
-	f = fopen(NTP_CONF_FILE,"r");
-	if(f) {
-		while(fgets(linebuf,NTP_BUFFLEN,f)) {
-			if (linebuf[0] == '#') { /* comments, skip */
-				continue;
-			}
-			if(strstr(linebuf,"restrict")!= NULL) {
-				continue;
-			}
-			get_ntpsrv_info(linebuf,&ntpinfo);
-			if(ntpinfo.isipv6) {
-				idx += snprintf(buf+idx, size-idx, "ntp server %s %d\n",inet_ntop(AF_INET6,&(ntpinfo.in.in_6),tmp_ip,sizeof(tmp_ip)),ntpinfo.version);
-				if (idx >= size) {
-					fclose(f);
-					syslog(LOG_ERR, "idx >= size\n");
-					return buf;
-				}
-			} else {
-				idx += snprintf(buf+idx, size-idx, "ntp server %s %d\n",inet_ntop(AF_INET,&(ntpinfo.in.in_4),tmp_ip,sizeof(tmp_ip)),ntpinfo.version);
-				if (idx >= size) {
-					fclose(f);
-					syslog(LOG_ERR, "idx >= size\n");
-					return buf;
-				}
-			}
-		}
-
-		fclose(f);
-	}
-	
-	if(isntpon()) {
-		if (ntp_type == NTP_TYPE_NTPD) {
-			idx += snprintf(buf+idx, size-idx, "ntp on 0\n");
-			if (idx >= size) {
-				return buf;
-			}
-		} 
-		else if (ntp_type == NTP_TYPE_NTPDATE) {
-			idx += snprintf(buf+idx, size-idx, "ntp on 1\n");
-			if (idx >= size) {
-				return buf;
-			}
-		} 
-
-	} else {
-			idx += snprintf(buf+idx, size-idx, "ntp off\n");
-			if (idx >= size) {
-				return buf;
-			}
-	}
-	
-	return buf;
-}
-  
-int
-ui_showntp()
-{
-	char	*buf;
-	size_t len = 4;
-	int ntp_type;
-	char tmp[128] = {0};
-	struct stat s;
-
-	buf = write_ntp("");
-	if (buf) {
-		printf("%s", buf);
-		free(buf);
-	}
-	if (sysctlbyname("net.inet.clicktcp.ntp_type", &ntp_type, &len, NULL, 0)) {
-		perror("error retrieving ntp information");
-		return 0;
-	}
-	if (ntp_type == NTP_TYPE_NTPD) {
-		if (!print_ntpstat())
-			printf("\n");
-		print_ntppeers();
-	} else {
-		
-		bzero(&s, sizeof(s));
-		if(stat("/var/crash/cron_ntp", &s) == 0 && S_ISREG(s.st_mode)){
-			printf("\n");
-
-			snprintf(tmp,sizeof(tmp), "grep -e 'ntpdate' /var/crash/cron_ntp | tail -n 10");
-			std_close_on_exec_off();
-			system(tmp);
-		}	std_close_on_exec_on();
-
-	}	
-	return (0);
-}
-int
-ui_clearntp()
-{
-	size_t len = 4;
-	int ntpdate_enable=0;
-
-	ui_ntpoff();
-
-	if (sysctlbyname("net.inet.clicktcp.ntpdate_enable", NULL, NULL, &ntpdate_enable, sizeof(ntpdate_enable))) {
-		printf("Error clear ntp");
-		return -1;
-	}
-	unlink(NTP_CONF_FILE);
+        printf("\nChrony Authentication Data:\n");
+        fp = popen(CHRONYC_AUTH_CMD, "r");
+        while (fgets(line, sizeof(line), fp) != NULL) {
+            printf("%s", line);
+        }
+    } else {
+        printf("Chrony daemon is not running.\n");
+        print_ntp_servers();
+    }
+
+    return 0; 
+}
+
+int ui_showntp_auth_keys()
+{
+    FILE *fp = NULL;
+    chronyKey keys[65535];
+    int i, count = 0;
+    char line[256];
+
+    fp = fopen(CHRONY_KEYS_FILE, "r");
+    if (!fp) {
+        printf("Failed to open chrony keys file\n");
+        return 1;
+    }
+
+    while (fgets(line, sizeof(line), fp)) {
+        if(strncmp(line, "#", 1) && strncmp(line, "\n", 1)) {
+            sscanf(line, "%d %s %[^\n]", &keys[count].key, keys[count].type, keys[count].value);
+            count++;
+        }
+    }
+    fclose(fp);
+
+    if(count > 0) {
+        /* Sort key */
+        qsort(keys, count, sizeof(chronyKey), compare_keys);
+
+        /* Display */
+        printf("Key ID     MD5 String\n");
+        printf("---------- --------------------------------\n");    
+        for(i = 0; i < count; i++) {
+            printf("%-8d   %s\n", keys[i].key, keys[i].value);
+        }        
+    }
+
+    return 0;
+}
+
+int ui_clearntp()
+{
+    size_t len = 4;
+    int ntp_enable=0;
+    char reset_conf[1024];
+    char reset_keys[1024];
+
+    ui_ntpoff();
+
+    if (sysctlbyname("net.inet.clicktcp.ntp_enable", NULL, NULL, &ntp_enable, sizeof(ntp_enable))) {
+        printf("Error clear ntp");
+        return -1;
+    }
+
+    unlink(CHRONY_CONF_FILE);
+    unlink(CHRONY_KEYS_FILE);
+
+    sprintf(reset_conf, "cp -f %s %s", CHRONY_CONF_DEFAULT, CHRONY_CONF_FILE);
+    system(reset_conf);
+    sprintf(reset_keys, "cp -f %s %s", CHRONY_KEYS_DEFAULT, CHRONY_KEYS_FILE);
+    system(reset_keys);
 
-	return (0);	
+    return 0;
 }
Index: /branches/rel_apv_10_7/usr/click/lib/libca_snmp/snmp_cadmin.c
===================================================================
--- /branches/rel_apv_10_7/usr/click/lib/libca_snmp/snmp_cadmin.c	(revision 38800)
+++ /branches/rel_apv_10_7/usr/click/lib/libca_snmp/snmp_cadmin.c	(working copy)
@@ -231,23 +231,24 @@
 int
 monitor_get_ntp_status() {
 	size_t len = 4;
-	int  ntp_type, ntp_ret, ntpdate_enable;
-	
-	if (u_sysctlbyname("net.inet.clicktcp.ntp_type", &ntp_type, &len, NULL, 0)) {
+	int ntp_enable;
+	FILE *fp = NULL;
+	char buffer[1024] = {0};
+
+	if (u_sysctlbyname("net.inet.clicktcp.ntp_enable", &ntp_enable, &len, NULL, 0)) {
 		return 0;
 	}
 	
-	if (ntp_type == 1) {
-		if (u_sysctlbyname("net.inet.clicktcp.ntpdate_enable", &ntpdate_enable, &len, NULL, 0)) {
+	if (ntp_enable) {
+		fp = popen("LD_LIBRARY_PATH=/usr/local/lib:/usr/local/lib64 /ca/bin/chronyc tracking", "r");
+		if (!fp) {
 			return 0;
 		}
-		if (ntpdate_enable == 1) {
-			return 1;
-		}
-	} else {
-		ntp_ret = system("/usr/bin/ntpstat > /dev/null");
-		if (ntp_ret != -1 && WIFEXITED(ntp_ret) && WEXITSTATUS(ntp_ret) == 0) {
-			return 1;
+
+		while (fgets(buffer, sizeof(buffer), fp)) {
+			if (strstr(buffer, "Leap status") && strstr(buffer, "Normal")) {
+				return 1;
+			}
 		}
 	}
 
Index: /branches/rel_apv_10_7/usr/click/lib/libparser/commands.pm
===================================================================
--- /branches/rel_apv_10_7/usr/click/lib/libparser/commands.pm	(revision 38800)
+++ /branches/rel_apv_10_7/usr/click/lib/libparser/commands.pm	(working copy)
@@ -39619,131 +39619,182 @@
 		function_name => "show_comp_ieworkaround_uagent",
  		function_args => [],
  	},
-	{
-		obj_type => "MENU",
-		name => "ntp",
-		parent_menu => ".",
-		uniq_name => "root_ntp",
-		help_string => "Configure Network Time Protocol (NTP) settings",
-		cmd_attribute => "CMD_ARRAYOS|CMD_SPROXY|CMD_NORMAL",
-		user_level => "CLI_LEVEL_CONFIG",
-	},
-	{
-		obj_type => "ITEM",
-		name => "on",
-		menu => "root_ntp",
-		help_string  => "Enable NTP",
-		cmd_attribute => "CMD_ARRAYOS|CMD_SPROXY|CMD_NORMAL|CMD_GLOBAL",
-		user_level => "CLI_LEVEL_CONFIG",
-		function_name => "ui_ntpon",
-		function_args => [
-                                        {
-                                                type => "U32",
-                                                help_string => "Index of synchronization software used by the device. 0 is ntpd, 1 is ntpdate. (Default = 0)",
-                                                optional => "YES",
-                                                default_value => 0,
-                                        },
-                                ],
-	},
-	{
-		obj_type => "ITEM",
-		name => "off",
-		menu => "root_ntp",
-		help_string  => "Disable NTP",
-		cmd_attribute => "CMD_ARRAYOS|CMD_SPROXY|CMD_NORMAL|CMD_GLOBAL",
-		user_level => "CLI_LEVEL_CONFIG",
-		function_name => "ui_ntpoff",
-		function_args => [],
-	},
-	{
-                obj_type => "ITEM",
-                name => "crontab",
-                menu => "root_ntp",
-                help_string  => "crontab Enable NTP",
-                cmd_attribute => "CMD_ARRAYOS|CMD_SPROXY|CMD_NORMAL",
-                user_level => "CLI_LEVEL_ENGINEER",
-                function_name => "crontab_ntp_on",
-                function_args => [],
-        },
-	{
-                obj_type => "ITEM",
-                name => "syncsystime",
-                menu => "root_ntp",
-                help_string  => "crontab sync time",
-                cmd_attribute => "CMD_ARRAYOS|CMD_SPROXY|CMD_NORMAL",
-                user_level => "CLI_LEVEL_ENGINEER",
-                function_name => "crontab_ntp_sync_systime",
-                function_args => [],
-        },
-	{
-		obj_type => "ITEM",
-		name => "server",
-		menu => "root_ntp",
-		help_string  => "NTP server to connect to",
-		cmd_attribute => "CMD_ARRAYOS|CMD_SPROXY|CMD_NORMAL|CMD_GLOBAL",
-		user_level => "CLI_LEVEL_CONFIG",
-		function_name => "ui_ntpserver",
-		function_args => [ {
-					type => "IPADDR",
-					help_string => "NTP server IP",
-					optional => "NO",
-					},
-					{
-					type => "U32",
-					help_string => "NTP version (optional, default = 4)",
-					optional => "YES",
-					default_value => "4",
-				}, ],
-	},
-	{
-		obj_type => "MENU",
-		name => "ntp",
-		parent_menu => "root_no",
-		uniq_name => "root_no_ntp",
-		cmd_attribute => "CMD_ARRAYOS|CMD_SPROXY|CMD_NORMAL|CMD_GLOBAL",
-		user_level => "CLI_LEVEL_CONFIG",
-		help_string => "Delete the NTP configuration(s)",
-	},
-	{
-		obj_type => "ITEM",
-		name => "server",
-		menu => "root_no_ntp",
-		help_string  => "Delete the NTP server",
-		cmd_attribute => "CMD_ARRAYOS|CMD_SPROXY|CMD_NORMAL|CMD_GLOBAL",
-		user_level => "CLI_LEVEL_CONFIG",
-		function_name => "ui_no_ntpserver",
-		function_args => [ {
-					type => "IPADDR",
-					help_string => "NTP server IP",
-					optional => "NO",
-					},
-					{
-					type => "U32",
-					help_string => "NTP version (optional, the default value is 4)",
-					optional => "YES",
-					default_value => "4",
-				}, ],
-	},
-	{
-		obj_type => "ITEM",
-		name => "ntp",
-		menu => "root_show",
-		help_string => "Show NTP status",
-		cmd_attribute => "CMD_ARRAYOS|CMD_SPROXY|CMD_NORMAL",
-		user_level => "CLI_LEVEL_ENABLE",
-		function_name => "ui_showntp",
-		function_args => [],
-	},
-	{
-		obj_type => "ITEM",
-		name => "ntp",
-		menu => "root_clear",
-		help_string => "Clear NTP configuration",
-		cmd_attribute => "CMD_ARRAYOS|CMD_SPROXY|CMD_NORMAL|CMD_GLOBAL",
-		user_level => "CLI_LEVEL_CONFIG",
-		function_name => "ui_clearntp",
-		function_args => [],
-	},
+    {
+        obj_type => "MENU",
+        name => "ntp",
+        parent_menu => ".",
+        uniq_name => "root_ntp",
+        help_string => "Configure Network Time Protocol (NTP) settings",
+        cmd_attribute => "CMD_ARRAYOS|CMD_SPROXY|CMD_NORMAL",
+        user_level => "CLI_LEVEL_CONFIG",
+    },
+	{
+        obj_type => "ITEM",
+        name => "on",
+        menu => "root_ntp",
+        help_string  => "Enable NTP",
+        cmd_attribute => "CMD_ARRAYOS|CMD_SPROXY|CMD_NORMAL|CMD_GLOBAL",
+        user_level => "CLI_LEVEL_CONFIG",
+        function_name => "ui_ntpon",
+        function_args => [],
+    },
+    {
+        obj_type => "ITEM",
+        name => "off",
+        menu => "root_ntp",
+        help_string  => "Disable NTP",
+        cmd_attribute => "CMD_ARRAYOS|CMD_SPROXY|CMD_NORMAL|CMD_GLOBAL",
+        user_level => "CLI_LEVEL_CONFIG",
+        function_name => "ui_ntpoff",
+        function_args => [],
+    },
+    {
+        obj_type => "ITEM",
+        name => "crontab",
+        menu => "root_ntp",
+        help_string  => "crontab Enable NTP",
+        cmd_attribute => "CMD_ARRAYOS|CMD_SPROXY|CMD_NORMAL",
+        user_level => "CLI_LEVEL_ENGINEER",
+        function_name => "crontab_ntp_on",
+        function_args => [],
+    },
+    {
+        obj_type => "ITEM",
+        name => "syncsystime",
+        menu => "root_ntp",
+        help_string  => "crontab sync time",
+        cmd_attribute => "CMD_ARRAYOS|CMD_SPROXY|CMD_NORMAL",
+        user_level => "CLI_LEVEL_ENGINEER",
+        function_name => "crontab_ntp_sync_systime",
+        function_args => [],
+    },
+    {
+        obj_type => "ITEM",
+        name => "server",
+        menu => "root_ntp",
+        help_string  => "NTP server to connect to",
+        cmd_attribute => "CMD_ARRAYOS|CMD_SPROXY|CMD_NORMAL|CMD_GLOBAL",
+        user_level => "CLI_LEVEL_CONFIG",
+        function_name => "ui_ntpserver",
+        function_args => [ {
+                                type => "STRING",
+                                help_string => "NTP server IP or URL. NTP need UDP port 123.",
+                                optional => "NO",
+                            },
+                            {
+                                type => "STRING",
+                                help_string => "NTP server option(nts, iburst etc). NTS is on TCP port 4460.",
+                                optional => "YES",
+                                default_value => "NULL",
+                            },
+                            {
+                                type => "U16",
+                                help_string => "Key ID  (Specifies the authentication key ID. Range: 1 to 65535.)",
+                                optional => "YES",
+                                default_value => "0",
+                            }]
+    },
+    {
+        obj_type => "ITEM",
+        name => "key",
+        menu => "root_ntp",
+        help_string  => "Define the NTP authentication key",
+        cmd_attribute => "CMD_ARRAYOS|CMD_SPROXY|CMD_NORMAL|CMD_GLOBAL",
+        user_level => "CLI_LEVEL_CONFIG",
+        function_name => "ui_ntp_auth_key",
+        function_args => [{
+                                type => "U16",
+                                help_string => "Key ID  (Specifies the authentication key ID. Range: 1 to 65535.)",
+                                optional => "NO",
+                            },
+                            {
+                                type => "STRING",
+                                help_string => "Specifies the authentication md5 key",
+                                optional => "NO",
+                            },
+                            {
+                                type => "STRING",
+                                help_string => "",
+                                optional => "YES",
+                                default_value => "\"\"",
+                            }]
+    },
+    {
+        obj_type => "MENU",
+        name => "ntp",
+        parent_menu => "root_no",
+        uniq_name => "root_no_ntp",
+        cmd_attribute => "CMD_ARRAYOS|CMD_SPROXY|CMD_NORMAL|CMD_GLOBAL",
+        user_level => "CLI_LEVEL_CONFIG",
+        help_string => "Delete the NTP configuration(s)",
+    },
+    {
+        obj_type => "ITEM",
+        name => "server",
+        menu => "root_no_ntp",
+        help_string  => "Delete the NTP server",
+        cmd_attribute => "CMD_ARRAYOS|CMD_SPROXY|CMD_NORMAL|CMD_GLOBAL",
+        user_level => "CLI_LEVEL_CONFIG",
+        function_name => "ui_no_ntpserver",
+        function_args => [ {
+                                type => "STRING",
+                                help_string => "NTP server IP or URL.",
+                                optional => "NO",
+                            }],
+    },
+    {
+        obj_type => "ITEM",
+        name => "key",
+        menu => "root_no_ntp",
+        help_string  => "Delete the NTP authentication key",
+        cmd_attribute => "CMD_ARRAYOS|CMD_NORMAL|CMD_GLOBAL",
+        user_level => "CLI_LEVEL_CONFIG",
+        function_name => "ui_no_ntp_auth_key",
+        function_args => [{
+                            type => "U16",
+                            help_string => "Key ID  (Specifies the authentication key ID. Range: 1 to 65535.)",
+                            optional => "NO",
+                        }]
+    },
+    {
+        obj_type => "MENU",
+        name => "ntp",
+        parent_menu => "root_show",
+        uniq_name => "root_show_ntp",
+        help_string => "Show NTP status",
+        cmd_attribute => "CMD_ARRAYOS|CMD_SPROXY|CMD_NORMAL",
+        user_level => "CLI_LEVEL_ENABLE",
+    },
+    {
+        obj_type => "ITEM",
+        name => "status",
+        menu => "root_show_ntp",
+        help_string => "Display NTP servers states and settings",
+        cmd_attribute => "CMD_ARRAYOS|CMD_SPROXY|CMD_NORMAL",
+        user_level => "CLI_LEVEL_ENABLE",
+        function_name => "ui_showntp",
+        function_args => [],
+    },
+    {
+        obj_type => "ITEM",
+        name => "keys",
+        menu => "root_show_ntp",
+        help_string => "Display NTP authentication keys",
+        cmd_attribute => "CMD_ARRAYOS|CMD_SPROXY|CMD_NORMAL",
+        user_level => "CLI_LEVEL_ENABLE",
+        function_name => "ui_showntp_auth_keys",
+        function_args => [],
+    },
+    {
+        obj_type => "ITEM",
+        name => "ntp",
+        menu => "root_clear",
+        help_string => "Clear NTP configuration",
+        cmd_attribute => "CMD_ARRAYOS|CMD_SPROXY|CMD_NORMAL|CMD_GLOBAL",
+        user_level => "CLI_LEVEL_CONFIG",
+        function_name => "ui_clearntp",
+        function_args => [],
+    },
 	{
 		obj_type => "MENU",
 		name => "write",
Index: /branches/rel_apv_10_7/usr/click/tools/ca_crontab_ntp.sh
===================================================================
--- /branches/rel_apv_10_7/usr/click/tools/ca_crontab_ntp.sh	(revision 38800)
+++ /branches/rel_apv_10_7/usr/click/tools/ca_crontab_ntp.sh	(working copy)
@@ -3,13 +3,13 @@
 
 execute_cli_cmd()
 {
-	/ca/bin/backend -c "ntp crontab"`echo -e "\0374"` | sed "s/`echo -e "\0374"`//g" >> $CRON_LOG
+    /ca/bin/backend -c "ntp crontab"`echo -e "\0374"` | sed "s/`echo -e "\0374"`//g" >> $CRON_LOG
 }
 
-CRONTAB_ENABLE=$(/ca/bin/u_sysctl net.inet.clicktcp.ntpdate_enable | cut -d ":" -f 2)
+CRONTAB_ENABLE=$(/ca/bin/u_sysctl net.inet.clicktcp.ntp_enable | cut -d ":" -f 2)
 if [ $CRONTAB_ENABLE -eq 1 ]
 then
-        execute_cli_cmd 
+    execute_cli_cmd 
 fi 
 
 
Index: /branches/rel_apv_10_7/usr/src/sys/click/netinet/click_eroute.c
===================================================================
--- /branches/rel_apv_10_7/usr/src/sys/click/netinet/click_eroute.c	(revision 38800)
+++ /branches/rel_apv_10_7/usr/src/sys/click/netinet/click_eroute.c	(working copy)
@@ -554,13 +554,9 @@
 SYSCTL_INT(_net_inet_clicktcp, OID_AUTO, crontab_enable, CTLFLAG_RW,
 	&crontab_enable, 0, "Enable crontab");
 
-int ntpdate_enable=0;
-SYSCTL_INT(_net_inet_clicktcp, OID_AUTO, ntpdate_enable, CTLFLAG_RW,
-        &ntpdate_enable, 0, "Enable ntp");
-
-int ntp_type=0;
-SYSCTL_INT(_net_inet_clicktcp, OID_AUTO, ntp_type, CTLFLAG_RW,
-        &ntp_type, 0, "ntp type");
+int ntp_enable=0;
+SYSCTL_INT(_net_inet_clicktcp, OID_AUTO, ntp_enable, CTLFLAG_RW,
+			&ntp_enable, 0, "Enable ntp");
 
 static int ev_arith_del_id_from_hlist(struct ev_gtable *gt, int isipv6, int index);
 static int ev_arith_del_on_parts(struct ev_gtable *gt, int isipv6, int index);
