File tree Expand file tree Collapse file tree 2 files changed +46
-14
lines changed Expand file tree Collapse file tree 2 files changed +46
-14
lines changed Original file line number Diff line number Diff line change @@ -134,16 +134,33 @@ let refresh_localhost_info ~__context info =
134
134
) else
135
135
Db.Host. remove_from_other_config ~__context ~self: host
136
136
~key: Xapi_globs. host_no_local_storage ;
137
- let script_output =
138
- Helpers. call_script ! Xapi_globs. firewall_port_config_script [" check" ; " 80" ]
137
+ let update_https_only =
138
+ match ! Xapi_globs. firewall_backend with
139
+ | "firewalld" ->
140
+ let enabled =
141
+ Firewall. is_firewall_service_enabled ~service: Firewall. Xapi_insecure
142
+ in
143
+ Db.Host. set_https_only ~__context ~self: host ~value: (not enabled)
144
+ | "iptables" -> (
145
+ let script_output =
146
+ Helpers. call_script
147
+ ! Xapi_globs. firewall_port_config_script
148
+ [" check" ; " 80" ]
149
+ in
150
+ try
151
+ let network_state =
152
+ Scanf. sscanf script_output " Port 80 open: %B" Fun. id
153
+ in
154
+ Db.Host. set_https_only ~__context ~self: host ~value: network_state
155
+ with _ ->
156
+ Helpers. internal_error
157
+ " unexpected output from /etc/xapi.d/plugins/firewall-port: %s"
158
+ script_output
159
+ )
160
+ | backend ->
161
+ warn " Unknown firewall backend %s, ignore it." backend
139
162
in
140
- try
141
- let network_state = Scanf. sscanf script_output " Port 80 open: %B" Fun. id in
142
- Db.Host. set_https_only ~__context ~self: host ~value: network_state
143
- with _ ->
144
- Helpers. internal_error
145
- " unexpected output from /etc/xapi.d/plugins/firewall-port: %s"
146
- script_output
163
+ update_https_only
147
164
(* ************** update database tools ******************)
148
165
149
166
(* * Record host memory properties in database *)
Original file line number Diff line number Diff line change @@ -3116,13 +3116,28 @@ let cc_prep () =
3116
3116
true
3117
3117
3118
3118
let set_https_only ~__context ~self ~value =
3119
- let state = match value with true -> " close" | false -> " open" in
3120
3119
match cc_prep () with
3121
3120
| false ->
3122
- ignore
3123
- @@ Helpers. call_script
3124
- ! Xapi_globs. firewall_port_config_script
3125
- [state; " 80" ] ;
3121
+ ( match ! Xapi_globs. firewall_backend with
3122
+ | "firewalld" ->
3123
+ let status =
3124
+ match value with
3125
+ | true ->
3126
+ Firewall. Disabled
3127
+ | false ->
3128
+ Firewall. Enabled
3129
+ in
3130
+ Firewall. update_firewall_status ~service: Firewall. Xapi_insecure
3131
+ ~status
3132
+ | "iptables" ->
3133
+ let state = match value with true -> " close" | false -> " open" in
3134
+ ignore
3135
+ @@ Helpers. call_script
3136
+ ! Xapi_globs. firewall_port_config_script
3137
+ [state; " 80" ]
3138
+ | backend ->
3139
+ warn " Unknown firewall backend %s, ignore it." backend
3140
+ ) ;
3126
3141
Db.Host. set_https_only ~__context ~self ~value
3127
3142
| true when value = Db.Host. get_https_only ~__context ~self ->
3128
3143
(* the new value is the same as the old value *)
You can’t perform that action at this time.
0 commit comments