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

+3 -4
View File
@@ -14,7 +14,7 @@ from plinth.package import Packages
from . import manifest, privileged
from .forms import is_repo_url
from .manifest import GIT_REPO_PATH, REPO_DIR_OWNER
from .manifest import GIT_REPO_PATH
_description = [
_('Git is a distributed version-control system for tracking changes in '
@@ -217,7 +217,7 @@ def get_repo_list():
def repo_info(repo):
"""Get information about repository."""
info = privileged.repo_info(repo, _run_as_user=REPO_DIR_OWNER)
info = privileged.repo_info(repo)
if info['access'] == 'private':
info['is_private'] = True
else:
@@ -248,5 +248,4 @@ def edit_repo(form_initial, form_cleaned):
privileged.set_repo_access(repo, 'public')
if form_cleaned['default_branch'] != form_initial['default_branch']:
privileged.set_default_branch(repo, form_cleaned['default_branch'],
_run_as_user=REPO_DIR_OWNER)
privileged.set_default_branch(repo, form_cleaned['default_branch'])