    <rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:admin="http://webns.net/mvcb/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:content="http://purl.org/rss/1.0/modules/content/">
     <channel>
        <title>ACCU  :: An Example Confined User Shell</title>
        <link>https://members.accu.org/index.php/journals/2820</link>
        <description>Professionalism in Programming</description>
        <dc:language>en-us</dc:language> 
        <dc:creator>Administrator</dc:creator> 
        <admin:generatorAgent rdf:resource="http://www.xaraya.org" /> 
        <admin:errorReportsTo rdf:resource="mailto:webeditor@accu.org" />
       <sy:updatePeriod>hourly</sy:updatePeriod>
       <sy:updateFrequency>1</sy:updateFrequency>
       <docs>http://backend.userland.com/rss</docs>


        <h2>Journal Articles</h2>


<div class="xar-mod-head"><span class="xar-mod-title">Overload Journal #158 - August 2020 + Design of applications and programs</span></div>

<table border="0" cellpadding="1" cellspacing="0">
    <tbody>
    <tr>
        <td valign="top">
            Browse in :
       </td>
       <td valign="top">

                                            <a href="https://members.accu.org/index.php/journals/">All</a>

                     &gt;                         <a href="https://members.accu.org/index.php/journals/c76/">Journals</a>

                     &gt;                         <a href="https://members.accu.org/index.php/journals/c78/">Overload</a>

                     &gt;                         <a href="https://members.accu.org/index.php/journals/c413/">o158</a>
                    (7)
<br />

                                            <a href="https://members.accu.org/index.php/journals/">All</a>

                     &gt;                         <a href="https://members.accu.org/index.php/journals/c13/">Topics</a>

                     &gt;                         <a href="https://members.accu.org/index.php/journals/c67/">Design</a>
                    (236)
<br />

                                            <a href="https://members.accu.org/index.php/journals/c413-67/">Any of these categories</a>

                    -                        <a href="https://members.accu.org/index.php/journals/c413+67/">All of these categories</a>
<br />
</td>
   </tr>
   </tbody>
</table>




<div class="xar-error">
   <p>
 <strong>Note:</strong> when you create a new publication type,
the articles module will automatically use the templates
<em>user-display-[publicationtype].xt</em>
and <em>user-summary-[publicationtype].xt</em>.
If those templates do not exist when you try to preview or display a new article,
you'll get this warning :-)  Please place your own templates in themes/<em>yourtheme</em>/modules/articles . The templates will get the extension .xt there. </p>
</div>
<div class="xar-norm xar-standard-box-padding">
   <h1><strong>Title:</strong>&nbsp;An Example Confined User Shell</h1>
<p><strong>Author:</strong>&nbsp;Bob Schmidt</p>
<p>
<strong>Date:</strong> 01 August 2020 17:51:32 +01:00 or Sat, 01 August 2020 17:51:32 +01:00</p>
<p><strong>Summary:</strong>&nbsp;Snap confinement is not just for individual apps but can be applied to a complete GUI environment. Alan Griffiths demonstrates with the Mircade shell.</p>
<p><strong>Body:</strong>&nbsp;<p>In <em>Overload</em> #155 [<a href="#[Griffiths20]">Griffiths20</a>], I wrote about snap confinement and why confinement is important in the current computing landscape. Having the operating system enforce limits on the things programs can do allows them to be installed and used with confidence.</p>

<p>This time Iâ€™m going to describe another way of employing snaps that provides a bespoke confined environment that can be deployed a range of target platforms from embedded IoT devices to all the major Linux distros.</p>

<p>There are various scenarios and reasons for packaging a Snap confined shell and a selection of applications together in a confined environment. You might have applications that work well together for a particular task; or, you may want to offer a number of alternative applications and have them available on a wide range of target platforms. The Mircade snap illustrates this approach.</p>

<table class="sidebartable">
	<tr>
		<td><img src="/content/images/journals/ol158/Griffiths/Griffiths-01.png" /></td>
	</tr>
	<tr>
		<td class="title">Figure 1</td>
	</tr>
</table>

<h2>Contents of the Mircade snap</h2>

<p>The contents of the Mircade snap are determined by a <code>snapcraft.yaml</code> packaging script. I wonâ€™t go into detail about how the packaging tools work, as thereâ€™s plenty of online material that covers this well. But I will show a few extracts that illustrate how things are put together.</p>

<h3>The user shell</h3>

<p>A user shell is a program that allows the user to interact with the computer. It could be as simple as a command-line shell or as complex as a full desktop environment.</p>

<p>For Mircade, I use a modified example Mir shell (egmde) Iâ€™ve presented in my writing for <em>C Vu</em> [<a href="#[Griffiths]">Griffiths</a>]. This â€˜mircadeâ€™ branch of egmde allows the user to select one of a number of programs and run it all within the Snap confined environment (see Listing 1).</p>

<table class="sidebartable">
	<tr>
		<td>
			<pre class="programlisting">
egmde:
  source: https://github.com/AlanGriffiths/egmde.git
  source-branch: mircade
  plugin: cmake-with-ppa
  ppa: mir-team/release
  build-packages:
    - pkg-config
    - libmiral-dev
    - libboost-filesystem-dev
    - libfreetype6-dev
    - libwayland-dev
    - libxkbcommon-dev
    - g++
  stage-packages:
    - try: [libmiral4]
    - else: [libmiral3]
    - mir-graphics-drivers-desktop
    - fonts-freefont-ttf
  stage:
    - -usr/share/wayland-sessions/egmde.desktop
    - -bin/egmde-launch
			</pre>
		</td>
	</tr>
	<tr>
		<td class="title">Listing 1</td>
	</tr>
</table>

<p>If youâ€™re emulating this approach you donâ€™t have to use egmde, or even a Mir based shell, but doing so ensures there are no unexpected issues to resolve.</p>

<h3>The applications</h3>

<p>A successful â€˜bundledâ€™ snap is really down to choosing a compelling set of applications.</p>

<p>Iâ€™ve taken a bunch of games from the Ubuntu archive and bundled them into the snap. That choice is only an illustration, thereâ€™s no need to choose games, or programs from the archive.</p>

<pre class="programlisting">
  neverball:
    plugin: nil
    stage-packages:
      - neverball</pre>

<p>In this example, most of the applications use SDL2 and all use Wayland.</p>

<pre class="programlisting">
  sdl2:
    plugin: nil
    stage-packages:
      - libsdl2-2.0-0
      - libsdl2-image-2.0-0
      - libsdl2-mixer-2.0-0
      - libsdl2-net-2.0-0</pre>

<p>Iâ€™ve not covered other toolkits in the Mirade example. In spite of this, applications based on GTK, Qt and X11 can also be packaged. (X11 support does require Mir 2.0 which had not been released at the time of writing.)</p>

<h2>The target platforms</h2>

<h3>Running on Ubuntu Core</h3>

<p>There are a lot of advantages to running Ubuntu Core on IoT devices, and Mircade shows how a bundle of applications can be delivered for this. When installed on Ubuntu Core, Mircade connects to a Wayland server (such as mir-kiosk).</p>

<h3>Running on Classic Linux</h3>

<p>On Ubuntu Classic, there are four ways that Mircade can run, the first three are:</p>

<ol>
	<li>Connecting to an X11 compositor as a window on a traditional desktop</li>
	<li>Connecting to a Wayland compositor as a full-screen window on a traditional desktop</li>
	<li>Running directly on the hardware as a graphical login session</li>
</ol>

<p>For each of these the corresponding interface needs to be connected:</p>

<ul>
	<li>Connecting to an X11 compositor:<code>snap connect mircade:x11</code></li>
	<li>Connecting to a Wayland compositor:<code>snap connect mircade:wayland</code></li>
	<li>Running directly on the hardware:<code>snap connect mircade:login-session-control</code></li>
</ul>

<p>The fourth option, typically on an Ubuntu Server installation, is to run in the same way as on Ubuntu Core using a <code>mir-kiosk</code> daemon as to access the hardware.</p>

<h2>Conclusion</h2>

<p>The Mircade snap confined shell demonstrates how it is possible to take some applications, a user shell and Snap technology and use them deliver a portable, secure package to multiple Linux platforms including Ubuntu Core, Ubuntu Desktop and many other distros.</p>

<p>Targeting multiple platforms is important to the developers of snaps and confinement is important as users of a snap can ensure that it has limited access to their computer and what they are doing with it.</p>

<p>Do you have, or know of, a set of applications that would benefit from this approach?</p>

<h2>References</h2>

<p class="bibliomixed"><a id="[Griffiths]"></a>[Griffiths] Some of the relevant articles (available online to members) are:</p>
	<ul>
		<li>â€˜Making a Linux Desktopâ€™ in <em>CVu</em> 31.4, available at:<a href="https://accu.org/index.php/journals/2696">https://accu.org/index.php/journals/2696</a></li>
		
		<li>â€˜Making a Linux Desktop: Painting Some Wallpaperâ€™ in <em>CVu</em> 31.5, available at: <a href="https://accu.org/index.php/journals/2714">https://accu.org/index.php/journals/2714</a></li>
		
		<li>â€˜Making a Linux Desktop â€“ Launching Applicationsâ€™ in <em>CVu</em> 32.1, available at: <a href="https://accu.org/index.php/journals/2761">https://accu.org/index.php/journals/2761</a></li>
	</ul>

<p class="bibliomixed"><a id="[Griffiths20]"></a>[Griffiths20] Alan Griffiths (2020) â€˜What does â€˜app confinementâ€™ mean?â€™ in <em>Overload</em> 155, available at:<a href="https://accu.org/index.php/journals/2747">https://accu.org/index.php/journals/2747</a></p>

<h2>Resources</h2>

<p class="bibliomixed">Mircade on GitHub: <a href="https://github.com/MirServer/mircade">https://github.com/MirServer/mircade</a></p>

<p class="bibliomixed"><a href="https://github.com/AlanGriffiths/egmde/">Egmde on GitHub: https://github.com/AlanGriffiths/egmde/</a></p>

<p class="bibliomixed">The Mir display server: <a href="https://mir-server.io/">https://mir-server.io/</a></p>

<p class="bio"><span class="author"><b>Alan Griffiths</b></span> Alan has delivered working software and development processes to a range of organizations, written for a number of magazines, spoken at several conferences, and made many friends.</p>
</p>
<p><strong>Notes:</strong>&nbsp;</p>
<p><em>More fields may be available via dynamicdata ..</em></p>
</div>
</channel>
</rss>
