gitweb: Don't use privileged action feature to run as different user

- Instead implement running specific commands inside the privileged action as a
specific user.

Tests:

- Gitweb functional tests and unit tests work.

- Running various operations such as clone, create, set branch, rename, etc. all
result in repositories (and all their contents) owned by www-data:www-data.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: Joseph Nuthalapati <njoseph@riseup.net>
This commit is contained in:
Sunil Mohan Adapa authored and Joseph Nuthalapati committed 2025-09-05 20:22:40 +05:30
1 parent 7a4fb9d9f6
commit 87331e7c97
5 files changed
+31 -18

No files matched your search

@@ -16,16 +16,16 @@ REPO_DATA = {
'access': 'private',
}
pytestmark = pytest.mark.usefixtures('mock_privileged')
pytestmark = pytest.mark.usefixtures('mock_privileged', 'mock_run_as_user')
privileged_modules_to_mock = ['plinth.modules.gitweb.privileged']
git_installed = pytest.mark.skipif(not pathlib.Path('/usr/bin/git').exists(),
reason='git is not installed')
@pytest.fixture(autouse=True)
def fixture_set_repo_path(tmpdir):
def fixture_set_repo_path(tmp_path):
"""Set a repository path in the actions module."""
privileged.GIT_REPO_PATH = tmpdir
privileged.GIT_REPO_PATH = tmp_path
@pytest.fixture(name='existing_repo')