Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
drf-tunnel
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
jupyterjsc
k8s
images
drf-tunnel
Commits
4d475816
Commit
4d475816
authored
2 years ago
by
Tim Kreuzer
Browse files
Options
Downloads
Plain Diff
Merge branch 'permission_fix' into 'main'
Permission fix See merge request
!11
parents
c157ac2f
8f8ef3d3
No related branches found
No related tags found
1 merge request
!11
Permission fix
Pipeline
#106835
passed
2 years ago
Stage: unittest
Stage: build-devel
Stage: build-tag
Changes
2
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
web/tunnel/apps.py
+2
-14
2 additions, 14 deletions
web/tunnel/apps.py
web/tunnel/utils.py
+12
-1
12 additions, 1 deletion
web/tunnel/utils.py
with
14 additions
and
15 deletions
web/tunnel/apps.py
+
2
−
14
View file @
4d475816
...
...
@@ -40,20 +40,8 @@ class TunnelConfig(AppConfig):
"
Could not delete k8s service
"
,
extra
=
kwargs
,
exc_info
=
True
)
continue
try
:
log
.
debug
(
"
Create k8s svc
"
)
k8s_svc
(
"
create
"
,
alert_admins
=
True
,
**
kwargs
)
except
:
log
.
warning
(
"
Could not create k8s service. Stop/Delete tunnel
"
,
extra
=
kwargs
,
exc_info
=
True
,
)
try
:
stop_and_delete
(
raise_exception
=
False
,
**
kwargs
)
tunnel
.
delete
()
except
:
log
.
exception
(
"
Could not stop/delete ssh tunnel
"
,
extra
=
kwargs
)
k8s_svc
(
"
create
"
,
alert_admins
=
True
,
raise_exception
=
False
,
**
kwargs
)
def
create_user
(
self
,
username
,
passwd
,
groups
=
[],
superuser
=
False
,
mail
=
""
):
from
django.contrib.auth.models
import
Group
...
...
This diff is collapsed.
Click to expand it.
web/tunnel/utils.py
+
12
−
1
View file @
4d475816
...
...
@@ -116,7 +116,18 @@ def run_popen_cmd(
extra
=
log_extra
,
)
with
subprocess
.
Popen
(
cmd
,
stderr
=
subprocess
.
PIPE
,
stdout
=
subprocess
.
PIPE
)
as
p
:
# gunicorn preload app feature does not use gunicorn user/group but
# the current uid instead. Which is root. We don't want to run commands as root.
def
set_uid
():
def
result
():
os
.
setuid
(
1000
)
os
.
setgid
(
100
)
return
result
with
subprocess
.
Popen
(
cmd
,
stderr
=
subprocess
.
PIPE
,
stdout
=
subprocess
.
PIPE
,
preexec_fn
=
set_uid
()
)
as
p
:
stdout
,
stderr
=
p
.
communicate
()
returncode
=
p
.
returncode
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment