summaryrefslogtreecommitdiff
path: root/src/Wrapper.hs
diff options
context:
space:
mode:
authorRoman Smrž <roman.smrz@seznam.cz>2024-10-13 16:50:13 +0200
committerRoman Smrž <roman.smrz@seznam.cz>2024-10-14 20:52:21 +0200
commit0c8bad166577f9973ba5701aee5ca5d9a3f3bc5d (patch)
treec5d0db1f5ca41f95755770bcbec76c0c3fcc62dc /src/Wrapper.hs
parent321859ab1fe4a6b1f3cc7084b8836474ff872e2b (diff)
Custom C main instead of wrapper binaryHEADmasterdevel
Changelog: Use custom C main instead of wrapper binary for unshare(2) call.
Diffstat (limited to 'src/Wrapper.hs')
-rw-r--r--src/Wrapper.hs45
1 files changed, 0 insertions, 45 deletions
diff --git a/src/Wrapper.hs b/src/Wrapper.hs
deleted file mode 100644
index 544e37c..0000000
--- a/src/Wrapper.hs
+++ /dev/null
@@ -1,45 +0,0 @@
-module Main where
-
-import Control.Monad
-
-import GHC.Environment
-
-import System.Directory
-import System.Environment
-import System.FilePath
-import System.Linux.Namespaces
-import System.Posix.Process
-import System.Posix.User
-import System.Process
-
-main :: IO ()
-main = do
- -- we must get uid/gid before unshare
- uid <- getEffectiveUserID
- gid <- getEffectiveGroupID
-
- unshare [User, Network, Mount]
- writeUserMappings Nothing [UserMapping 0 uid 1]
- writeGroupMappings Nothing [GroupMapping 0 gid 1] True
-
- -- needed for creating /run/netns
- callCommand "mount -t tmpfs tmpfs /run"
-
- epath <- takeDirectory <$> getExecutablePath -- directory containing executable
- fpath <- map takeDirectory . filter (any isPathSeparator) . take 1 <$> getFullArgs
- -- directory used for invocation, can differ from above for symlinked executable
-
- let dirs = concat
- [ [ epath ]
- , [ epath </> "../../../erebos-tester-core/build/erebos-tester-core" ]
- , fpath
- ]
-
- args <- getArgs
- mapM_ (\file -> executeFile file False args Nothing) =<<
- findExecutablesInDirectories dirs "erebos-tester-core"
- when (null fpath) $
- mapM_ (\file -> executeFile file False args Nothing) =<<
- findExecutables "erebos-tester-core"
-
- fail "core binary not found"