aboutsummaryrefslogtreecommitdiff
path: root/src/utils.nim
diff options
context:
space:
mode:
authorkitsunyan2018-05-05 18:42:14 +0000
committerkitsunyan2018-05-05 18:42:14 +0000
commit9c7c88d41a3a4f59602f1e4b42635551379ccc99 (patch)
treeb506d9ac6487aeb332fa36bcca6ae601ae26a7ef /src/utils.nim
parent4b07b34b80ecbf8cfb88945a56ce021525b74741 (diff)
Copy built packages to package cache directory
Diffstat (limited to 'src/utils.nim')
-rw-r--r--src/utils.nim11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/utils.nim b/src/utils.nim
index b480ce9..7dcf620 100644
--- a/src/utils.nim
+++ b/src/utils.nim
@@ -285,6 +285,17 @@ proc dropPrivileges*(): bool =
else:
return true
+proc checkExec(file: string): bool =
+ var statv: Stat
+ stat(file, statv) == 0 and (statv.st_mode and S_IXUSR) == S_IXUSR
+
+let sudoPrefix*: seq[string] = if checkExec(sudoCmd):
+ @[sudoCmd]
+ elif checkExec(suCmd):
+ @[suCmd, "root", "-c", "exec \"$@\"", "--", "sh"]
+ else:
+ @[]
+
var intSigact: SigAction
intSigact.sa_handler = SIG_DFL
discard sigaction(SIGINT, intSigact)