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

+1 -2
View File
@@ -14,12 +14,11 @@ from django.utils.translation import gettext_lazy as _
from plinth.modules import gitweb
from . import privileged
from .manifest import REPO_DIR_OWNER
def _get_branches(repo):
"""Get all the branches in the repository."""
branch_data = privileged.get_branches(repo, _run_as_user=REPO_DIR_OWNER)
branch_data = privileged.get_branches(repo)
default_branch = branch_data['default_branch']
branches = branch_data['branches']