From 9c7c88d41a3a4f59602f1e4b42635551379ccc99 Mon Sep 17 00:00:00 2001 From: kitsunyan Date: Sat, 5 May 2018 21:42:14 +0300 Subject: Copy built packages to package cache directory --- src/utils.nim | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'src/utils.nim') 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) -- cgit v1.2.3-70-g09d2