diff options
| author | ruki <[email protected]> | 2017-05-24 11:45:37 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2017-05-24 11:45:37 +0800 |
| commit | 4e52205dc696ade5ba01c8d6ccf9831b59ad6196 (patch) | |
| tree | 2a2e2065ed0f65b019168d2e3f099363d4b96a26 /xmake/core/sandbox/modules/os.lua | |
| parent | 0041140dbfebce83293bcd3991760c8651f7a7ee (diff) | |
add privilege.sudo and find sudo modules
Diffstat (limited to 'xmake/core/sandbox/modules/os.lua')
| -rw-r--r-- | xmake/core/sandbox/modules/os.lua | 73 |
1 files changed, 0 insertions, 73 deletions
diff --git a/xmake/core/sandbox/modules/os.lua b/xmake/core/sandbox/modules/os.lua index 083181c00..00e22bfbb 100644 --- a/xmake/core/sandbox/modules/os.lua +++ b/xmake/core/sandbox/modules/os.lua @@ -464,79 +464,6 @@ function sandbox_os.uuid(name) return uuid end --- get the feature of os -function sandbox_os.feature(name) - - -- has 'sudo' feature? - if name == "sudo" then - return sandbox_os.host() ~= "windows" - end -end - --- sudo run shell with administrator permission --- --- .e.g --- os.sudo(os.run, "echo", "hello xmake!") --- -function sandbox_os.sudo(runner, cmd, ...) - - -- check - assert(sandbox_os.feature("sudo"), "no sudo!") - - -- run it with administrator permission - if sandbox_os.host() == "windows" then - - -- TODO wrap sudo.bat - runner(cmd, ...) - else - -- run it with administrator permission and preserve parent environment - runner("sudo -E " .. cmd, ...) - end -end - --- sudo run shell with administrator permission and arguments list --- --- .e.g --- os.sudov(os.runv, {"echo", "hello xmake!"}) --- -function sandbox_os.sudov(runner, shellname, argv) - - -- check - assert(sandbox_os.feature("sudo"), "no sudo!") - - -- run it with administrator permission - if sandbox_os.host() == "windows" then - - -- TODO wrap sudo.bat - runner(shellname, argv) - else - -- run it with administrator permission and preserve parent environment - runner("sudo", table.join("-E", shellname, argv)) - end -end - --- sudo run lua script with administrator permission and arguments list --- --- .e.g --- os.sudol(os.runv, "xxx.lua", {"arg1", "arg2"}) --- -function sandbox_os.sudol(runner, luafile, luaargv) - - -- init argv - local argv = {"lua", "--root"} - for _, name in ipairs({"file", "project", "backtrace", "verbose", "quiet"}) do - local value = option.get(name) - if type(value) == "string" then - table.insert(argv, "--" .. name .. "=" .. value) - elseif value then - table.insert(argv, "--" .. name) - end - end - - -- run it with administrator permission - sandbox_os.sudov(runner, path.join(sandbox_os.programdir(), "xmake"), table.join(argv, luafile, luaargv)) -end - -- get versioninfo function sandbox_os.versioninfo() return os.versioninfo() |
