Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NAS-128845 / 24.10 / Do not render all IPv4 addresses in Web UI URLs list if :: is in the listen address list, but 0.0.0.0 is not #14154

Merged
merged 3 commits into from
Aug 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 1 addition & 11 deletions src/middlewared/middlewared/plugins/network_/global_config.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
import ipaddress
import psutil
import contextlib
import signal

import middlewared.sqlalchemy as sa
from middlewared.service import ConfigService, private
Expand Down Expand Up @@ -345,14 +342,7 @@ async def do_update(self, data):
except Exception:
self.logger.warning('Failed to generate resolv.conf on standby storage controller', exc_info=True)

def reload_cli():
for process in psutil.process_iter(['pid', 'cmdline']):
cmdline = process.cmdline()
if len(cmdline) >= 2 and cmdline[1] == '/usr/bin/cli':
with contextlib.suppress(Exception):
process.send_signal(signal.SIGUSR1)

await self.middleware.run_in_thread(reload_cli)
await self.middleware.call('system.reload_cli')

# default gateways changed
ipv4gw_changed = new_config['ipv4gateway'] != config['ipv4gateway']
Expand Down
16 changes: 16 additions & 0 deletions src/middlewared/middlewared/plugins/system/cli.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import contextlib
import signal

import psutil

from middlewared.service import Service, private


class SystemService(Service):
@private
def reload_cli(self):
for process in psutil.process_iter(['pid', 'cmdline']):
cmdline = process.cmdline()
if len(cmdline) >= 2 and cmdline[1] == '/usr/bin/cli':
with contextlib.suppress(Exception):
process.send_signal(signal.SIGUSR1)
2 changes: 1 addition & 1 deletion src/middlewared/middlewared/plugins/system_general/ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ async def get_ui_urls(self):
if https_port != 443:
https_url += f':{https_port}'

if all_ip4 or all_ip6:
if (i['type'] == 'INET' and all_ip4) or (i['type'] == 'INET6' and all_ip6):
urls.add(http_url)
if https_url:
urls.add(https_url)
Expand Down
13 changes: 9 additions & 4 deletions src/middlewared/middlewared/plugins/system_general/update.py
Original file line number Diff line number Diff line change
Expand Up @@ -249,16 +249,16 @@ async def do_update(self, data):
verrors = await self.validate_general_settings(new_config, 'general_settings_update')
verrors.check()

keys = new_config.keys()
for key in list(keys):
db_config = new_config.copy()
for key in list(new_config.keys()):
if key.startswith('ui_'):
new_config['gui' + key[3:]] = new_config.pop(key)
db_config['gui' + key[3:]] = db_config.pop(key)

await self.middleware.call(
'datastore.update',
self._config.datastore,
config['id'],
new_config,
db_config,
{'prefix': 'stg_'}
)

Expand Down Expand Up @@ -288,6 +288,11 @@ async def do_update(self, data):
if ui_restart_delay is not None:
await self.middleware.call('system.general.ui_restart', ui_restart_delay)

for key in ('ui_port', 'ui_httpsport', 'ui_httpsredirect', 'ui_address', 'ui_v6address'):
if config[key] != new_config[key]:
await self.middleware.call('system.reload_cli')
break

return await self.config()

@private
Expand Down
Loading