diff options
| author | ruki <[email protected]> | 2017-05-23 10:50:50 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2017-05-23 10:55:06 +0800 |
| commit | 5e5897bfb063f13282dabf6ecea7a1c3000664e4 (patch) | |
| tree | 1870c36844d68a6990d642071cfb71aaa64e65f3 /xmake/core/base/privilege.lua | |
| parent | ffa57872e4e1df66db1df8174ffcde4ff0dcd296 (diff) | |
modify some code styles
Diffstat (limited to 'xmake/core/base/privilege.lua')
| -rw-r--r-- | xmake/core/base/privilege.lua | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/xmake/core/base/privilege.lua b/xmake/core/base/privilege.lua index 275a7e7b5..96426cbf3 100644 --- a/xmake/core/base/privilege.lua +++ b/xmake/core/base/privilege.lua @@ -30,6 +30,7 @@ local os = require("base/os") -- store privilege function privilege.store() + -- check if root if not os.isroot() then return false @@ -40,8 +41,9 @@ function privilege.store() assert(projectdir) local owner = os.getown(projectdir) if not owner then + -- fallback to current dir - owner = os.getown(".") + owner = os.getown(os.curdir()) if not owner then return false end @@ -53,7 +55,7 @@ function privilege.store() end -- set uid - if os.uid({["ruid"] = owner.uid}).errno ~= 0 or os.uid({["euid"] = owner.uid}).errno ~= 0 then + if os.uid({ruid = owner.uid}).errno ~= 0 or os.uid({euid = owner.uid}).errno ~= 0 then return false end @@ -70,13 +72,14 @@ function privilege.has() end function privilege.get() + -- has? if privilege._HAS_PRIVILEGE ~= true then return false end -- set uid - if os.uid({["euid"] = 0}).errno ~= 0 or os.uid({["ruid"] = 0}).errno ~= 0 then + if os.uid({euid = 0}).errno ~= 0 or os.uid({ruid = 0}).errno ~= 0 then return false end |
