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
d03b53b3
Commit
d03b53b3
authored
Feb 21, 2016
by
Franco Fichtner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
services: extent for openvpn's special arguments
parent
71bd852f
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
44 additions
and
62 deletions
+44
-62
openvpn.inc
src/etc/inc/openvpn.inc
+25
-31
services.inc
src/etc/inc/services.inc
+3
-0
status_services.php
src/www/status_services.php
+16
-31
No files found.
src/etc/inc/openvpn.inc
View file @
d03b53b3
...
@@ -807,6 +807,31 @@ function openvpn_reconfigure($mode, $settings)
...
@@ -807,6 +807,31 @@ function openvpn_reconfigure($mode, $settings)
@
chmod
(
"/var/etc/openvpn/
{
$mode_id
}
.conf"
,
0600
);
@
chmod
(
"/var/etc/openvpn/
{
$mode_id
}
.conf"
,
0600
);
}
}
function
openvpn_restart_by_vpnid
(
$mode
,
$vpnid
)
{
global
$config
;
$found
=
null
;
if
(
isset
(
$config
[
'openvpn'
][
"openvpn-
$mode
"
]))
{
foreach
(
$config
[
'openvpn'
][
"openvpn-
$mode
"
]
as
$settings
)
{
if
(
isset
(
$settings
[
'disable'
]))
{
continue
;
}
if
(
$vpnid
!=
0
&&
$vpnid
==
$settings
[
'vpnid'
])
{
$found
=
$settings
;
break
;
}
}
}
if
(
$found
==
null
)
{
return
;
}
openvpn_restart
(
$mode
,
$found
);
}
function
openvpn_restart
(
$mode
,
$settings
)
function
openvpn_restart
(
$mode
,
$settings
)
{
{
global
$config
;
global
$config
;
...
@@ -1362,37 +1387,6 @@ function openvpn_gen_route_ipv6($network, $iroute = false)
...
@@ -1362,37 +1387,6 @@ function openvpn_gen_route_ipv6($network, $iroute = false)
return
"
{
$i
}
route-ipv6 ${ipv6}/${prefix}"
;
return
"
{
$i
}
route-ipv6 ${ipv6}/${prefix}"
;
}
}
function
openvpn_get_settings
(
$mode
,
$vpnid
)
{
global
$config
;
if
(
is_array
(
$config
[
'openvpn'
][
'openvpn-server'
]))
{
foreach
(
$config
[
'openvpn'
][
'openvpn-server'
]
as
$settings
)
{
if
(
isset
(
$settings
[
'disable'
]))
{
continue
;
}
if
(
$vpnid
!=
0
&&
$vpnid
==
$settings
[
'vpnid'
])
{
return
$settings
;
}
}
}
if
(
is_array
(
$config
[
'openvpn'
][
'openvpn-client'
]))
{
foreach
(
$config
[
'openvpn'
][
'openvpn-client'
]
as
$settings
)
{
if
(
isset
(
$settings
[
'disable'
]))
{
continue
;
}
if
(
$vpnid
!=
0
&&
$vpnid
==
$settings
[
'vpnid'
])
{
return
$settings
;
}
}
}
return
array
();
}
/**
/**
* Retrieve a list of remote access servers, indexed by vpnid
* Retrieve a list of remote access servers, indexed by vpnid
*/
*/
...
...
src/etc/inc/services.inc
View file @
d03b53b3
...
@@ -2654,6 +2654,9 @@ function services_get()
...
@@ -2654,6 +2654,9 @@ function services_get()
$pconfig
[
'id'
]
=
$id
;
$pconfig
[
'id'
]
=
$id
;
$pconfig
[
'vpnid'
]
=
$setting
[
'vpnid'
];
$pconfig
[
'vpnid'
]
=
$setting
[
'vpnid'
];
$pconfig
[
'description'
]
=
gettext
(
"OpenVPN"
)
.
" "
.
$mode
.
": "
.
htmlspecialchars
(
$setting
[
'description'
]);
$pconfig
[
'description'
]
=
gettext
(
"OpenVPN"
)
.
" "
.
$mode
.
": "
.
htmlspecialchars
(
$setting
[
'description'
]);
$pconfig
[
'php'
][
'restart'
]
=
array
(
'openvpn_restart_by_vpnid'
);
$pconfig
[
'php'
][
'start'
]
=
array
(
'openvpn_restart_by_vpnid'
);
$pconfig
[
'php'
][
'args'
]
=
array
(
'mode'
,
'vpnid'
);
$pconfig
[
'pidfile'
]
=
"/var/run/openvpn_
{
$mode
}{
$setting
[
'vpnid'
]
}
.pid"
;
$pconfig
[
'pidfile'
]
=
"/var/run/openvpn_
{
$mode
}{
$setting
[
'vpnid'
]
}
.pid"
;
$services
[]
=
$pconfig
;
$services
[]
=
$pconfig
;
}
}
...
...
src/www/status_services.php
View file @
d03b53b3
...
@@ -40,12 +40,6 @@ require_once("vpn.inc");
...
@@ -40,12 +40,6 @@ require_once("vpn.inc");
require_once
(
"interfaces.inc"
);
require_once
(
"interfaces.inc"
);
require_once
(
"rrd.inc"
);
require_once
(
"rrd.inc"
);
function
openvpn_restart_by_vpnid
(
$mode
,
$vpnid
)
{
$settings
=
openvpn_get_settings
(
$mode
,
$vpnid
);
openvpn_restart
(
$mode
,
$settings
);
}
if
(
!
empty
(
$_GET
[
'service'
]))
{
if
(
!
empty
(
$_GET
[
'service'
]))
{
$service_name
=
$_GET
[
'service'
];
$service_name
=
$_GET
[
'service'
];
switch
(
$_GET
[
'mode'
])
{
switch
(
$_GET
[
'mode'
])
{
...
@@ -73,20 +67,11 @@ function service_control_start($name, $extras)
...
@@ -73,20 +67,11 @@ function service_control_start($name, $extras)
{
{
$msg
=
sprintf
(
gettext
(
'%s has been started.'
),
htmlspecialchars
(
$name
));
$msg
=
sprintf
(
gettext
(
'%s has been started.'
),
htmlspecialchars
(
$name
));
/* XXX openvpn is handled special at the moment */
if
(
$name
==
'openvpn'
)
{
if
(
$name
==
'openvpn'
)
{
$vpnmode
=
isset
(
$extras
[
'vpnmode'
])
?
htmlspecialchars
(
$extras
[
'vpnmode'
])
:
htmlspecialchars
(
$extras
[
'mode'
]);
$filter
[
'vpnid'
]
=
$extras
[
'id'
];
if
((
$vpnmode
==
"server"
)
||
(
$vpnmode
==
"client"
))
{
$id
=
isset
(
$extras
[
'vpnid'
])
?
htmlspecialchars
(
$extras
[
'vpnid'
])
:
htmlspecialchars
(
$extras
[
'id'
]);
$configfile
=
"/var/etc/openvpn/
{
$vpnmode
}{
$id
}
.conf"
;
if
(
file_exists
(
$configfile
))
{
openvpn_restart_by_vpnid
(
$vpnmode
,
$id
);
}
}
return
$msg
;
}
}
$service
=
find_service_by_name
(
$name
);
$service
=
find_service_by_name
(
$name
,
$filter
);
if
(
!
isset
(
$service
[
'name'
]))
{
if
(
!
isset
(
$service
[
'name'
]))
{
return
sprintf
(
gettext
(
"Could not start unknown service `%s'"
),
htmlspecialchars
(
$name
));
return
sprintf
(
gettext
(
"Could not start unknown service `%s'"
),
htmlspecialchars
(
$name
));
}
}
...
@@ -97,7 +82,13 @@ function service_control_start($name, $extras)
...
@@ -97,7 +82,13 @@ function service_control_start($name, $extras)
}
}
}
elseif
(
isset
(
$service
[
'php'
][
'start'
]))
{
}
elseif
(
isset
(
$service
[
'php'
][
'start'
]))
{
foreach
(
$service
[
'php'
][
'start'
]
as
$cmd
)
{
foreach
(
$service
[
'php'
][
'start'
]
as
$cmd
)
{
$cmd
();
$params
=
array
();
if
(
isset
(
$service
[
'php'
][
'args'
]))
{
foreach
(
$service
[
'php'
][
'args'
]
as
$param
)
{
$params
[]
=
$service
[
$param
];
}
}
call_user_func_array
(
$cmd
,
$params
);
}
}
}
elseif
(
isset
(
$service
[
'mwexec'
][
'start'
]))
{
}
elseif
(
isset
(
$service
[
'mwexec'
][
'start'
]))
{
foreach
(
$service
[
'mwexec'
][
'start'
]
as
$cmd
)
{
foreach
(
$service
[
'mwexec'
][
'start'
]
as
$cmd
)
{
...
@@ -116,7 +107,6 @@ function service_control_stop($name, $extras)
...
@@ -116,7 +107,6 @@ function service_control_stop($name, $extras)
$filter
=
array
();
$filter
=
array
();
if
(
$name
==
'openvpn'
)
{
if
(
$name
==
'openvpn'
)
{
$filter
[
'mode'
]
=
$extras
[
'vpnmode'
];
/* XXX I think mode is spurious */
$filter
[
'vpnid'
]
=
$extras
[
'id'
];
$filter
[
'vpnid'
]
=
$extras
[
'id'
];
}
}
...
@@ -147,7 +137,6 @@ function service_control_stop($name, $extras)
...
@@ -147,7 +137,6 @@ function service_control_stop($name, $extras)
return
$msg
;
return
$msg
;
}
}
function
service_control_restart
(
$name
,
$extras
)
function
service_control_restart
(
$name
,
$extras
)
{
{
$msg
=
sprintf
(
gettext
(
"%s has been restarted."
),
htmlspecialchars
(
$name
));
$msg
=
sprintf
(
gettext
(
"%s has been restarted."
),
htmlspecialchars
(
$name
));
...
@@ -158,16 +147,6 @@ function service_control_restart($name, $extras)
...
@@ -158,16 +147,6 @@ function service_control_restart($name, $extras)
killbypid
(
"/var/run/apinger.pid"
);
killbypid
(
"/var/run/apinger.pid"
);
setup_gateways_monitor
();
setup_gateways_monitor
();
return
$msg
;
return
$msg
;
case
'openvpn'
:
$vpnmode
=
htmlspecialchars
(
$extras
[
'vpnmode'
]);
if
(
$vpnmode
==
"server"
||
$vpnmode
==
"client"
)
{
$id
=
htmlspecialchars
(
$extras
[
'id'
]);
$configfile
=
"/var/etc/openvpn/
{
$vpnmode
}{
$id
}
.conf"
;
if
(
file_exists
(
$configfile
))
{
openvpn_restart_by_vpnid
(
$vpnmode
,
$id
);
}
}
return
$msg
;
case
'relayd'
:
case
'relayd'
:
relayd_configure
(
true
);
relayd_configure
(
true
);
filter_configure
();
filter_configure
();
...
@@ -187,7 +166,13 @@ function service_control_restart($name, $extras)
...
@@ -187,7 +166,13 @@ function service_control_restart($name, $extras)
}
}
}
elseif
(
isset
(
$service
[
'php'
][
'restart'
]))
{
}
elseif
(
isset
(
$service
[
'php'
][
'restart'
]))
{
foreach
(
$service
[
'php'
][
'restart'
]
as
$cmd
)
{
foreach
(
$service
[
'php'
][
'restart'
]
as
$cmd
)
{
$cmd
();
$params
=
array
();
if
(
isset
(
$service
[
'php'
][
'args'
]))
{
foreach
(
$service
[
'php'
][
'args'
]
as
$param
)
{
$params
[]
=
$service
[
$param
];
}
}
call_user_func_array
(
$cmd
,
$params
);
}
}
}
elseif
(
isset
(
$service
[
'mwexec'
][
'restart'
]))
{
}
elseif
(
isset
(
$service
[
'mwexec'
][
'restart'
]))
{
foreach
(
$service
[
'mwexec'
][
'restart'
]
as
$cmd
)
{
foreach
(
$service
[
'mwexec'
][
'restart'
]
as
$cmd
)
{
...
...
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