summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Silverstone <dsilvers@digital-scurf.org>2012-08-25 14:47:35 +0100
committerDaniel Silverstone <dsilvers@digital-scurf.org>2012-08-25 14:47:35 +0100
commit6825f94ad6d42072661f2e5d36c5b7558a79b2fd (patch)
tree4201f86f7624f5aac1e9e82df6432e14a6f36c26
parentdf164d771d48bb7cc02c513f79d19f0461ae928e (diff)
downloadgitano-6825f94ad6d42072661f2e5d36c5b7558a79b2fd.tar.gz
SANDBOX: Remove unused simplistic sandbox code
-rw-r--r--lib/gitano.lua2
-rw-r--r--lib/gitano/actions.lua1
-rw-r--r--lib/gitano/sandbox.lua78
3 files changed, 0 insertions, 81 deletions
diff --git a/lib/gitano.lua b/lib/gitano.lua
index d1a0cca..b2f8244 100644
--- a/lib/gitano.lua
+++ b/lib/gitano.lua
@@ -7,7 +7,6 @@
local util = require 'gitano.util'
local git = require 'gitano.git'
-local sandbox = require 'gitano.sandbox'
local config = require 'gitano.config'
local repository = require 'gitano.repository'
local log = require 'gitano.log'
@@ -20,7 +19,6 @@ local supple = require 'gitano.supple'
return {
util = util,
git = git,
- sandbox = sandbox,
config = config,
repository = repository,
log = log,
diff --git a/lib/gitano/actions.lua b/lib/gitano/actions.lua
index 0e4bebd..b6defc5 100644
--- a/lib/gitano/actions.lua
+++ b/lib/gitano/actions.lua
@@ -5,7 +5,6 @@
-- Copyright 2012 Daniel Silverstone <dsilvers@digital-scurf.org>
local util = require "gitano.util"
-local sandbox = require "gitano.sandbox"
local log = require "gitano.log"
local git = require "gitano.git"
local config = require "gitano.config"
diff --git a/lib/gitano/sandbox.lua b/lib/gitano/sandbox.lua
deleted file mode 100644
index d1ffe21..0000000
--- a/lib/gitano/sandbox.lua
+++ /dev/null
@@ -1,78 +0,0 @@
--- gitano.sandbox
---
--- Sandboxing functionality for Gitano
---
--- Copyright 2012 Daniel Silverstone <dsilvers@digital-scurf.org>
---
---
-
-local load = load
-local setfenv = setfenv
-local type = type
-
--- Run fn with globs as its globals. Returns a function to run which
--- returns the return values of fn, and also wrap returns the table
--- which will be filled with any new globals fn creates.
---
--- If fn is a string then it is used as the source of the function, if it
--- is a function then it is expected to be a closure which when called
--- repeatedly returns more data loaded (perhaps from a file?). src is
--- expected to be the name associated with this source code.
---
--- In case of error, returns nil, errmsg
-local function _wrap(fn, src, globs)
- local fn_glob = setmetatable({}, { __index = globs, __metatable=true })
- local fn_ret, msg
-
- assert(fn, "No function/source provided?")
- assert(src, "No source name provided?")
- globs = globs or {}
-
- if setfenv then
- -- Lua 5.1 style load...
- fn_ret, msg = ((type(fn) == "string") and loadstring or load)(fn, src)
- if not fn_ret then
- return nil, msg
- end
- setfenv(fn_ret, fn_glob)
- else
- -- Lua 5.2 style load...
- fn_ret, msg = load(fn, src, "t", fn_glob)
- if not fn_ret then
- return nil, msg
- end
- end
-
- assert(fn_ret, "Unusual, missing fn_ret now?")
-
- return fn_ret, fn_glob
-end
-
-local function safe_load(str, name)
- local fn, glob = _wrap(str, name, {})
- if not fn then
- return fn, glob
- end
- local protected, count = false, 100
- local function hookf()
- count = count - 1
- if count == 0 then
- error "TIMEOUT"
- end
- end
- local function run_safely()
- debug.sethook(hookf, "c", 10)
- fn()
- debug.sethook()
- end
- local ok, err = pcall(run_safely)
- if not ok then
- return ok, err
- end
-
- return true, glob
-end
-
-return {
- safe_load = safe_load,
-}