[augeas-devel] augeas: master - Ntp: fixes to make the default Fedora config work
David Lutterkort
lutter at fedoraproject.org
Wed Apr 8 00:22:19 UTC 2009
Gitweb: http://git.fedorahosted.org/git/augeas.git?p=augeas.git;a=commitdiff;h=ce876a53d2394cec611fcbdf2f0576b52b23f526
Commit: ce876a53d2394cec611fcbdf2f0576b52b23f526
Parent: 0f07863af8f2eddca215c4595bd27c9437841c0d
Author: David Lutterkort <lutter at redhat.com>
AuthorDate: Tue Apr 7 17:01:50 2009 -0700
Committer: David Lutterkort <lutter at redhat.com>
CommitterDate: Tue Apr 7 17:01:50 2009 -0700
Ntp: fixes to make the default Fedora config work
Now enough of ntp.conf is understood so that the config from Fedora 10 with
all directives uncommented can be processed.
---
lenses/ntp.aug | 32 ++++++++++++++++++++--------
lenses/tests/test_ntp.aug | 19 +++++++++++++++++
tests/root/etc/ntp.conf | 50 +++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 92 insertions(+), 9 deletions(-)
diff --git a/lenses/ntp.aug b/lenses/ntp.aug
index 08641fb..d1b2615 100644
--- a/lenses/ntp.aug
+++ b/lenses/ntp.aug
@@ -23,13 +23,19 @@ module Ntp =
(* Define generic record *)
- let record (kw:string) (value:lens) = [ key kw . sep_spc . store word . value . eol ]
+ let record (kw:regexp) (value:lens) =
+ [ key kw . sep_spc . store word . value . eol ]
- (* Define a server record *)
- let server_opt = [ sep_spc . key "version" . sep_spc . store word ]
- | [ sep_spc . key "dynamic" ]
- let server_record = record "server" server_opt?
+ (* Define a command record; see confopt.html#cfg in the ntp docs *)
+ let command_record =
+ let opt = [ sep_spc . key /version|key/ . sep_spc . store word ]
+ | [ sep_spc . key "dynamic" ] in
+ let cmd = /server|peer|broadcast|manycastclient/
+ | /multicastclient|manycastserver/ in
+ record cmd opt*
+ let broadcastclient =
+ [ key "broadcastclient" . [ sep_spc . key "novolley" ]? . eol ]
(* Define a fudge record *)
let fudge_opt_re = "refid" | "stratum"
@@ -74,14 +80,22 @@ module Ntp =
let filegen_record = [ label "filegen" . filegen . filegen_opts* . eol ]
- (* Includefile/keys *)
- let files = [ key /includefile|keys/ . sep_spc . store word . eol ]
+ (* Authentication commands, see authopt.html#cmd; incomplete *)
+ let auth_command =
+ [ key /controlkey|keys|keysdir|requestkey/ .
+ sep_spc . store word . eol ]
+ | [ key /autokey|revoke/ . [sep_spc . store word]? . eol ]
+ | [ key /trustedkey/ . [ sep_spc . label "key" . store word ]+ . eol ]
+
+ (* Includefile *)
+ let files = [ key /includefile/ . sep_spc . store word . eol ]
(* Define lens *)
- let lns = ( comment | empty | server_record | fudge_record
+ let lns = ( comment | empty | command_record | fudge_record
| restrict_record | simple_settings | statistics_record
- | filegen_record | files)*
+ | filegen_record | files | broadcastclient
+ | auth_command )*
let filter = (incl "/etc/ntp.conf")
. Util.stdexcl
diff --git a/lenses/tests/test_ntp.aug b/lenses/tests/test_ntp.aug
index 257bb2a..f56a924 100644
--- a/lenses/tests/test_ntp.aug
+++ b/lenses/tests/test_ntp.aug
@@ -115,3 +115,22 @@ filegen clockstats file clockstats type day enable nolink
test Ntp.lns get "fudge 127.127.1.0 stratum 10\n" =
{ "fudge" = "127.127.1.0" { "stratum" = "10" } }
+
+ test Ntp.lns get "broadcast 192.168.1.255 key 42\n" =
+ { "broadcast" = "192.168.1.255" { "key" = "42" } }
+
+
+ test Ntp.lns get "multicastclient 224.0.1.1\n" =
+ { "multicastclient" = "224.0.1.1" }
+
+ test Ntp.lns put "broadcastclient\tnovolley # broadcast\n"
+ after rm "/*/novolley" = "broadcastclient # broadcast\n"
+
+ test Ntp.auth_command get "trustedkey 4 8 42\n" =
+ { "trustedkey"
+ { "key" = "4" }
+ { "key" = "8" }
+ { "key" = "42" } }
+
+ test Ntp.auth_command get "trustedkey 42\n" =
+ { "trustedkey" { "key" = "42" } }
diff --git a/tests/root/etc/ntp.conf b/tests/root/etc/ntp.conf
new file mode 100644
index 0000000..8a375db
--- /dev/null
+++ b/tests/root/etc/ntp.conf
@@ -0,0 +1,50 @@
+# Permit time synchronization with our time source, but do not
+# permit the source to query or modify the service on this system.
+restrict default kod nomodify notrap nopeer noquery
+restrict -6 default kod nomodify notrap nopeer noquery
+
+# Permit all access over the loopback interface. This could
+# be tightened as well, but to do so would effect some of
+# the administrative functions.
+restrict 127.0.0.1
+restrict -6 ::1
+
+# Hosts on local network are less restricted.
+restrict 192.168.1.0 mask 255.255.255.0 nomodify notrap
+
+# Use public servers from the pool.ntp.org project.
+# Please consider joining the pool (http://www.pool.ntp.org/join.html).
+server 0.centos.pool.ntp.org
+server 1.centos.pool.ntp.org
+server 2.centos.pool.ntp.org
+
+broadcast 192.168.1.255 key 42 # broadcast server
+broadcastclient # broadcast client
+broadcast 224.0.1.1 key 42 # multicast server
+multicastclient 224.0.1.1 # multicast client
+manycastserver 239.255.254.254 # manycast server
+manycastclient 239.255.254.254 key 42 # manycast client
+
+# Undisciplined Local Clock. This is a fake driver intended for backup
+# and when no outside source of synchronized time is available.
+server 127.127.1.0 # local clock
+fudge 127.127.1.0 stratum 10
+
+# Drift file. Put this in a directory which the daemon can write to.
+# No symbolic links allowed, either, since the daemon updates the file
+# by creating a temporary in the same directory and then rename()'ing
+# it to the file.
+driftfile /var/lib/ntp/drift
+
+# Key file containing the keys and key identifiers used when operating
+# with symmetric key cryptography.
+keys /etc/ntp/keys
+
+# Specify the key identifiers which are trusted.
+trustedkey 4 8 42
+
+# Specify the key identifier to use with the ntpdc utility.
+requestkey 8
+
+# Specify the key identifier to use with the ntpq utility.
+controlkey 8
More information about the augeas-devel
mailing list