<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[couldn&#x27;t &#96;bwrap&#96; be a small shell script around &#96;unshare&#96;?]]></title><description><![CDATA[couldn't `bwrap` be a small shell script around `unshare`?]]></description><link>https://board.circlewithadot.net/topic/86b4aa48-773d-4465-a0f2-6b6f88ace880/couldn-t-bwrap-be-a-small-shell-script-around-unshare</link><generator>RSS for Node</generator><lastBuildDate>Fri, 01 May 2026 11:34:44 GMT</lastBuildDate><atom:link href="https://board.circlewithadot.net/topic/86b4aa48-773d-4465-a0f2-6b6f88ace880.rss" rel="self" type="application/rss+xml"/><pubDate>Sun, 19 Apr 2026 19:04:24 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to couldn&#x27;t &#96;bwrap&#96; be a small shell script around &#96;unshare&#96;? on Mon, 20 Apr 2026 08:23:44 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/navi%40social.vlhl.dev" aria-label="Profile: navi@social.vlhl.dev">@<bdi>navi@social.vlhl.dev</bdi></a> <a class="plugin-mentions-user plugin-mentions-a" href="/user/sertonix%40social.treehouse.systems" aria-label="Profile: sertonix@social.treehouse.systems">@<bdi>sertonix@social.treehouse.systems</bdi></a> yea  makes  sense actually</p>
<p dir="auto">imean . if  u work on  a  shell reimpl  definitely lmk ,  id  love  to help out</p>
]]></description><link>https://board.circlewithadot.net/post/https://brain.worm.pink/objects/d02aa102-f2bf-46ae-ae62-846d393a7b49</link><guid isPermaLink="true">https://board.circlewithadot.net/post/https://brain.worm.pink/objects/d02aa102-f2bf-46ae-ae62-846d393a7b49</guid><dc:creator><![CDATA[fiore@brain.worm.pink]]></dc:creator><pubDate>Mon, 20 Apr 2026 08:23:44 GMT</pubDate></item><item><title><![CDATA[Reply to couldn&#x27;t &#96;bwrap&#96; be a small shell script around &#96;unshare&#96;? on Mon, 20 Apr 2026 08:19:53 GMT]]></title><description><![CDATA[<span><a href="/user/fiore%40brain.worm.pink" rel="ugc">@<span>fiore</span></a></span> <span><a href="/user/sertonix%40social.treehouse.systems" rel="ugc">@<span>sertonix</span></a></span> still works here if the shell and such are still in the namespace, then you can nest the same way as bwrap, it's doing the exact same thing<br /><br />for bwrap you need bwrap and libcap if not static linked, so it's easier with a c program i guess, just not exclusive to it]]></description><link>https://board.circlewithadot.net/post/https://social.vlhl.dev/objects/806f6aa5-d521-4c42-9b64-723cf48761bb</link><guid isPermaLink="true">https://board.circlewithadot.net/post/https://social.vlhl.dev/objects/806f6aa5-d521-4c42-9b64-723cf48761bb</guid><dc:creator><![CDATA[navi@social.vlhl.dev]]></dc:creator><pubDate>Mon, 20 Apr 2026 08:19:53 GMT</pubDate></item><item><title><![CDATA[Reply to couldn&#x27;t &#96;bwrap&#96; be a small shell script around &#96;unshare&#96;? on Mon, 20 Apr 2026 05:41:17 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/navi%40social.vlhl.dev" aria-label="Profile: navi@social.vlhl.dev">@<bdi>navi@social.vlhl.dev</bdi></a> <a class="plugin-mentions-user plugin-mentions-a" href="/user/sertonix%40social.treehouse.systems" aria-label="Profile: sertonix@social.treehouse.systems">@<bdi>sertonix@social.treehouse.systems</bdi></a> well ,  cool thing  about  bwrap  chroots is  that  they are  nestable .</p>
]]></description><link>https://board.circlewithadot.net/post/https://brain.worm.pink/objects/ae051ea7-9cae-408a-872d-b722a11ad95b</link><guid isPermaLink="true">https://board.circlewithadot.net/post/https://brain.worm.pink/objects/ae051ea7-9cae-408a-872d-b722a11ad95b</guid><dc:creator><![CDATA[fiore@brain.worm.pink]]></dc:creator><pubDate>Mon, 20 Apr 2026 05:41:17 GMT</pubDate></item><item><title><![CDATA[Reply to couldn&#x27;t &#96;bwrap&#96; be a small shell script around &#96;unshare&#96;? on Sun, 19 Apr 2026 23:40:06 GMT]]></title><description><![CDATA[<span><a href="/user/sertonix%40social.treehouse.systems" rel="ugc">@<span>sertonix</span></a></span> <span><a href="/user/fiore%40brain.worm.pink" rel="ugc">@<span>fiore</span></a></span> <br /><br />&gt; If there is C code which wants to pass a fd into the sandbox it might happens to be the same as the one used in the shell code<br /><br />in this application, there's no reason to open file descriptors internally in the shell script (e.g. by `exec foo&gt;3` or smth) -- additionally, by all i know, posix shells are not supposed to modify already-open file descriptors passed to it, so all in all passing fds through the shell would work fine<br /><br />the only moment the shell would interact with fds directly would be to handle `bwrap`s --file argument, for the other fd arguments, unwrap expects a file path, so the shell would have to make a /proc/self/fd/$fd arg, thus not touching them directly<br /><br />&gt; As far as I can tell you are also assuming a shell to be available in the new user namespace. I have used bwrap in ways where this was not the case.<br /><br />the shell script is used to build the tmpfs, as mentioned the first post you replied to -- meaning it's launched from the host, it creates the namespaces, and executes the command inside it as the last step<br /><br />nothing here requires spawning a new shell in the resulting tmpfs root tree, so nothing requires a shell to exist inside the resulting container, *all* the setup is done in the host before chrooting, and the very same thing is true for bwrap]]></description><link>https://board.circlewithadot.net/post/https://social.vlhl.dev/objects/06bab2ab-b4b8-488f-b9c7-3c74cfcd1836</link><guid isPermaLink="true">https://board.circlewithadot.net/post/https://social.vlhl.dev/objects/06bab2ab-b4b8-488f-b9c7-3c74cfcd1836</guid><dc:creator><![CDATA[navi@social.vlhl.dev]]></dc:creator><pubDate>Sun, 19 Apr 2026 23:40:06 GMT</pubDate></item><item><title><![CDATA[Reply to couldn&#x27;t &#96;bwrap&#96; be a small shell script around &#96;unshare&#96;? on Sun, 19 Apr 2026 23:33:03 GMT]]></title><description><![CDATA[<p><span><a href="/user/navi%40social.vlhl.dev">@<span>navi</span></a></span> <span><a href="/user/fiore%40brain.worm.pink">@<span>fiore</span></a></span> </p><p>&gt; i'd like examples of what those are, for this specific usecase, because all setup happens before the target untrusted application is even started</p><p>I don't know a concrete example, it's just a guess. One might need to open fds to pass around data. In POSIX shell that typically requires fixed fd numbers. If there is C code which wants to pass a fd into the sandbox it might happens to be the same as the one used in the shell code and some data ends up in places it wasn't supposed to.</p><p>As far as I can tell you are also assuming a shell to be available in the new user namespace. I have used bwrap in ways where this was not the case.</p>]]></description><link>https://board.circlewithadot.net/post/https://social.treehouse.systems/users/sertonix/statuses/116433982840451622</link><guid isPermaLink="true">https://board.circlewithadot.net/post/https://social.treehouse.systems/users/sertonix/statuses/116433982840451622</guid><dc:creator><![CDATA[sertonix@social.treehouse.systems]]></dc:creator><pubDate>Sun, 19 Apr 2026 23:33:03 GMT</pubDate></item><item><title><![CDATA[Reply to couldn&#x27;t &#96;bwrap&#96; be a small shell script around &#96;unshare&#96;? on Sun, 19 Apr 2026 23:10:10 GMT]]></title><description><![CDATA[<span><a href="/user/sertonix%40social.treehouse.systems" rel="ugc">@<span>sertonix</span></a></span> <span><a href="/user/fiore%40brain.worm.pink" rel="ugc">@<span>fiore</span></a></span> <br /><br />&gt; later require protection against a race condition (or similar) that is impossible to fix in shell<br /><br />i'd like examples of what those are, for this specific usecase, because all setup happens before the target untrusted application is even started<br /><br />&gt; bwrap can be suid/setcap<br /><br />a thin suid/setcap wrapper can provide that (since unshare itself can't be setuid, that'd be *bad*) if it's really needed, but now a days user namespaces are basically better than setuid]]></description><link>https://board.circlewithadot.net/post/https://social.vlhl.dev/objects/eaee8791-cee5-4f04-ab4a-f5c1604b36b3</link><guid isPermaLink="true">https://board.circlewithadot.net/post/https://social.vlhl.dev/objects/eaee8791-cee5-4f04-ab4a-f5c1604b36b3</guid><dc:creator><![CDATA[navi@social.vlhl.dev]]></dc:creator><pubDate>Sun, 19 Apr 2026 23:10:10 GMT</pubDate></item><item><title><![CDATA[Reply to couldn&#x27;t &#96;bwrap&#96; be a small shell script around &#96;unshare&#96;? on Sun, 19 Apr 2026 23:02:32 GMT]]></title><description><![CDATA[<p><span><a href="/user/navi%40social.vlhl.dev">@<span>navi</span></a></span> <span><a href="/user/fiore%40brain.worm.pink">@<span>fiore</span></a></span> </p><p>My experience with shell scripts says that it can't cover the same user case as bubblewrap since bwrap can be suid/setcap if the distribution kernel requires it and being a security component will sooner or later require protection against a race condition (or similar) that is impossible to fix in shell. Aside from that the C code could be made more trimmed, yes.</p>]]></description><link>https://board.circlewithadot.net/post/https://social.treehouse.systems/users/sertonix/statuses/116433862829329012</link><guid isPermaLink="true">https://board.circlewithadot.net/post/https://social.treehouse.systems/users/sertonix/statuses/116433862829329012</guid><dc:creator><![CDATA[sertonix@social.treehouse.systems]]></dc:creator><pubDate>Sun, 19 Apr 2026 23:02:32 GMT</pubDate></item><item><title><![CDATA[Reply to couldn&#x27;t &#96;bwrap&#96; be a small shell script around &#96;unshare&#96;? on Sun, 19 Apr 2026 20:27:08 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/fiore%40brain.worm.pink" aria-label="Profile: fiore@brain.worm.pink">@<bdi>fiore@brain.worm.pink</bdi></a></p>
<p dir="auto">unshare all namespaces, map current user, create a temporary dir and mount a tmpfs on it</p>
<p dir="auto">on that tmpfs, setup /dev, /proc, /sys, and then do whatever the commandline arguments asked, be it <code>mount -o bind,ro</code>, <code>mount -o bind,rw</code>, <code>mount -o overlay</code>, etc -- skimming the manpage, all options map to either a <code>unshare</code> flag, a <code>mount</code> command, or normal coreutils commands (e.g. for --dir and --file)</p>
<p dir="auto">pivot_root into the dir, unmount the old root, drop the capabilities (that allow mounting), exec into the application, done</p>
]]></description><link>https://board.circlewithadot.net/post/https://social.vlhl.dev/objects/b0156bef-acb4-426f-b167-c0a809d6617d</link><guid isPermaLink="true">https://board.circlewithadot.net/post/https://social.vlhl.dev/objects/b0156bef-acb4-426f-b167-c0a809d6617d</guid><dc:creator><![CDATA[navi@social.vlhl.dev]]></dc:creator><pubDate>Sun, 19 Apr 2026 20:27:08 GMT</pubDate></item><item><title><![CDATA[Reply to couldn&#x27;t &#96;bwrap&#96; be a small shell script around &#96;unshare&#96;? on Sun, 19 Apr 2026 20:20:50 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/navi%40social.vlhl.dev" aria-label="Profile: navi@social.vlhl.dev">@<bdi>navi@social.vlhl.dev</bdi></a> unsharing things  properly  is not  trivial ,  so having smth  that u  know  does  it  the  way  you   want it  to be  done  is  nice</p>
]]></description><link>https://board.circlewithadot.net/post/https://brain.worm.pink/objects/ee4c3686-171e-4a7c-99ea-a43ccdf4c854</link><guid isPermaLink="true">https://board.circlewithadot.net/post/https://brain.worm.pink/objects/ee4c3686-171e-4a7c-99ea-a43ccdf4c854</guid><dc:creator><![CDATA[fiore@brain.worm.pink]]></dc:creator><pubDate>Sun, 19 Apr 2026 20:20:50 GMT</pubDate></item><item><title><![CDATA[Reply to couldn&#x27;t &#96;bwrap&#96; be a small shell script around &#96;unshare&#96;? on Sun, 19 Apr 2026 20:20:20 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/navi%40social.vlhl.dev" aria-label="Profile: navi@social.vlhl.dev">@<bdi>navi@social.vlhl.dev</bdi></a> imean  bwrap has  lots of  different features  and  things  it can  do tho .  hell it  has  overlays  n shit  too</p>
]]></description><link>https://board.circlewithadot.net/post/https://brain.worm.pink/objects/8f00d460-bb43-484c-bb4f-d29cb0e3356c</link><guid isPermaLink="true">https://board.circlewithadot.net/post/https://brain.worm.pink/objects/8f00d460-bb43-484c-bb4f-d29cb0e3356c</guid><dc:creator><![CDATA[fiore@brain.worm.pink]]></dc:creator><pubDate>Sun, 19 Apr 2026 20:20:20 GMT</pubDate></item><item><title><![CDATA[Reply to couldn&#x27;t &#96;bwrap&#96; be a small shell script around &#96;unshare&#96;? on Sun, 19 Apr 2026 20:18:25 GMT]]></title><description><![CDATA[<span><a href="/user/fiore%40brain.worm.pink" rel="ugc">@<span>fiore</span></a></span> i just learned more in depth how unshare works and i'm just at a bit of a shock, because bwrap is 4.3k lines of c when it basically could be a quite small shell script calling `unshare`, `mount` and that's about it]]></description><link>https://board.circlewithadot.net/post/https://social.vlhl.dev/objects/47e59106-0f37-4506-94a5-e469bbb351d3</link><guid isPermaLink="true">https://board.circlewithadot.net/post/https://social.vlhl.dev/objects/47e59106-0f37-4506-94a5-e469bbb351d3</guid><dc:creator><![CDATA[navi@social.vlhl.dev]]></dc:creator><pubDate>Sun, 19 Apr 2026 20:18:25 GMT</pubDate></item><item><title><![CDATA[Reply to couldn&#x27;t &#96;bwrap&#96; be a small shell script around &#96;unshare&#96;? on Sun, 19 Apr 2026 20:16:11 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/navi%40social.vlhl.dev" aria-label="Profile: navi@social.vlhl.dev">@<bdi>navi@social.vlhl.dev</bdi></a> imean  yes ?  but like .  its ok  like  it is  for me , its  nice</p>
]]></description><link>https://board.circlewithadot.net/post/https://brain.worm.pink/objects/148f40fa-96a0-4a6e-90ad-6186fe883f84</link><guid isPermaLink="true">https://board.circlewithadot.net/post/https://brain.worm.pink/objects/148f40fa-96a0-4a6e-90ad-6186fe883f84</guid><dc:creator><![CDATA[fiore@brain.worm.pink]]></dc:creator><pubDate>Sun, 19 Apr 2026 20:16:11 GMT</pubDate></item></channel></rss>