<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:atom="http://www.w3.org/2005/Atom" version="2.0">
    <channel>
      <title>Snamellit - lisp</title>
      <link>https://www.snamellit.com</link>
      <description></description>
      <generator>Zola</generator>
      <language>en</language>
      <atom:link href="https://www.snamellit.com/categories/lisp/rss.xml" rel="self" type="application/rss+xml"/>
      <lastBuildDate>Tue, 25 Jun 2024 00:00:00 +0000</lastBuildDate>
      <item>
          <title>Workflows for Unix Password Store with Emacs and Shell</title>
          <pubDate>Tue, 25 Jun 2024 00:00:00 +0000</pubDate>
          <author>Peter Tillemans</author>
          <link>https://www.snamellit.com/posts/20240624t104859-secrets-management-using-unix-password-store-pass-linux-osx-sysadmin/</link>
          <guid>https://www.snamellit.com/posts/20240624t104859-secrets-management-using-unix-password-store-pass-linux-osx-sysadmin/</guid>
          <description xml:base="https://www.snamellit.com/posts/20240624t104859-secrets-management-using-unix-password-store-pass-linux-osx-sysadmin/">&lt;h1 id=&quot;table-of-contents&quot;&gt;Table of Contents&lt;/h1&gt;
&lt;ol&gt;
&lt;li&gt;&lt;a href=&quot;https://www.snamellit.com/posts/20240624t104859-secrets-management-using-unix-password-store-pass-linux-osx-sysadmin/#orgeea54c9&quot;&gt;Managing Secrets using Pass&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://www.snamellit.com/posts/20240624t104859-secrets-management-using-unix-password-store-pass-linux-osx-sysadmin/#org44c3160&quot;&gt;Installation&lt;/a&gt;
&lt;ol&gt;
&lt;li&gt;&lt;a href=&quot;https://www.snamellit.com/posts/20240624t104859-secrets-management-using-unix-password-store-pass-linux-osx-sysadmin/#org7920015&quot;&gt;GUIX&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://www.snamellit.com/posts/20240624t104859-secrets-management-using-unix-password-store-pass-linux-osx-sysadmin/#orgbee77ce&quot;&gt;Debian, Ubuntu et al&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://www.snamellit.com/posts/20240624t104859-secrets-management-using-unix-password-store-pass-linux-osx-sysadmin/#orgad61fe8&quot;&gt;Emacs Integration&lt;/a&gt;
&lt;ol&gt;
&lt;li&gt;&lt;a href=&quot;https://www.snamellit.com/posts/20240624t104859-secrets-management-using-unix-password-store-pass-linux-osx-sysadmin/#orgf739a63&quot;&gt;Enable the Unix Password Store.&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://www.snamellit.com/posts/20240624t104859-secrets-management-using-unix-password-store-pass-linux-osx-sysadmin/#org1c798ff&quot;&gt;Helper Function&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://www.snamellit.com/posts/20240624t104859-secrets-management-using-unix-password-store-pass-linux-osx-sysadmin/#org25108ee&quot;&gt;Using in Emacs Configuration&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://www.snamellit.com/posts/20240624t104859-secrets-management-using-unix-password-store-pass-linux-osx-sysadmin/#org849f72f&quot;&gt;Shell integration&lt;/a&gt;
&lt;ol&gt;
&lt;li&gt;&lt;a href=&quot;https://www.snamellit.com/posts/20240624t104859-secrets-management-using-unix-password-store-pass-linux-osx-sysadmin/#org299dd7c&quot;&gt;DirEnv integration&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://www.snamellit.com/posts/20240624t104859-secrets-management-using-unix-password-store-pass-linux-osx-sysadmin/#org158dbf2&quot;&gt;Tips&lt;/a&gt;
&lt;ol&gt;
&lt;li&gt;&lt;a href=&quot;https://www.snamellit.com/posts/20240624t104859-secrets-management-using-unix-password-store-pass-linux-osx-sysadmin/#org00fffd0&quot;&gt;Entering passwords on the terminal&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://www.snamellit.com/posts/20240624t104859-secrets-management-using-unix-password-store-pass-linux-osx-sysadmin/#org6ab1e11&quot;&gt;Getting fields from multi field secrets&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;&lt;a id=&quot;orgeea54c9&quot;&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h1 id=&quot;managing-secrets-using-pass&quot;&gt;Managing Secrets using Pass&lt;/h1&gt;
&lt;p&gt;On UNIX there is a well known tool to manage secrets called
&lt;strong&gt;password-store&lt;/strong&gt; or &lt;strong&gt;pass&lt;/strong&gt; for short.&lt;/p&gt;
&lt;p&gt;It is a very minimal tool, more to facilitate workflows that to do
real work, very much in the UNIX philosophy. It stores all secrets in
plain files in a folder structure. It does not care about what is in
the files and encrypts them using a GPG public key so only the owner
of the private key can decrypt them. It does offer special access to
the first line so a password can be quickly fetched and copied to the
clipboard or stdout or wherever some &lt;strong&gt;pass&lt;/strong&gt; aware integration needs it.&lt;/p&gt;
&lt;p&gt;Certain folders can be configured to use a different public keys to
allow pragmatic secret delegation to different systems without
exposing all secrets.&lt;/p&gt;
&lt;p&gt;It leverages the &lt;strong&gt;gpg&lt;/strong&gt; infrastructure for key management, distribution,
unlocking with &lt;strong&gt;pinentry&lt;/strong&gt;, caching with &lt;strong&gt;gpg-agent&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;&lt;a id=&quot;org44c3160&quot;&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h1 id=&quot;installation&quot;&gt;Installation&lt;/h1&gt;
&lt;p&gt;&lt;a id=&quot;org7920015&quot;&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2 id=&quot;guix&quot;&gt;GUIX&lt;/h2&gt;
&lt;p&gt;Add &lt;strong&gt;password-store&lt;/strong&gt;, &lt;strong&gt;gpg&lt;/strong&gt; and &lt;strong&gt;pinentry&lt;/strong&gt; to your package list.&lt;/p&gt;
&lt;p&gt;The &lt;strong&gt;pinentry&lt;/strong&gt; program provides a client to securely unlock your keys in
a GUI and terminal environment. There are other options to make it
better fit your environment, but this is fine for me.&lt;/p&gt;
&lt;p&gt;&lt;a id=&quot;orgbee77ce&quot;&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2 id=&quot;debian-ubuntu-et-al&quot;&gt;Debian, Ubuntu et al&lt;/h2&gt;
&lt;p&gt;Add &lt;strong&gt;pass&lt;/strong&gt;, &lt;strong&gt;gpg&lt;/strong&gt;, &lt;strong&gt;gpg-agent&lt;/strong&gt; and &lt;strong&gt;pinentry-gnome&lt;/strong&gt; of &lt;strong&gt;pinentry-qt&lt;/strong&gt; using&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #D8DEE9; background-color: #2E3440;&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;$ apt-get install pass gpg gpg-agent pinentry-qt&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Both the gnome and qt versions at least fall back gracefully if no
graphical environment are available.&lt;/p&gt;
&lt;p&gt;The current selected pinentry program is provided as
&lt;strong&gt;/usr/bin/pinentry&lt;/strong&gt; and this link is managed by the usual alternatives
machinery in debian based distros.&lt;/p&gt;
&lt;p&gt;&lt;a id=&quot;orgad61fe8&quot;&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h1 id=&quot;emacs-integration&quot;&gt;Emacs Integration&lt;/h1&gt;
&lt;p&gt;Emacs &lt;strong&gt;auth-source&lt;/strong&gt; infrastructure supports &lt;strong&gt;pass&lt;/strong&gt; out of the box.&lt;/p&gt;
&lt;p&gt;&lt;a id=&quot;orgf739a63&quot;&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2 id=&quot;enable-the-unix-password-store&quot;&gt;Enable the Unix Password Store.&lt;/h2&gt;
&lt;p&gt;We have to make sure the password-store is added to the
auth-sources. There is a handy function for that:&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #D8DEE9; background-color: #2E3440;&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;;; enable unix password-store&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;(auth-source-pass-enable)&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;We add that somewhere in the init.el before any secrets are needed.&lt;/p&gt;
&lt;p&gt;&lt;a id=&quot;org1c798ff&quot;&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2 id=&quot;helper-function&quot;&gt;Helper Function&lt;/h2&gt;
&lt;p&gt;Auth-sources is a flexible system and works like a database, i.e. you
can query, browse through results and have multiple fields per secret.&lt;/p&gt;
&lt;p&gt;Example:&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #D8DEE9; background-color: #2E3440;&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;(defun snam-password (host user)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  &amp;quot;Get password from the unix password store.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;Searches the password file for a secret in the folder corresponding to&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;the HOST name given, which is the folder with the &amp;#39;/&amp;#39; replaced by a &amp;#39;.&amp;#39;.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;The filename in the folder corresponds to the USER argument with a&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;&amp;#39;.pgp&amp;#39; extension.&amp;quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  (auth-info-password&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;   (car (auth-source-search&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;         :max 1&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;         :host host&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;         :user user))))&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;`auth-source-search` returns a list of results, so we have to get the
first entry with `car`. The secret is lightly obfuscated, hence the
need to decode it with the `auth-info-password` function.&lt;/p&gt;
&lt;p&gt;Luckily there is a function &lt;a href=&quot;help:auth-source-pass-get&quot;&gt;auth-source-pass-get&lt;/a&gt; to get a password
from the password store which also follows the recommended conventions
for multiple fields in a pass file.&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #D8DEE9; background-color: #2E3440;&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;(auth-source-pass-get &amp;#39;secret &amp;quot;snamellit/znc&amp;quot;)&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The pseudo key `&#39;secret` returns the first line of the password store
entry which contains the password, per &lt;strong&gt;pass&lt;/strong&gt; conventions.&lt;/p&gt;
&lt;p&gt;&lt;a id=&quot;org25108ee&quot;&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2 id=&quot;using-in-emacs-configuration&quot;&gt;Using in Emacs Configuration&lt;/h2&gt;
&lt;p&gt;For single secrets, like connecting to my &lt;strong&gt;znc&lt;/strong&gt; IRC bouncer:&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #D8DEE9; background-color: #2E3440;&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;(erc-tls :id &amp;#39;znc :server &amp;quot;********&amp;quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;         :port &amp;quot;****&amp;quot; :user &amp;quot;xyz&amp;quot; :nick&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;         &amp;quot;foobar&amp;quot; :password (auth-source-pass-get &amp;#39;secret &amp;quot;foobar/znc&amp;quot;)))&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;For multifield secrets, like for google authentication, we can
leverage the multiple fields in the password store. Here is my
&lt;strong&gt;org-gcal&lt;/strong&gt; configuration:&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #D8DEE9; background-color: #2E3440;&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;(setq org-gcal-client-id (auth-source-pass-get &amp;#39;secret &amp;quot;snamellit/org-gcal-client&amp;quot;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;      org-gcal-client-secret (auth-source-pass-get &amp;quot;id&amp;quot; &amp;quot;snamellit/org-gcal-client&amp;quot;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;      org-gcal-fetch-file-alist &amp;#39;((&amp;quot;xyz@foobar.com&amp;quot; .  &amp;quot;~/org/schedule.org&amp;quot;)))&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;a id=&quot;org849f72f&quot;&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h1 id=&quot;shell-integration&quot;&gt;Shell integration&lt;/h1&gt;
&lt;p&gt;&lt;a id=&quot;org299dd7c&quot;&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2 id=&quot;direnv-integration&quot;&gt;DirEnv integration&lt;/h2&gt;
&lt;p&gt;When developping 12-factor or similar inspired apps, the configuration
is passed using environment variables. Using &lt;strong&gt;.envrc&lt;/strong&gt; files with
&lt;strong&gt;direnv&lt;/strong&gt; integration in the shell is a very smooth way to work in
multiple projects.&lt;/p&gt;
&lt;p&gt;It is of course less than ideal to have the secrets exposed in the
&lt;strong&gt;.envrc&lt;/strong&gt; files in your project tree even if it is in the &lt;strong&gt;.gitignore&lt;/strong&gt;
file, although that is infinitely better than having secrets end up in
the git repository.&lt;/p&gt;
&lt;p&gt;Secrets in the &lt;strong&gt;.envrc&lt;/strong&gt; files can be easily moved to the password store
by entering the folder. The following snippet prints the current value
to the screen and then inserts it in the password store, and verifies
it actually is entered correctly.&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #D8DEE9; background-color: #2E3440;&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;$ echo $FOO_BAR_PASSWORD&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;$ echo $FOO_BAR_PASSWORD | pass add -e foo/bar&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;$ pass foo/bar&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;and then editing the &lt;strong&gt;.envrc&lt;/strong&gt; file from&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #D8DEE9; background-color: #2E3440;&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;...&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;FOO_BAR_PASSWORD=&amp;lt;some secret&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;...&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;to&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #D8DEE9; background-color: #2E3440;&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;...&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;FOO_BAR_PASSWORD=$(pass foo/bar)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;...&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;After modification you&#39;ll be asked to allow to read the new &lt;strong&gt;.envrc&lt;/strong&gt;
file content and you can check if it still works by comparing the
password with the one printed previously.&lt;/p&gt;
&lt;p&gt;Printing the passwords allows to fix any typos. If this are the only
copies you have of them you might rug-pull yourself. Ideally it should
be possible to quickly recreate secrets if you lose any, but reality
is often far from ideal. Echoing all these passwords is also not
ideal, but preferable over keeping a little black book of secrets. If
these passwords are coming from another password manager it is not
needed of course.&lt;/p&gt;
&lt;p&gt;Do not forget to clear your terminal scroll back history with&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #D8DEE9; background-color: #2E3440;&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;$ clear&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;To help migration of &lt;strong&gt;.envrc&lt;/strong&gt; files I created a bash script I stored in
&lt;strong&gt;~/.local/bin/envrc-to-pass&lt;/strong&gt;:&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #D8DEE9; background-color: #2E3440;&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;#!/bin/bash&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;if [ &amp;quot;$#&amp;quot; -ne 2 ]; then&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    echo &amp;quot;Usage: $0 &amp;lt;variable_name&amp;gt; &amp;lt;namespace&amp;gt;&amp;quot; &amp;gt;&amp;amp;2&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    exit 1&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;fi&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;VAR_NAME=$1&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;SLUG=$(echo $VAR_NAME | sed &amp;#39;s/_/-/g&amp;#39; | tr &amp;#39;[:upper:]&amp;#39; &amp;#39;[:lower:]&amp;#39;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;NAMESPACE=$2&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;echo &amp;quot;Moving variable $VAR_NAME to $NAMESPACE/$SLUG in password store&amp;quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;SECRET=$(grep &amp;quot;$VAR_NAME=&amp;quot; .envrc | cut -d&amp;#39;=&amp;#39; -f2)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;if (echo $SECRET | grep &amp;#39;^\$(pass.*)&amp;#39;); then&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    echo &amp;quot;secret already migrated&amp;quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;else&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    echo $SECRET | pass insert -e $NAMESPACE/$SLUG&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;fi&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;sed -i &amp;quot;s#$VAR_NAME=.*#$VAR_NAME=\\\$(pass $NAMESPACE\/$SLUG)#&amp;quot; .envrc&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This makes short work of migrating projects to use the password-store.&lt;/p&gt;
&lt;p&gt;&lt;a id=&quot;org158dbf2&quot;&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h1 id=&quot;tips&quot;&gt;Tips&lt;/h1&gt;
&lt;p&gt;&lt;a id=&quot;org00fffd0&quot;&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2 id=&quot;entering-passwords-on-the-terminal&quot;&gt;Entering passwords on the terminal&lt;/h2&gt;
&lt;p&gt;Usually invoking `pass add foobar/baz` will ask to enter the password
and confirm it in the shell.&lt;/p&gt;
&lt;p&gt;However when piping a secret into the password-store
with&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #D8DEE9; background-color: #2E3440;&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;echo FOO_BAR_PASSWORD | pass add foo/bar&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;will silently fail although the man pages tell that `pass add` will
read from &lt;strong&gt;stdin&lt;/strong&gt;. It is not clear IMO that you have to specify the &lt;strong&gt;-e&lt;/strong&gt;
flag like :&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #D8DEE9; background-color: #2E3440;&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;echo FOO_BAR_PASSWORD | pass -e add foo/bar&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;to suppress the confirmation and make it work as expected.&lt;/p&gt;
&lt;p&gt;&lt;a id=&quot;org6ab1e11&quot;&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2 id=&quot;getting-fields-from-multi-field-secrets&quot;&gt;Getting fields from multi field secrets&lt;/h2&gt;
&lt;p&gt;Often secrets come in multiple parts which are nice to be stored in a
single entry in order not to complicate the tree. The &lt;strong&gt;pass&lt;/strong&gt;
documentation suggests:&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #D8DEE9; background-color: #2E3440;&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;&amp;lt;password or main secret&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;field1: &amp;lt;some data&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;field2: &amp;lt;more data&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;the main secret is just the first line, and can have the same
structure as the other lines, if that makes more sense.&lt;/p&gt;
&lt;p&gt;e.g. for a google integration:&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #D8DEE9; background-color: #2E3440;&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;service-account: 1234567-abcdefghijklm@developer.gserviceadmin.com(some-project)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;email: xyz@foobar.com&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;private-key: ...&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;In this case it is useful to &lt;span class=&quot;underline&quot;&gt;document&lt;/span&gt; which kind of secret it is as it
could also be an api-key, or a refresh-token, or whatever part of the
authentication menagerie that Google offers.&lt;/p&gt;
&lt;p&gt;To get these fields individually I use:&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #D8DEE9; background-color: #2E3440;&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;GOOGLE_EMAIL=$(pass foo/bar | awk &amp;#39;/^email:/ {print $2}) &lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;in emacs this syntax is supported directly and the same info can be
fetched with&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #D8DEE9; background-color: #2E3440;&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;(let&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    ((google-email (auth-source-pass-get &amp;quot;email&amp;quot; &amp;quot;foo/bar&amp;quot;)))&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  ... )&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;</description>
      </item>
      <item>
          <title>Issue with SBCL console output in Sly</title>
          <pubDate>Sat, 13 Apr 2024 00:00:00 +0000</pubDate>
          <author>Peter Tillemans</author>
          <link>https://www.snamellit.com/posts/sly-repl-io-issues/</link>
          <guid>https://www.snamellit.com/posts/sly-repl-io-issues/</guid>
          <description xml:base="https://www.snamellit.com/posts/sly-repl-io-issues/">&lt;h1 id=&quot;inconsistent-output-in-repl&quot;&gt;Inconsistent output in REPL&lt;/h1&gt;
&lt;p&gt;When doing the examples in the &lt;em&gt;Practical Common Lisp&lt;/em&gt; book I had confusing output in the repl when prompting the user for CDs using SBCL.&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #D8DEE9; background-color: #2E3440;&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;; Dedicated output stream setup (port 46185)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;; Redirecting all output to this MREPL&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;; SLY 1.0.43 (#&amp;lt;MREPL mrepl-1-1&amp;gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;CL-USER&amp;gt; (prompt-for-cd)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;Title: Unplugged&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;Eric Clapton &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;8&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;y&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Apparently a similar issue was first found on MacOSX and later confirmed on Arch.&lt;/p&gt;
&lt;p&gt;The suggestion was given to disable passing the output via a socket to have higher performance that via the protocol by adding&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #D8DEE9; background-color: #2E3440;&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;(setf slynk:*use-dedicated-output-stream* nil)&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Since I rather have something working than it being highly performant and not-working I followed the suggestion which fixed the issue:&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #D8DEE9; background-color: #2E3440;&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;CL-USER&amp;gt; (prompt-for-cd)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;Title: Bar &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;Artist: Foo Fighters&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;Rating: 8&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;Ripped: y&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;y (y or n) y&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;(:TITLE &amp;quot;Bar &amp;quot; :ARTIST &amp;quot;Foo Fighters&amp;quot; :RATING 8 :RIPPED T)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;CL-USER&amp;gt;  &lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;so I can continue with the chapter.&lt;/p&gt;
</description>
      </item>
    </channel>
</rss>
