summaryrefslogtreecommitdiff
path: root/xmake/actions/install/main.lua
diff options
context:
space:
mode:
authorruki <[email protected]>2017-05-23 10:08:10 +0800
committerGitHub <[email protected]>2017-05-23 10:08:10 +0800
commitffa57872e4e1df66db1df8174ffcde4ff0dcd296 (patch)
treeefdfac36b53d06e8f18d12e4abe1d32de85cc67e /xmake/actions/install/main.lua
parenta29b2d72f26bc88f64eb44cd14255dad68153e7d (diff)
parent2cb7a91bf266680266de51636ce6620cbecc9362 (diff)
Merge pull request #113 from TitanSnow/root
privilege manage (escalation & degradation) when running as root
Diffstat (limited to 'xmake/actions/install/main.lua')
-rw-r--r--xmake/actions/install/main.lua23
1 files changed, 23 insertions, 0 deletions
diff --git a/xmake/actions/install/main.lua b/xmake/actions/install/main.lua
index 3ca155789..f9bca9419 100644
--- a/xmake/actions/install/main.lua
+++ b/xmake/actions/install/main.lua
@@ -26,6 +26,7 @@
import("core.base.option")
import("core.project.task")
import("core.platform.platform")
+import("core.base.privilege")
import("install")
-- main
@@ -57,6 +58,28 @@ function main()
-- failed or not permission? request administrator permission and install it again
function (errors)
+ -- try get privilege
+ if privilege.get() then
+ local ok = try
+ {
+ function ()
+ -- install target
+ install.install(targetname or ifelse(option.get("all"), "__all", "__def"))
+
+ -- trace
+ cprint("${bright}install ok!${clear}${ok_hand}")
+
+ -- ok
+ return true
+ end
+ }
+
+ -- release privilege
+ privilege.store()
+
+ if ok then return end
+ end
+
-- show tips
cprint("${bright red}error: ${default red}installation failed, may permission denied!")