From bb1a45ef0a360c40fc4b3cca79d832fab9b42d8a Mon Sep 17 00:00:00 2001 From: Frederico Gomes Date: Sat, 21 Nov 2026 21:45:19 +0000 Subject: [PATCH] apache: Remove default welcome page Closes: #1293. Tests: - Copy /usr/share/apache2/default-site/index.html to /var/www/html/index.html. Apply the patches. The file in /var/www/html/index.html is removed. - Create a new custom file in /var/www/html/index.html. Increment the setup version so apache2 setup is run. The file is not removed. - Copy the default file again and run setup again. The file is removed. - Increment setup version again and there are no errors due to missing file. [sunil: Add check to ensure that only default files are not removed] Signed-off-by: Frederico Gomes Signed-off-by: Sunil Mohan Adapa Tested-by: Sunil Mohan Adapa Reviewed-by: Sunil Mohan Adapa --- freedombox/modules/apache/__init__.py | 2 +- freedombox/modules/apache/privileged.py | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/freedombox/modules/apache/__init__.py b/freedombox/modules/apache/__init__.py index 8df691a4b..e569c2e28 100644 --- a/freedombox/modules/apache/__init__.py +++ b/freedombox/modules/apache/__init__.py @@ -86,7 +86,7 @@ class ApacheApp(app_module.App): app_id = 'apache' - _version = 17 + _version = 18 def __init__(self) -> None: """Create components for the app.""" diff --git a/freedombox/modules/apache/privileged.py b/freedombox/modules/apache/privileged.py index 5d284ef4a..ba79b3a08 100644 --- a/freedombox/modules/apache/privileged.py +++ b/freedombox/modules/apache/privileged.py @@ -62,6 +62,15 @@ def _disable_mod_php(webserver): webserver.disable('php' + version, kind='module') +def _remove_default_index_html(): + """Remove Apache's default welcome page.""" + default_page = pathlib.Path('/var/www/html/index.html') + shipped_default_page = pathlib.Path( + '/usr/share/apache2/default-site/index.html') + if default_page.read_text() == shipped_default_page.read_text(): + default_page.unlink(missing_ok=True) + + @privileged def setup(old_version: int): """Setup Apache configuration.""" @@ -81,6 +90,7 @@ def setup(old_version: int): check=True) _setup_oidc_config() + _remove_default_index_html() with action_utils.WebserverChange() as webserver: # Disable mod_php as we have switched to mod_fcgi + php-fpm. Disable