mirror of
https://github.com/netblue30/firejail.git
synced 2026-05-15 14:16:14 -06:00
[GH-ISSUE #1337] Possible to set runtime limit? #917
Labels
No labels
LTS merge
LTS merge
bug
bug
converted-to-discussion
doc-todo
documentation
duplicate
enhancement
file-transfer
firecfg
firejail-in-firejail
firetools
graphics
help wanted
information_old
installation
invalid
modif
moved
needinfo
networking
notabug
notourbug
old-version
overlayfs
packaging
profile-request
pull-request
question
question_old
removal
runtime-permissions
sandbox-ipc
security
stale
wiki
wiki
wontfix
wordpress
workaround
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: github-starred/firejail#917
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @sknepal on GitHub (Jun 15, 2017).
Original GitHub issue: https://github.com/netblue30/firejail/issues/1337
Hi,
I am using firejail to run bash for an online repl. The user might run python, java or other codes on the bash. Is it possible to set runtime limit for these codes so that the user for example, can be stopped from doing infinite loops etc? Like, kill the python execution as soon as it goes over 2 minutes?
If its not possible via firejail, can you think of any other way? Please let me know. I have no idea how this can be achieved.
Thank you!
@Ferroin commented on GitHub (Jun 15, 2017):
AFAIK, it's not possible with firejail, but it is possible using the ulimit builtin in bash.
For example, the following bash script will run a python script passed to it and cause SIGKILL to be sent if the total CPU time exceeds roughly 2 minutes:
Similar scripts will work for just about any interpreted language as well as mono and java.
The downside to this is that total CPU time doesn't work like most people expect it. Put simply:
Assuming this is a web app, you can also do filtering in the app itself to catch obviously bad stuff like:
@reinerh commented on GitHub (Jun 15, 2017):
Using timeout also works:
$ timeout 1s firejail sleep 20@sknepal commented on GitHub (Jun 18, 2017):
@reinerh I think that would timeout firejail but not the processes that are running on the bash (which is inside the jail). I would just like to timeout the processes, not firejail itself.
Anyway, I wrote a script to monitor for processes running longer than X seconds and kill them. Put it on crontab so that it runs regularly. That seems to have solved my problem. Thank you for the responses.