<?xml version="1.0" encoding="UTF-8"?>
<!-- generator="FeedCreator 1.8" -->
<?xml-stylesheet href="https://www.baszerr.eu/lib/exe/css.php?s=feed" type="text/css"?>
<rss version="2.0">
    <channel xmlns:g="http://base.google.com/ns/1.0">
        <title>BaSzErr - blog:2022:01:30</title>
        <description></description>
        <link>https://www.baszerr.eu/</link>
        <lastBuildDate>Wed, 06 May 2026 09:38:18 +0000</lastBuildDate>
        <generator>FeedCreator 1.8</generator>
        <image>
            <url>https://www.baszerr.eu/lib/exe/fetch.php?media=wiki:dokuwiki.svg</url>
            <title>BaSzErr</title>
            <link>https://www.baszerr.eu/</link>
        </image>
        <item>
            <title>2022-01-30_-_missing_user_in_docker_image</title>
            <link>https://www.baszerr.eu/doku.php?id=blog:2022:01:30:2022-01-30_-_missing_user_in_docker_image</link>
            <description>
&lt;h1 class=&quot;sectionedit1&quot; id=&quot;missing_user_in_docker_image&quot;&gt;2022-01-30 - missing user in docker image&lt;/h1&gt;
&lt;div class=&quot;level1&quot;&gt;

&lt;p&gt;
most of the time i don&amp;#039;t run docker images as &lt;code&gt;root&lt;/code&gt;… for obvious reasons. ;) however there are some tools, that will complain if current UID does not seem to have corresponding &lt;code&gt;/etc/passwd&lt;/code&gt; entry. for example calling &lt;code&gt;ssh-keygen -f mykey -N “” -t “ed25519”&lt;/code&gt; inside a container, started as &lt;code&gt;–user 1234:1234&lt;/code&gt; will end up with error &lt;code&gt;No user 1234&lt;/code&gt;. :/
&lt;/p&gt;

&lt;p&gt;
while i&amp;#039;m far from seeing logic in &lt;code&gt;ssh-keygen&lt;/code&gt; needing to have &lt;code&gt;/etc/passwd&lt;/code&gt; entry for a current user, that&amp;#039;s how things seem to be working atm.
&lt;/p&gt;

&lt;p&gt;
many ppl on the internet suggest to just add your user to the image, or simply assume that UID:GID is 1000:1000. these are no-go for me. adding user to image makes it impossible to change later on, thus everyone is stuck with your hardcoded user… that might not even match their setup! while it&amp;#039;s true that 1000:1000 is the most common on workstations, since usually installation has just one user account, but this fails spectacularly on shared hosts (eg. build machines on CI agents), where typically multiple users have access to it. CI agent is also a typical setup where might share a volume between host and container, so that build artifacts “survive” after container is done with building them.
&lt;/p&gt;

&lt;p&gt;
so a workaround for situation this is needed. my current best take is via a proxy shell script, like this:
&lt;/p&gt;
&lt;pre class=&quot;code bash&quot;&gt;&lt;span class=&quot;co0&quot;&gt;#!/bin/bash&lt;/span&gt;
&lt;span class=&quot;kw1&quot;&gt;set&lt;/span&gt; &lt;span class=&quot;re5&quot;&gt;-eu&lt;/span&gt; &lt;span class=&quot;re5&quot;&gt;-o&lt;/span&gt; pipefail
&amp;nbsp;
&lt;span class=&quot;co0&quot;&gt;# workaround for missing user account in /etc/passwd - some tools can&#039;t handle it...&lt;/span&gt;
&lt;span class=&quot;kw3&quot;&gt;read&lt;/span&gt; R_UID R_GID &lt;span class=&quot;sy0&quot;&gt;&amp;lt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class=&quot;st0&quot;&gt;&amp;quot;&lt;span class=&quot;es4&quot;&gt;$(echo &amp;quot;$REAL_USER&amp;quot; | tr &#039;:&#039; &#039; &#039;)&lt;/span&gt;&amp;quot;&lt;/span&gt;
groupadd &lt;span class=&quot;re5&quot;&gt;-g&lt;/span&gt; &lt;span class=&quot;st0&quot;&gt;&amp;quot;&lt;span class=&quot;es2&quot;&gt;$R_GID&lt;/span&gt;&amp;quot;&lt;/span&gt; &lt;span class=&quot;st0&quot;&gt;&amp;quot;user&amp;quot;&lt;/span&gt;
useradd &lt;span class=&quot;re5&quot;&gt;-g&lt;/span&gt; &lt;span class=&quot;st0&quot;&gt;&amp;quot;&lt;span class=&quot;es2&quot;&gt;$R_GID&lt;/span&gt;&amp;quot;&lt;/span&gt; &lt;span class=&quot;re5&quot;&gt;-u&lt;/span&gt; &lt;span class=&quot;st0&quot;&gt;&amp;quot;&lt;span class=&quot;es2&quot;&gt;$R_UID&lt;/span&gt;&amp;quot;&lt;/span&gt; &lt;span class=&quot;re5&quot;&gt;-s&lt;/span&gt; &lt;span class=&quot;st0&quot;&gt;&amp;quot;/bin/bash&amp;quot;&lt;/span&gt; &lt;span class=&quot;st0&quot;&gt;&amp;quot;user&amp;quot;&lt;/span&gt;
&amp;nbsp;
&lt;span class=&quot;kw1&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#91;&lt;/span&gt; &lt;span class=&quot;re4&quot;&gt;$#&lt;/span&gt; &lt;span class=&quot;re5&quot;&gt;-eq&lt;/span&gt; &lt;span class=&quot;nu0&quot;&gt;0&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#93;&lt;/span&gt;
&lt;span class=&quot;kw1&quot;&gt;then&lt;/span&gt;
  &lt;span class=&quot;kw3&quot;&gt;exec&lt;/span&gt; setpriv &lt;span class=&quot;re5&quot;&gt;--reuid&lt;/span&gt; &lt;span class=&quot;st0&quot;&gt;&amp;quot;user&amp;quot;&lt;/span&gt; &lt;span class=&quot;re5&quot;&gt;--regid&lt;/span&gt; &lt;span class=&quot;st0&quot;&gt;&amp;quot;user&amp;quot;&lt;/span&gt; &lt;span class=&quot;re5&quot;&gt;--init-groups&lt;/span&gt; &lt;span class=&quot;st0&quot;&gt;&amp;quot;bash&amp;quot;&lt;/span&gt;
&lt;span class=&quot;kw1&quot;&gt;fi&lt;/span&gt;
&lt;span class=&quot;kw3&quot;&gt;exec&lt;/span&gt; setpriv &lt;span class=&quot;re5&quot;&gt;--reuid&lt;/span&gt; &lt;span class=&quot;st0&quot;&gt;&amp;quot;user&amp;quot;&lt;/span&gt; &lt;span class=&quot;re5&quot;&gt;--regid&lt;/span&gt; &lt;span class=&quot;st0&quot;&gt;&amp;quot;user&amp;quot;&lt;/span&gt; &lt;span class=&quot;re5&quot;&gt;--init-groups&lt;/span&gt; &lt;span class=&quot;st0&quot;&gt;&amp;quot;$@&amp;quot;&lt;/span&gt;&lt;/pre&gt;

&lt;p&gt;
it can then be added to &lt;code&gt;Dockerfile&lt;/code&gt;:
&lt;/p&gt;
&lt;pre class=&quot;code dockerfile&quot;&gt;FROM four_favorite_distro:version
COPY shell_proxy /usr/local/bin/
ENTRYPOINT [&amp;quot;shell_proxy&amp;quot;]
...&lt;/pre&gt;

&lt;p&gt;
and run container like this:
&lt;/p&gt;
&lt;pre class=&quot;code bash&quot;&gt;docker run \
  &lt;span class=&quot;re5&quot;&gt;-it&lt;/span&gt; \
  &lt;span class=&quot;re5&quot;&gt;--rm&lt;/span&gt; \
  &lt;span class=&quot;re5&quot;&gt;-e&lt;/span&gt; &lt;span class=&quot;re2&quot;&gt;REAL_USER&lt;/span&gt;=&lt;span class=&quot;st0&quot;&gt;&amp;quot;&lt;span class=&quot;es4&quot;&gt;$(id -u)&lt;/span&gt;:&lt;span class=&quot;es4&quot;&gt;$(id -g)&lt;/span&gt;&amp;quot;&lt;/span&gt; \
  container \
    &lt;span class=&quot;kw3&quot;&gt;command&lt;/span&gt; arg1 arg2 ...&lt;/pre&gt;

&lt;p&gt;
so &lt;code&gt;docker&lt;/code&gt; will now start container as &lt;code&gt;root&lt;/code&gt;, with &lt;code&gt;REAL_USER&lt;/code&gt; pointing to UID and GID of user that it should really be running. in the entrypoint script user named &lt;code&gt;user&lt;/code&gt; is created with appropriate UID and GID and then &lt;code&gt;setpriv&lt;/code&gt; is used to execute provided command or start interactive &lt;code&gt;bash&lt;/code&gt; shell, if no command is given.
&lt;/p&gt;

&lt;/div&gt;
</description>
            <author>anonymous@undisclosed.example.com (Anonymous)</author>
            <pubDate>Sun, 30 Jan 2022 20:40:39 +0000</pubDate>
        </item>
        <item>
            <title>2022-01-30_-_real_story_behind_wayland_and_x</title>
            <link>https://www.baszerr.eu/doku.php?id=blog:2022:01:30:2022-01-30_-_real_story_behind_wayland_and_x</link>
            <description>
&lt;h1 class=&quot;sectionedit1&quot; id=&quot;real_story_behind_wayland_and_x&quot;&gt;2022-01-30 - real story behind Wayland and X&lt;/h1&gt;
&lt;div class=&quot;level1&quot;&gt;

&lt;p&gt;
some time ago a friend of mine shared with me &lt;a href=&quot;https://www.youtube.com/watch?v=GWQh_DmDLKQ&quot; class=&quot;urlextern&quot; title=&quot;https://www.youtube.com/watch?v=GWQh_DmDLKQ&quot; rel=&quot;ugc nofollow&quot;&gt;the real story behind Wayland and X&lt;/a&gt; – cool insight into how Wayland came into being and why X11 must (eventually) go.
&lt;/p&gt;

&lt;p&gt;
one thing that is still missing for me – X11 forwarding equivalent. this is my daily use case and not having it would make my life way more painful. :/
&lt;/p&gt;

&lt;/div&gt;
</description>
            <author>anonymous@undisclosed.example.com (Anonymous)</author>
            <pubDate>Sun, 30 Jan 2022 20:25:34 +0000</pubDate>
        </item>
        <item>
            <title>2022-01-30_-_world_ugliest_increment</title>
            <link>https://www.baszerr.eu/doku.php?id=blog:2022:01:30:2022-01-30_-_world_ugliest_increment</link>
            <description>
&lt;h1 class=&quot;sectionedit1&quot; id=&quot;world_ugliest_increment&quot;&gt;2022-01-30 - world ugliest increment&lt;/h1&gt;
&lt;div class=&quot;level1&quot;&gt;

&lt;p&gt;
some time ago i was working on a small project, that used &lt;a href=&quot;https://en.wikipedia.org/wiki/elasticsearch&quot; class=&quot;interwiki iw_wp&quot; title=&quot;https://en.wikipedia.org/wiki/elasticsearch&quot;&gt;elasticsearch&lt;/a&gt; as a data backend. i was facing an interesting issue, of having to do atomic increment, on a record. say under &lt;code&gt;foo.bar.data.answer&lt;/code&gt; key. the problem however was that the target record could already exist… or not. if it did exist, it could already have some value assigned… or could have been created by a different request, that do not set that field at all.
&lt;/p&gt;

&lt;p&gt;
the answer was painful, to say the least. i&amp;#039;ve ended up with this:
&lt;/p&gt;
&lt;pre class=&quot;code json&quot;&gt;{
  &amp;quot;script&amp;quot;: {
    &amp;quot;source&amp;quot;: &amp;quot;if ( ctx._source.containsKey(&#039;foo&#039;) ) { ctx._source.foo.bar.data.answer += 1; } else { ctx._source.put(&#039;foo&#039;, params); }&amp;quot;,
    &amp;quot;params&amp;quot;: {
      &amp;quot;bar&amp;quot;: {
        &amp;quot;data&amp;quot;: {
          &amp;quot;answer&amp;quot;: 1
        }
      }
    }
  },
  &amp;quot;upsert&amp;quot;: {
    &amp;quot;date&amp;quot;: &amp;quot;2020-07-20&amp;quot;,
    &amp;quot;xxx&amp;quot;: &amp;quot;ain&#039;t gonna do anything the first time - either upsert OR script will work...&amp;quot;
  }
}&lt;/pre&gt;

&lt;p&gt;
so… ES will always execute either &lt;code&gt;upsert&lt;/code&gt; or &lt;code&gt;script&lt;/code&gt;. if there entry is not there, &lt;code&gt;upsert&lt;/code&gt; will create some generic entry template. if the elemet exists, &lt;code&gt;script&lt;/code&gt; will be called instead. &lt;code&gt;script.source&lt;/code&gt; has a simple program – if given key (“branch”) exists, action is executed (here – incrementing a value). if not, content of &lt;code&gt;params&lt;/code&gt; is put under the key &lt;code&gt;foo&lt;/code&gt;, thus effectively crating some initial value, that later increments can work with.
&lt;/p&gt;

&lt;p&gt;
in my case, the problem was even more extreme, as the path itself depended on some runtime values, thus this “incremenation” code was in fact a metaprogram, generating ES script, based on the path and values needed.
&lt;/p&gt;

&lt;p&gt;
well, at the end of the day –it worked. but i guess this deserves a prize for a worst incrementation ever. it would be really nice to have ES feature, that would allow to address an existing key or create new, with a default value, in case it does not exist. such an operation would save a lot of effort.
&lt;/p&gt;

&lt;/div&gt;
</description>
            <author>anonymous@undisclosed.example.com (Anonymous)</author>
            <pubDate>Sun, 30 Jan 2022 20:11:37 +0000</pubDate>
        </item>
        <item>
            <title>2022-01-30_-_x11_forwarding_to_docker_container</title>
            <link>https://www.baszerr.eu/doku.php?id=blog:2022:01:30:2022-01-30_-_x11_forwarding_to_docker_container</link>
            <description>
&lt;h1 class=&quot;sectionedit1&quot; id=&quot;x11_forwarding_to_docker_container&quot;&gt;2022-01-30 - X11 forwarding to docker container&lt;/h1&gt;
&lt;div class=&quot;level1&quot;&gt;

&lt;p&gt;
sometime ago i had an issue with X11 forwarding for containers. for quite some time i just used setup SSHd in container and X11 forward via SSH. later on things improved. in fact my &lt;a href=&quot;https://www.baszerr.eu/doku.php?id=blog:2021:12:15:2021-12-15_-_containerized_steam&quot; class=&quot;wikilink1&quot; title=&quot;blog:2021:12:15:2021-12-15_-_containerized_steam&quot; data-wiki-id=&quot;blog:2021:12:15:2021-12-15_-_containerized_steam&quot;&gt;steam containerization&lt;/a&gt; efforts did use that approach, yet it was not exposed, so maybe it would be good to point it out explicitly.
&lt;/p&gt;

&lt;p&gt;
the spell is:
&lt;/p&gt;
&lt;pre class=&quot;code bash&quot;&gt;docker run \
  &lt;span class=&quot;re5&quot;&gt;-it&lt;/span&gt; \
  &lt;span class=&quot;re5&quot;&gt;-rm&lt;/span&gt; \
  &lt;span class=&quot;re5&quot;&gt;-u&lt;/span&gt; &lt;span class=&quot;st0&quot;&gt;&amp;quot;&lt;span class=&quot;es4&quot;&gt;$(id -u)&lt;/span&gt;:&lt;span class=&quot;es4&quot;&gt;$(id -g)&lt;/span&gt;&amp;quot;&lt;/span&gt; \
  &lt;span class=&quot;re5&quot;&gt;-e&lt;/span&gt; DISPLAY \
  &lt;span class=&quot;re5&quot;&gt;-v&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;/&lt;/span&gt;tmp&lt;span class=&quot;sy0&quot;&gt;/&lt;/span&gt;.X11-unix:&lt;span class=&quot;sy0&quot;&gt;/&lt;/span&gt;tmp&lt;span class=&quot;sy0&quot;&gt;/&lt;/span&gt;.X11-unix \
  &lt;span class=&quot;st0&quot;&gt;&amp;quot;your_image_with_x11_app&amp;quot;&lt;/span&gt;&lt;/pre&gt;

&lt;p&gt;
so the key thing is to forward &lt;code&gt;DISPLAY&lt;/code&gt; variable and path to X11 socket file. simple and straight forward… once you spent enough time on the net googling for quirks. ;)
&lt;/p&gt;

&lt;p&gt;
btw: for QT-based applications you may also want to pass &lt;code&gt;-e QT_X11_NO_MITSHM=1&lt;/code&gt;, to disabled shared memory usage.
&lt;/p&gt;

&lt;/div&gt;
</description>
            <author>anonymous@undisclosed.example.com (Anonymous)</author>
            <pubDate>Sun, 30 Jan 2022 20:21:18 +0000</pubDate>
        </item>
    </channel>
</rss>
