Hello everybody,

please find attached a patch to simplify the ntpd plugin peer
configuration code; this patch is necessary to make the plugin
compatibile with busybox implementation of ntpd, which does not 
support a configuration file.

Best regards,
Davide Cavalca
>From e392831631f55ce7a7ff2898b26ff6d81c4c0e41 Mon Sep 17 00:00:00 2001
From: Davide Cavalca <dav...@geexbox.org>
Date: Tue, 5 Oct 2010 11:24:04 +0200
Subject: [PATCH] ntpd: simplify peer configuration

---
 plugins/ntpd.c |   36 ++----------------------------------
 1 files changed, 2 insertions(+), 34 deletions(-)

diff --git a/plugins/ntpd.c b/plugins/ntpd.c
index 731fa46..3d9a572 100644
--- a/plugins/ntpd.c
+++ b/plugins/ntpd.c
@@ -120,23 +120,6 @@ static void ntpdate_died(struct connman_task *task, void *user_data)
 	connman_task_destroy(ntpdate->task);
 }
 
-static void ntpdate_add_peer(struct ntpdate_task *ntpdate, char *peer)
-{
-	FILE *conf_file;
-
-	DBG("%s", peer);
-
-	conf_file = fdopen(ntpdate->conf_fd, "a+");
-	if (conf_file == NULL) {
-		connman_error("fdopen failed");
-		return;
-	}
-
-	fprintf(conf_file, "server %s iburst\n", peer);
-
-	fclose(conf_file);
-}
-
 static int ntpdate(void)
 {
 	int err;
@@ -161,33 +144,18 @@ static int ntpdate(void)
 	connman_task_add_argument(ntpdate->task, "-g", NULL);
 	connman_task_add_argument(ntpdate->task, "-q", NULL);
 
-	/* The servers are added through a temp configuration file */
-	ntpdate->conf_fd = g_file_open_tmp("connman.ntp.conf_XXXXXX",
-						&ntpdate->conf_path, &g_err);
-	if  (ntpdate->conf_fd == -1) {
-		err = g_err->code;
-		g_free(g_err);
-		goto error_open;
-	}
-
-	connman_task_add_argument(ntpdate->task, "-c", ntpdate->conf_path);
-
-	DBG("conf path %s", ntpdate->conf_path);
-
 	for (list = pending_peers; list; list = list->next) {
 		peer = list->data;
 
-		ntpdate_add_peer(ntpdate, peer->server);
+		connman_task_add_argument(ntpdate->task, "-p", peer->server);
 	}
 
 	for (list = peers; list; list = list->next) {
 		peer = list->data;
 
-		ntpdate_add_peer(ntpdate, peer->server);
+		connman_task_add_argument(ntpdate->task, "-p", peer->server);
 	}
 
-	close(ntpdate->conf_fd);
-
 	return connman_task_run(ntpdate->task, ntpdate_died, ntpdate,
 						NULL, NULL, NULL);
 error_open:
-- 
1.7.1

_______________________________________________
connman mailing list
connman@connman.net
http://lists.connman.net/listinfo/connman

Reply via email to