Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
O
OpnSense
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kulya
OpnSense
Commits
0d70b4a9
Commit
0d70b4a9
authored
Feb 25, 2016
by
Franco Fichtner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ntp: disable when no servers are set; closes #332
This will make a few good people very happy. :)
parent
334e4936
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
34 additions
and
21 deletions
+34
-21
services.inc
src/etc/inc/services.inc
+9
-7
system.inc
src/etc/inc/system.inc
+11
-6
services_ntpd.php
src/www/services_ntpd.php
+3
-2
system_general.php
src/www/system_general.php
+11
-6
No files found.
src/etc/inc/services.inc
View file @
0d70b4a9
...
@@ -2543,6 +2543,7 @@ function services_get()
...
@@ -2543,6 +2543,7 @@ function services_get()
$services
[]
=
$pconfig
;
$services
[]
=
$pconfig
;
}
}
if
(
isset
(
$config
[
'system'
][
'timeservers'
]))
{
$pconfig
=
array
();
$pconfig
=
array
();
$pconfig
[
'name'
]
=
"ntpd"
;
$pconfig
[
'name'
]
=
"ntpd"
;
$pconfig
[
'description'
]
=
gettext
(
"NTP clock sync"
);
$pconfig
[
'description'
]
=
gettext
(
"NTP clock sync"
);
...
@@ -2550,6 +2551,7 @@ function services_get()
...
@@ -2550,6 +2551,7 @@ function services_get()
$pconfig
[
'php'
][
'start'
]
=
array
(
'system_ntp_configure'
);
$pconfig
[
'php'
][
'start'
]
=
array
(
'system_ntp_configure'
);
$pconfig
[
'pidfile'
]
=
'/var/run/ntpd.pid'
;
$pconfig
[
'pidfile'
]
=
'/var/run/ntpd.pid'
;
$services
[]
=
$pconfig
;
$services
[]
=
$pconfig
;
}
$iflist
=
array
();
$iflist
=
array
();
$ifdescrs
=
get_configured_interface_list
();
$ifdescrs
=
get_configured_interface_list
();
...
...
src/etc/inc/system.inc
View file @
0d70b4a9
...
@@ -1474,6 +1474,17 @@ function system_ntp_configure($start_ntpd = true)
...
@@ -1474,6 +1474,17 @@ function system_ntp_configure($start_ntpd = true)
{
{
global
$config
;
global
$config
;
/* if ntpd is running, kill it when restart is not delayed */
while
(
$start_ntpd
&&
isvalidpid
(
'/var/run/ntpd.pid'
))
{
killbypid
(
'/var/run/ntpd.pid'
);
usleep
(
200
*
1000
);
}
if
(
!
isset
(
$config
[
'system'
][
'timeservers'
]))
{
/* use this field for on/off toggle */
return
;
}
$driftfile
=
'/var/db/ntpd.drift'
;
$driftfile
=
'/var/db/ntpd.drift'
;
$statsdir
=
'/var/log/ntp'
;
$statsdir
=
'/var/log/ntp'
;
$gps_device
=
'/dev/gps0'
;
$gps_device
=
'/dev/gps0'
;
...
@@ -1719,12 +1730,6 @@ function system_ntp_configure($start_ntpd = true)
...
@@ -1719,12 +1730,6 @@ function system_ntp_configure($start_ntpd = true)
return
;
return
;
}
}
/* if ntpd is running, kill it */
while
(
isvalidpid
(
'/var/run/ntpd.pid'
))
{
killbypid
(
'/var/run/ntpd.pid'
);
usleep
(
200
*
1000
);
}
/* if /var/empty does not exist, create it */
/* if /var/empty does not exist, create it */
@
mkdir
(
'/var/empty'
,
0775
,
true
);
@
mkdir
(
'/var/empty'
,
0775
,
true
);
...
...
src/www/services_ntpd.php
View file @
0d70b4a9
...
@@ -63,9 +63,10 @@ if ($_POST) {
...
@@ -63,9 +63,10 @@ if ($_POST) {
if
(
!
empty
(
$_POST
[
"servselect
{
$i
}
"
]))
$config
[
'ntpd'
][
'noselect'
]
.=
"
{
$tserver
}
"
;
if
(
!
empty
(
$_POST
[
"servselect
{
$i
}
"
]))
$config
[
'ntpd'
][
'noselect'
]
.=
"
{
$tserver
}
"
;
}
}
}
}
if
(
trim
(
$timeservers
)
==
""
)
$timeservers
=
"pool.ntp.org"
;
$config
[
'system'
][
'timeservers'
]
=
trim
(
$timeservers
);
$config
[
'system'
][
'timeservers'
]
=
trim
(
$timeservers
);
if
(
empty
(
$config
[
'system'
][
'timeservers'
]))
{
unset
(
$config
[
'system'
][
'timeservers'
]);
}
if
(
!
empty
(
$_POST
[
'ntporphan'
])
&&
(
$_POST
[
'ntporphan'
]
<
17
)
&&
(
$_POST
[
'ntporphan'
]
!=
'12'
))
if
(
!
empty
(
$_POST
[
'ntporphan'
])
&&
(
$_POST
[
'ntporphan'
]
<
17
)
&&
(
$_POST
[
'ntporphan'
]
!=
'12'
))
$config
[
'ntpd'
][
'orphan'
]
=
$_POST
[
'ntporphan'
];
$config
[
'ntpd'
][
'orphan'
]
=
$_POST
[
'ntporphan'
];
...
...
src/www/system_general.php
View file @
0d70b4a9
...
@@ -159,17 +159,22 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') {
...
@@ -159,17 +159,22 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') {
# it's easy to have a little too much whitespace in the field, clean it up for the user before processing.
# it's easy to have a little too much whitespace in the field, clean it up for the user before processing.
$pconfig
[
'timeservers'
]
=
preg_replace
(
'/[[:blank:]]+/'
,
' '
,
$pconfig
[
'timeservers'
]);
$pconfig
[
'timeservers'
]
=
preg_replace
(
'/[[:blank:]]+/'
,
' '
,
$pconfig
[
'timeservers'
]);
$pconfig
[
'timeservers'
]
=
trim
(
$pconfig
[
'timeservers'
]);
$pconfig
[
'timeservers'
]
=
trim
(
$pconfig
[
'timeservers'
]);
if
(
!
empty
(
$pconfig
[
'timeservers'
]))
{
foreach
(
explode
(
' '
,
$pconfig
[
'timeservers'
])
as
$ts
)
{
foreach
(
explode
(
' '
,
$pconfig
[
'timeservers'
])
as
$ts
)
{
if
(
!
is_domain
(
$ts
))
{
if
(
!
is_domain
(
$ts
))
{
$input_errors
[]
=
gettext
(
"A NTP Time Server name may only contain the characters a-z, 0-9, '-' and '.'."
);
$input_errors
[]
=
gettext
(
"A NTP Time Server name may only contain the characters a-z, 0-9, '-' and '.'."
);
}
}
}
}
}
if
(
count
(
$input_errors
)
==
0
)
{
if
(
count
(
$input_errors
)
==
0
)
{
$config
[
'system'
][
'hostname'
]
=
$pconfig
[
'hostname'
];
$config
[
'system'
][
'hostname'
]
=
$pconfig
[
'hostname'
];
$config
[
'system'
][
'domain'
]
=
$pconfig
[
'domain'
];
$config
[
'system'
][
'domain'
]
=
$pconfig
[
'domain'
];
$config
[
'system'
][
'timezone'
]
=
$pconfig
[
'timezone'
];
$config
[
'system'
][
'timezone'
]
=
$pconfig
[
'timezone'
];
$config
[
'system'
][
'timeservers'
]
=
strtolower
(
$pconfig
[
'timeservers'
]);
$config
[
'system'
][
'timeservers'
]
=
strtolower
(
$pconfig
[
'timeservers'
]);
if
(
empty
(
$config
[
'system'
][
'timeservers'
]))
{
unset
(
$config
[
'system'
][
'timeservers'
]);
}
$config
[
'theme'
]
=
$pconfig
[
'theme'
];
$config
[
'theme'
]
=
$pconfig
[
'theme'
];
if
(
!
empty
(
$pconfig
[
'language'
])
&&
$pconfig
[
'language'
]
!=
$config
[
'system'
][
'language'
])
{
if
(
!
empty
(
$pconfig
[
'language'
])
&&
$pconfig
[
'language'
]
!=
$config
[
'system'
][
'language'
])
{
...
@@ -448,9 +453,9 @@ include("head.inc");
...
@@ -448,9 +453,9 @@ include("head.inc");
<td
width=
"78%"
class=
"vtable"
>
<td
width=
"78%"
class=
"vtable"
>
<input
name=
"timeservers"
type=
"text"
class=
"formfld unknown"
value=
"
<?=
$pconfig
[
'timeservers'
];
?>
"
/>
<input
name=
"timeservers"
type=
"text"
class=
"formfld unknown"
value=
"
<?=
$pconfig
[
'timeservers'
];
?>
"
/>
<div
class=
"hidden"
for=
"help_for_ntp"
>
<div
class=
"hidden"
for=
"help_for_ntp"
>
<?=
gettext
(
"Use a space to separate multiple hosts
(only one
"
.
<?=
gettext
(
"Use a space to separate multiple hosts
if
"
.
"
required). Remember to set up at least one DNS server
"
.
"
needed or leave blank to disable the network time service.
"
.
"
if you enter a host name here!
"
);
?>
"
Remember to set up DNS if you enter host names here.
"
);
?>
</div>
</div>
</td>
</td>
</tr>
</tr>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment