Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
C
codejail
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
codejail
Commits
bbfd376d
Commit
bbfd376d
authored
Feb 03, 2015
by
Adam Palay
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
create proxy process on startup (TNL-1226)
add startup function
parent
6b17c33a
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
25 additions
and
8 deletions
+25
-8
codejail/django_integration.py
+3
-1
codejail/jail_code.py
+22
-7
No files found.
codejail/django_integration.py
View file @
bbfd376d
...
@@ -3,7 +3,6 @@
...
@@ -3,7 +3,6 @@
Code to glue codejail into a Django environment.
Code to glue codejail into a Django environment.
"""
"""
from
django.core.exceptions
import
MiddlewareNotUsed
from
django.core.exceptions
import
MiddlewareNotUsed
from
django.conf
import
settings
from
django.conf
import
settings
...
@@ -29,4 +28,7 @@ class ConfigureCodeJailMiddleware(object):
...
@@ -29,4 +28,7 @@ class ConfigureCodeJailMiddleware(object):
for
name
,
value
in
limits
.
items
():
for
name
,
value
in
limits
.
items
():
codejail
.
jail_code
.
set_limit
(
name
,
value
)
codejail
.
jail_code
.
set_limit
(
name
,
value
)
# if using a proxy, start it up now
codjail
.
jail_code
.
startup
()
raise
MiddlewareNotUsed
raise
MiddlewareNotUsed
codejail/jail_code.py
View file @
bbfd376d
...
@@ -7,7 +7,7 @@ import resource
...
@@ -7,7 +7,7 @@ import resource
import
shutil
import
shutil
import
sys
import
sys
from
.proxy
import
run_subprocess_through_proxy
from
.proxy
import
run_subprocess_through_proxy
,
get_proxy
from
.subproc
import
run_subprocess
from
.subproc
import
run_subprocess
from
.util
import
temp_directory
from
.util
import
temp_directory
...
@@ -220,12 +220,7 @@ def jail_code(command, code=None, files=None, extra_files=None, argv=None,
...
@@ -220,12 +220,7 @@ def jail_code(command, code=None, files=None, extra_files=None, argv=None,
# Add the code-specific command line pieces.
# Add the code-specific command line pieces.
cmd
.
extend
(
argv
)
cmd
.
extend
(
argv
)
# Use the configuration and maybe an environment variable to determine
if
use_proxy
():
# whether to use a proxy process.
use_proxy
=
LIMITS
[
"PROXY"
]
if
use_proxy
is
None
:
use_proxy
=
int
(
os
.
environ
.
get
(
"CODEJAIL_PROXY"
,
"0"
))
if
use_proxy
:
run_subprocess_fn
=
run_subprocess_through_proxy
run_subprocess_fn
=
run_subprocess_through_proxy
else
:
else
:
run_subprocess_fn
=
run_subprocess
run_subprocess_fn
=
run_subprocess
...
@@ -284,3 +279,23 @@ def create_rlimits():
...
@@ -284,3 +279,23 @@ def create_rlimits():
rlimits
.
append
((
resource
.
RLIMIT_FSIZE
,
(
fsize
,
fsize
)))
rlimits
.
append
((
resource
.
RLIMIT_FSIZE
,
(
fsize
,
fsize
)))
return
rlimits
return
rlimits
def
startup
():
"""
To be run when whatever process is running codejail starts up.
If we're using a proxy process, start it. Otherwise, noop.
"""
if
use_proxy
():
return
get_proxy
()
def
use_proxy
():
"""
Use the configuration and maybe an environment variable to determine
whether to use a proxy process.
"""
use_it
=
LIMITS
[
"PROXY"
]
if
use_it
is
None
:
use_it
=
bool
(
int
(
os
.
environ
.
get
(
"CODEJAIL_PROXY"
,
"0"
)))
return
use_it
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment