/usr/share/doc/libghc-unixutils-doc/html/src/System-Unix-Chroot.html is in libghc-unixutils-doc 1.54.1-4build4.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 | <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<!-- Generated by HsColour, http://code.haskell.org/~malcolm/hscolour/ -->
<title>System/Unix/Chroot.hs</title>
<link type='text/css' rel='stylesheet' href='hscolour.css' />
</head>
<body>
<pre><a name="line-1"></a><span class='hs-comment'>{-# LANGUAGE ForeignFunctionInterface #-}</span>
<a name="line-2"></a><span class='hs-comment'>-- | This module, except for useEnv, is copied from the build-env package.</span>
<a name="line-3"></a><span class='hs-keyword'>module</span> <span class='hs-conid'>System</span><span class='hs-varop'>.</span><span class='hs-conid'>Unix</span><span class='hs-varop'>.</span><span class='hs-conid'>Chroot</span>
<a name="line-4"></a> <span class='hs-layout'>(</span> <span class='hs-varid'>fchroot</span>
<a name="line-5"></a> <span class='hs-layout'>,</span> <span class='hs-varid'>useEnv</span>
<a name="line-6"></a> <span class='hs-comment'>-- , forceList -- moved to progress</span>
<a name="line-7"></a> <span class='hs-comment'>-- , forceList'</span>
<a name="line-8"></a> <span class='hs-layout'>)</span> <span class='hs-keyword'>where</span>
<a name="line-9"></a>
<a name="line-10"></a><span class='hs-keyword'>import</span> <span class='hs-conid'>Control</span><span class='hs-varop'>.</span><span class='hs-conid'>Exception</span> <span class='hs-layout'>(</span><span class='hs-varid'>evaluate</span><span class='hs-layout'>)</span>
<a name="line-11"></a><span class='hs-keyword'>import</span> <span class='hs-conid'>Control</span><span class='hs-varop'>.</span><span class='hs-conid'>Monad</span><span class='hs-varop'>.</span><span class='hs-conid'>Catch</span> <span class='hs-layout'>(</span><span class='hs-conid'>MonadMask</span><span class='hs-layout'>,</span> <span class='hs-varid'>finally</span><span class='hs-layout'>)</span>
<a name="line-12"></a><span class='hs-keyword'>import</span> <span class='hs-conid'>Control</span><span class='hs-varop'>.</span><span class='hs-conid'>Monad</span><span class='hs-varop'>.</span><span class='hs-conid'>Trans</span> <span class='hs-layout'>(</span><span class='hs-conid'>MonadIO</span><span class='hs-layout'>,</span> <span class='hs-varid'>liftIO</span><span class='hs-layout'>)</span>
<a name="line-13"></a><span class='hs-keyword'>import</span> <span class='hs-keyword'>qualified</span> <span class='hs-conid'>Data</span><span class='hs-varop'>.</span><span class='hs-conid'>ByteString</span><span class='hs-varop'>.</span><span class='hs-conid'>Char8</span> <span class='hs-keyword'>as</span> <span class='hs-conid'>B</span>
<a name="line-14"></a><span class='hs-keyword'>import</span> <span class='hs-keyword'>qualified</span> <span class='hs-conid'>Data</span><span class='hs-varop'>.</span><span class='hs-conid'>ByteString</span><span class='hs-varop'>.</span><span class='hs-conid'>Lazy</span><span class='hs-varop'>.</span><span class='hs-conid'>Char8</span> <span class='hs-keyword'>as</span> <span class='hs-conid'>L</span>
<a name="line-15"></a><span class='hs-keyword'>import</span> <span class='hs-conid'>Foreign</span><span class='hs-varop'>.</span><span class='hs-conid'>C</span><span class='hs-varop'>.</span><span class='hs-conid'>Error</span>
<a name="line-16"></a><span class='hs-keyword'>import</span> <span class='hs-conid'>Foreign</span><span class='hs-varop'>.</span><span class='hs-conid'>C</span><span class='hs-varop'>.</span><span class='hs-conid'>String</span>
<a name="line-17"></a><span class='hs-keyword'>import</span> <span class='hs-conid'>System</span><span class='hs-varop'>.</span><span class='hs-conid'>Directory</span> <span class='hs-layout'>(</span><span class='hs-varid'>createDirectoryIfMissing</span><span class='hs-layout'>)</span>
<a name="line-18"></a><span class='hs-keyword'>import</span> <span class='hs-conid'>System</span><span class='hs-varop'>.</span><span class='hs-conid'>Exit</span> <span class='hs-layout'>(</span><span class='hs-conid'>ExitCode</span><span class='hs-layout'>(</span><span class='hs-conid'>ExitSuccess</span><span class='hs-layout'>)</span><span class='hs-layout'>)</span>
<a name="line-19"></a><span class='hs-keyword'>import</span> <span class='hs-conid'>System</span><span class='hs-varop'>.</span><span class='hs-conid'>FilePath</span> <span class='hs-layout'>(</span><span class='hs-varid'>dropTrailingPathSeparator</span><span class='hs-layout'>,</span> <span class='hs-varid'>dropFileName</span><span class='hs-layout'>)</span>
<a name="line-20"></a><span class='hs-keyword'>import</span> <span class='hs-conid'>System</span><span class='hs-varop'>.</span><span class='hs-conid'>IO</span> <span class='hs-layout'>(</span><span class='hs-varid'>hPutStr</span><span class='hs-layout'>,</span> <span class='hs-varid'>stderr</span><span class='hs-layout'>)</span>
<a name="line-21"></a><span class='hs-keyword'>import</span> <span class='hs-conid'>System</span><span class='hs-varop'>.</span><span class='hs-conid'>Posix</span><span class='hs-varop'>.</span><span class='hs-conid'>Env</span> <span class='hs-layout'>(</span><span class='hs-varid'>getEnv</span><span class='hs-layout'>)</span>
<a name="line-22"></a><span class='hs-keyword'>import</span> <span class='hs-conid'>System</span><span class='hs-varop'>.</span><span class='hs-conid'>Posix</span><span class='hs-varop'>.</span><span class='hs-conid'>IO</span>
<a name="line-23"></a><span class='hs-keyword'>import</span> <span class='hs-conid'>System</span><span class='hs-varop'>.</span><span class='hs-conid'>Posix</span><span class='hs-varop'>.</span><span class='hs-conid'>Directory</span>
<a name="line-24"></a><span class='hs-keyword'>import</span> <span class='hs-conid'>System</span><span class='hs-varop'>.</span><span class='hs-conid'>Process</span> <span class='hs-layout'>(</span><span class='hs-varid'>readProcessWithExitCode</span><span class='hs-layout'>,</span> <span class='hs-varid'>showCommandForUser</span><span class='hs-layout'>)</span>
<a name="line-25"></a>
<a name="line-26"></a><span class='hs-keyword'>foreign</span> <span class='hs-keyword'>import</span> <span class='hs-keyword'>ccall</span> <span class='hs-keyword'>unsafe</span> <span class='hs-str'>"chroot"</span> <span class='hs-varid'>c_chroot</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>CString</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>IO</span> <span class='hs-conid'>Int</span>
<a name="line-27"></a>
<a name="line-28"></a><a name="forceList"></a><span class='hs-comment'>{-# DEPRECATED forceList "If you need forceList enable it in progress-System.Unix.Process." #-}</span>
<a name="line-29"></a><span class='hs-definition'>forceList</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>undefined</span>
<a name="line-30"></a><a name="forceList'"></a><span class='hs-comment'>{-# DEPRECATED forceList' "If you need forceList' enable it in progress-System.Unix.Process." #-}</span>
<a name="line-31"></a><span class='hs-definition'>forceList'</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>undefined</span>
<a name="line-32"></a>
<a name="line-33"></a><a name="chroot"></a><span class='hs-comment'>-- |chroot changes the root directory to filepath</span>
<a name="line-34"></a><span class='hs-comment'>-- NOTE: it does not change the working directory, just the root directory</span>
<a name="line-35"></a><span class='hs-comment'>-- NOTE: will throw IOError if chroot fails</span>
<a name="line-36"></a><span class='hs-definition'>chroot</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>FilePath</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>IO</span> <span class='hs-conid'>()</span>
<a name="line-37"></a><span class='hs-definition'>chroot</span> <span class='hs-varid'>fp</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>withCString</span> <span class='hs-varid'>fp</span> <span class='hs-varop'>$</span> <span class='hs-keyglyph'>\</span><span class='hs-varid'>cfp</span> <span class='hs-keyglyph'>-></span> <span class='hs-varid'>throwErrnoIfMinus1_</span> <span class='hs-str'>"chroot"</span> <span class='hs-layout'>(</span><span class='hs-varid'>c_chroot</span> <span class='hs-varid'>cfp</span><span class='hs-layout'>)</span>
<a name="line-38"></a>
<a name="line-39"></a><a name="fchroot"></a><span class='hs-comment'>-- |fchroot runs an IO action inside a chroot</span>
<a name="line-40"></a><span class='hs-comment'>-- fchroot performs a chroot, runs the action, and then restores the</span>
<a name="line-41"></a><span class='hs-comment'>-- original root and working directory. This probably affects the</span>
<a name="line-42"></a><span class='hs-comment'>-- chroot and working directory of all the threads in the process,</span>
<a name="line-43"></a><span class='hs-comment'>-- so...</span>
<a name="line-44"></a><span class='hs-comment'>-- NOTE: will throw IOError if internal chroot fails</span>
<a name="line-45"></a><span class='hs-definition'>fchroot</span> <span class='hs-keyglyph'>::</span> <span class='hs-layout'>(</span><span class='hs-conid'>MonadIO</span> <span class='hs-varid'>m</span><span class='hs-layout'>,</span> <span class='hs-conid'>MonadMask</span> <span class='hs-varid'>m</span><span class='hs-layout'>)</span> <span class='hs-keyglyph'>=></span> <span class='hs-conid'>FilePath</span> <span class='hs-keyglyph'>-></span> <span class='hs-varid'>m</span> <span class='hs-varid'>a</span> <span class='hs-keyglyph'>-></span> <span class='hs-varid'>m</span> <span class='hs-varid'>a</span>
<a name="line-46"></a><span class='hs-definition'>fchroot</span> <span class='hs-varid'>path</span> <span class='hs-varid'>action</span> <span class='hs-keyglyph'>=</span>
<a name="line-47"></a> <span class='hs-keyword'>do</span> <span class='hs-varid'>origWd</span> <span class='hs-keyglyph'><-</span> <span class='hs-varid'>liftIO</span> <span class='hs-varop'>$</span> <span class='hs-varid'>getWorkingDirectory</span>
<a name="line-48"></a> <span class='hs-varid'>rootFd</span> <span class='hs-keyglyph'><-</span> <span class='hs-varid'>liftIO</span> <span class='hs-varop'>$</span> <span class='hs-varid'>openFd</span> <span class='hs-str'>"/"</span> <span class='hs-conid'>ReadOnly</span> <span class='hs-conid'>Nothing</span> <span class='hs-varid'>defaultFileFlags</span>
<a name="line-49"></a> <span class='hs-varid'>liftIO</span> <span class='hs-varop'>$</span> <span class='hs-varid'>chroot</span> <span class='hs-varid'>path</span>
<a name="line-50"></a> <span class='hs-varid'>liftIO</span> <span class='hs-varop'>$</span> <span class='hs-varid'>changeWorkingDirectory</span> <span class='hs-str'>"/"</span>
<a name="line-51"></a> <span class='hs-varid'>action</span> <span class='hs-varop'>`finally`</span> <span class='hs-layout'>(</span><span class='hs-varid'>liftIO</span> <span class='hs-varop'>$</span> <span class='hs-varid'>breakFree</span> <span class='hs-varid'>origWd</span> <span class='hs-varid'>rootFd</span><span class='hs-layout'>)</span>
<a name="line-52"></a> <span class='hs-keyword'>where</span>
<a name="line-53"></a> <span class='hs-varid'>breakFree</span> <span class='hs-varid'>origWd</span> <span class='hs-varid'>rootFd</span> <span class='hs-keyglyph'>=</span>
<a name="line-54"></a> <span class='hs-keyword'>do</span> <span class='hs-varid'>changeWorkingDirectoryFd</span> <span class='hs-varid'>rootFd</span>
<a name="line-55"></a> <span class='hs-varid'>closeFd</span> <span class='hs-varid'>rootFd</span>
<a name="line-56"></a> <span class='hs-varid'>chroot</span> <span class='hs-str'>"."</span>
<a name="line-57"></a> <span class='hs-varid'>changeWorkingDirectory</span> <span class='hs-varid'>origWd</span>
<a name="line-58"></a>
<a name="line-59"></a><a name="useEnv"></a><span class='hs-comment'>-- |The ssh inside of the chroot needs to be able to talk to the</span>
<a name="line-60"></a><span class='hs-comment'>-- running ssh-agent. Therefore we mount --bind the ssh agent socket</span>
<a name="line-61"></a><span class='hs-comment'>-- dir inside the chroot (and umount it when we exit the chroot.</span>
<a name="line-62"></a><span class='hs-definition'>useEnv</span> <span class='hs-keyglyph'>::</span> <span class='hs-layout'>(</span><span class='hs-conid'>MonadIO</span> <span class='hs-varid'>m</span><span class='hs-layout'>,</span> <span class='hs-conid'>MonadMask</span> <span class='hs-varid'>m</span><span class='hs-layout'>)</span> <span class='hs-keyglyph'>=></span> <span class='hs-conid'>FilePath</span> <span class='hs-keyglyph'>-></span> <span class='hs-layout'>(</span><span class='hs-varid'>a</span> <span class='hs-keyglyph'>-></span> <span class='hs-varid'>m</span> <span class='hs-varid'>a</span><span class='hs-layout'>)</span> <span class='hs-keyglyph'>-></span> <span class='hs-varid'>m</span> <span class='hs-varid'>a</span> <span class='hs-keyglyph'>-></span> <span class='hs-varid'>m</span> <span class='hs-varid'>a</span>
<a name="line-63"></a><span class='hs-definition'>useEnv</span> <span class='hs-varid'>rootPath</span> <span class='hs-varid'>force</span> <span class='hs-varid'>action</span> <span class='hs-keyglyph'>=</span>
<a name="line-64"></a> <span class='hs-keyword'>do</span> <span class='hs-comment'>-- In order to minimize confusion, this QIO message is output</span>
<a name="line-65"></a> <span class='hs-comment'>-- at default quietness. If you want to suppress it while seeing</span>
<a name="line-66"></a> <span class='hs-comment'>-- the output from your action, you need to say something like</span>
<a name="line-67"></a> <span class='hs-comment'>-- quieter (+ 1) (useEnv (quieter (\x->x-1) action))</span>
<a name="line-68"></a> <span class='hs-varid'>sockPath</span> <span class='hs-keyglyph'><-</span> <span class='hs-varid'>liftIO</span> <span class='hs-varop'>$</span> <span class='hs-varid'>getEnv</span> <span class='hs-str'>"SSH_AUTH_SOCK"</span>
<a name="line-69"></a> <span class='hs-varid'>home</span> <span class='hs-keyglyph'><-</span> <span class='hs-varid'>liftIO</span> <span class='hs-varop'>$</span> <span class='hs-varid'>getEnv</span> <span class='hs-str'>"HOME"</span>
<a name="line-70"></a> <span class='hs-varid'>liftIO</span> <span class='hs-varop'>$</span> <span class='hs-varid'>copySSH</span> <span class='hs-varid'>home</span>
<a name="line-71"></a> <span class='hs-comment'>-- We need to force the output before we exit the changeroot.</span>
<a name="line-72"></a> <span class='hs-comment'>-- Otherwise we lose our ability to communicate with the ssh</span>
<a name="line-73"></a> <span class='hs-comment'>-- agent and we get errors.</span>
<a name="line-74"></a> <span class='hs-varid'>withSock</span> <span class='hs-varid'>sockPath</span> <span class='hs-varop'>.</span> <span class='hs-varid'>fchroot</span> <span class='hs-varid'>rootPath</span> <span class='hs-varop'>$</span> <span class='hs-layout'>(</span><span class='hs-varid'>action</span> <span class='hs-varop'>>>=</span> <span class='hs-varid'>force</span><span class='hs-layout'>)</span>
<a name="line-75"></a> <span class='hs-keyword'>where</span>
<a name="line-76"></a> <span class='hs-varid'>copySSH</span> <span class='hs-conid'>Nothing</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>return</span> <span class='hs-conid'>()</span>
<a name="line-77"></a> <span class='hs-varid'>copySSH</span> <span class='hs-layout'>(</span><span class='hs-conid'>Just</span> <span class='hs-varid'>home</span><span class='hs-layout'>)</span> <span class='hs-keyglyph'>=</span>
<a name="line-78"></a> <span class='hs-comment'>-- Do NOT preserve ownership, files must be owned by root.</span>
<a name="line-79"></a> <span class='hs-varid'>createDirectoryIfMissing</span> <span class='hs-conid'>True</span> <span class='hs-layout'>(</span><span class='hs-varid'>rootPath</span> <span class='hs-varop'>++</span> <span class='hs-str'>"/root"</span><span class='hs-layout'>)</span> <span class='hs-varop'>>></span>
<a name="line-80"></a> <span class='hs-varid'>run</span> <span class='hs-str'>"/usr/bin/rsync"</span> <span class='hs-keyglyph'>[</span><span class='hs-str'>"-rlptgDHxS"</span><span class='hs-layout'>,</span> <span class='hs-str'>"--delete"</span><span class='hs-layout'>,</span> <span class='hs-varid'>home</span> <span class='hs-varop'>++</span> <span class='hs-str'>"/.ssh/"</span><span class='hs-layout'>,</span> <span class='hs-varid'>rootPath</span> <span class='hs-varop'>++</span> <span class='hs-str'>"/root/.ssh"</span><span class='hs-keyglyph'>]</span>
<a name="line-81"></a> <span class='hs-varid'>withSock</span> <span class='hs-keyglyph'>::</span> <span class='hs-layout'>(</span><span class='hs-conid'>MonadIO</span> <span class='hs-varid'>m</span><span class='hs-layout'>,</span> <span class='hs-conid'>MonadMask</span> <span class='hs-varid'>m</span><span class='hs-layout'>)</span> <span class='hs-keyglyph'>=></span> <span class='hs-conid'>Maybe</span> <span class='hs-conid'>FilePath</span> <span class='hs-keyglyph'>-></span> <span class='hs-varid'>m</span> <span class='hs-varid'>a</span> <span class='hs-keyglyph'>-></span> <span class='hs-varid'>m</span> <span class='hs-varid'>a</span>
<a name="line-82"></a> <span class='hs-varid'>withSock</span> <span class='hs-conid'>Nothing</span> <span class='hs-varid'>action</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>action</span>
<a name="line-83"></a> <span class='hs-varid'>withSock</span> <span class='hs-layout'>(</span><span class='hs-conid'>Just</span> <span class='hs-varid'>sockPath</span><span class='hs-layout'>)</span> <span class='hs-varid'>action</span> <span class='hs-keyglyph'>=</span>
<a name="line-84"></a> <span class='hs-varid'>withMountBind</span> <span class='hs-varid'>dir</span> <span class='hs-layout'>(</span><span class='hs-varid'>rootPath</span> <span class='hs-varop'>++</span> <span class='hs-varid'>dir</span><span class='hs-layout'>)</span> <span class='hs-varid'>action</span>
<a name="line-85"></a> <span class='hs-keyword'>where</span> <span class='hs-varid'>dir</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>dropTrailingPathSeparator</span> <span class='hs-layout'>(</span><span class='hs-varid'>dropFileName</span> <span class='hs-varid'>sockPath</span><span class='hs-layout'>)</span>
<a name="line-86"></a> <span class='hs-varid'>withMountBind</span> <span class='hs-keyglyph'>::</span> <span class='hs-layout'>(</span><span class='hs-conid'>MonadIO</span> <span class='hs-varid'>m</span><span class='hs-layout'>,</span> <span class='hs-conid'>MonadMask</span> <span class='hs-varid'>m</span><span class='hs-layout'>)</span> <span class='hs-keyglyph'>=></span> <span class='hs-conid'>FilePath</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>FilePath</span> <span class='hs-keyglyph'>-></span> <span class='hs-varid'>m</span> <span class='hs-varid'>a</span> <span class='hs-keyglyph'>-></span> <span class='hs-varid'>m</span> <span class='hs-varid'>a</span>
<a name="line-87"></a> <span class='hs-varid'>withMountBind</span> <span class='hs-varid'>toMount</span> <span class='hs-varid'>mountPoint</span> <span class='hs-varid'>action</span> <span class='hs-keyglyph'>=</span>
<a name="line-88"></a> <span class='hs-layout'>(</span><span class='hs-keyword'>do</span> <span class='hs-varid'>liftIO</span> <span class='hs-varop'>$</span> <span class='hs-varid'>createDirectoryIfMissing</span> <span class='hs-conid'>True</span> <span class='hs-varid'>mountPoint</span>
<a name="line-89"></a> <span class='hs-varid'>liftIO</span> <span class='hs-varop'>$</span> <span class='hs-varid'>run</span> <span class='hs-str'>"/bin/mount"</span> <span class='hs-keyglyph'>[</span><span class='hs-str'>"--bind"</span><span class='hs-layout'>,</span> <span class='hs-varid'>escapePathForMount</span> <span class='hs-varid'>toMount</span><span class='hs-layout'>,</span> <span class='hs-varid'>escapePathForMount</span> <span class='hs-varid'>mountPoint</span><span class='hs-keyglyph'>]</span>
<a name="line-90"></a> <span class='hs-varid'>action</span><span class='hs-layout'>)</span> <span class='hs-varop'>`finally`</span> <span class='hs-layout'>(</span><span class='hs-varid'>liftIO</span> <span class='hs-varop'>$</span> <span class='hs-varid'>run</span> <span class='hs-str'>"/bin/umount"</span> <span class='hs-keyglyph'>[</span><span class='hs-varid'>escapePathForMount</span> <span class='hs-varid'>mountPoint</span><span class='hs-keyglyph'>]</span><span class='hs-layout'>)</span>
<a name="line-91"></a> <span class='hs-varid'>escapePathForMount</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>id</span> <span class='hs-comment'>-- FIXME - Path arguments should be escaped</span>
<a name="line-92"></a>
<a name="line-93"></a> <span class='hs-varid'>run</span> <span class='hs-varid'>cmd</span> <span class='hs-varid'>args</span> <span class='hs-keyglyph'>=</span>
<a name="line-94"></a> <span class='hs-keyword'>do</span> <span class='hs-layout'>(</span><span class='hs-varid'>code</span><span class='hs-layout'>,</span> <span class='hs-varid'>out</span><span class='hs-layout'>,</span> <span class='hs-varid'>err</span><span class='hs-layout'>)</span> <span class='hs-keyglyph'><-</span> <span class='hs-varid'>readProcessWithExitCode</span> <span class='hs-varid'>cmd</span> <span class='hs-varid'>args</span> <span class='hs-str'>""</span>
<a name="line-95"></a> <span class='hs-keyword'>case</span> <span class='hs-varid'>code</span> <span class='hs-keyword'>of</span>
<a name="line-96"></a> <span class='hs-conid'>ExitSuccess</span> <span class='hs-keyglyph'>-></span> <span class='hs-varid'>return</span> <span class='hs-conid'>()</span>
<a name="line-97"></a> <span class='hs-keyword'>_</span> <span class='hs-keyglyph'>-></span> <span class='hs-varid'>error</span> <span class='hs-layout'>(</span><span class='hs-str'>"Exception in System.Unix.Chroot.useEnv: "</span> <span class='hs-varop'>++</span> <span class='hs-varid'>showCommandForUser</span> <span class='hs-varid'>cmd</span> <span class='hs-varid'>args</span> <span class='hs-varop'>++</span> <span class='hs-str'>" -> "</span> <span class='hs-varop'>++</span> <span class='hs-varid'>show</span> <span class='hs-varid'>code</span> <span class='hs-varop'>++</span>
<a name="line-98"></a> <span class='hs-str'>"\n\nstdout:\n "</span> <span class='hs-varop'>++</span> <span class='hs-varid'>prefix</span> <span class='hs-str'>"> "</span> <span class='hs-varid'>out</span> <span class='hs-varop'>++</span> <span class='hs-str'>"\n\nstderr:\n"</span> <span class='hs-varop'>++</span> <span class='hs-varid'>prefix</span> <span class='hs-str'>"> "</span> <span class='hs-varid'>err</span><span class='hs-layout'>)</span>
<a name="line-99"></a> <span class='hs-varid'>prefix</span> <span class='hs-varid'>pre</span> <span class='hs-varid'>s</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>unlines</span> <span class='hs-layout'>(</span><span class='hs-varid'>map</span> <span class='hs-layout'>(</span><span class='hs-varid'>pre</span> <span class='hs-varop'>++</span><span class='hs-layout'>)</span> <span class='hs-layout'>(</span><span class='hs-varid'>lines</span> <span class='hs-varid'>s</span><span class='hs-layout'>)</span><span class='hs-layout'>)</span>
<a name="line-100"></a>
<a name="line-101"></a><span class='hs-comment'>{-
<a name="line-102"></a>printDots :: Int -> [Output] -> IO [Output]
<a name="line-103"></a>printDots cpd output =
<a name="line-104"></a> foldM f 0 output >> return output
<a name="line-105"></a> where
<a name="line-106"></a> print rem (Stdout s) =
<a name="line-107"></a> let (dots, rem') = quotRem (rem + length s) in
<a name="line-108"></a> hPutStr stderr (replicate dots '.')
<a name="line-109"></a> return rem'
<a name="line-110"></a> print rem (Stderr s) = print rem (Stdout s)
<a name="line-111"></a>-}</span>
</pre></body>
</html>
|