Comments (5)
So i can workaround this with
LANGUAGE=en chezmoi apply
but then i got errors for opening the temporary attachment file
What is the KeePassXC template function that you are using and what are its exact arguments?
from chezmoi.
Ahh...sorry, you are right, i missed that part.
This is the used template:
cat private_dot_ssh/private_id_ed25519.tmpl
{{ if (and (eq .chezmoi.hostname "cassandra") (eq .chezmoi.username "daniel")) -}}
{{ keepassxcAttachment "SSH / GPG/Firm - ed25519" "[email protected]" }}
{{- end -}}
This works if i not use the open
mode, but leads to the error if i use it:
LANGUAGE=en chezmoi --debug apply
2024-01-11T20:00:37+01:00 INF ReadFile component=system data="{{ if (and (eq .chezmoi.hostname \"cassandra\") (eq .chezmoi.usern..." name=/home/daniel/.local/share/chezmoi/private_dot_ssh/private_id_ed25519.tmpl size=166
2024-01-11T20:00:37+01:00 INF MkdirTemp tempDir=/tmp/chezmoi-keepassxc3807481411
2024-01-11T20:00:37+01:00 INF Start args=["keepassxc-cli","open","/mnt/Nextcloud/KeePassXC_dwe/Vault.kdbx"] path=/usr/sbin/keepassxc-cli start=2024-01-11T20:00:37+01:00
2024-01-11T20:00:45+01:00 INF RemoveAll tempDir=/tmp/chezmoi-keepassxc3807481411
chezmoi: template: private_dot_ssh/private_id_ed25519.tmpl:2:3: executing "private_dot_ssh/private_id_ed25519.tmpl" at <keepassxcAttachment "SSH / GPG/Firm - ed25519" "[email protected]">: error calling keepassxcAttachment: open /tmp/chezmoi-keepassxc3890023639/[email protected]: no such file or directory
Maybe this is an race condition as the output seems to indicate that the tempDir is removed before the file read?
BTW: i don't want to overload this issue but maybe it could be an better idea to use MemfdCreate function (at least at linux) for not having accessible files linger, but as i'm not an developer i did not know which dependencies this have.
from chezmoi.
Thank you for the follow-up. It turns out that there were several problems, all of which should be fixed by #3471.
Firstly, the prompt localization should be fixed by chezmoi now setting the LANGUAGE=en
environment variable when invoking keepassxc-cli
, as you identified. I did a fair amount of reading on localization (including this entertaining epic rant), and it seems that LANGUAGE
is indeed the correct environment variable to set, and not LC_ALL
or LANG
.
Secondly, in:
{{ keepassxcAttachment "SSH / GPG/Firm - ed25519" "[email protected]" }}
The first argument (SSH / GPG/Firm - ed25519
) is the entry name. This includes slashes, so it's actually an entry in a subgroup of a KeePassXC group, and it includes spaces, which means extra quoting is required when interacting with keepassxc-cli open
. With #3471, chezmoi should now handle KeePassXC's groups correctly and handle spaces (and other non-word characters) in KeePassXC entry and group names.
Thirdly, chezmoi was using the attachment name (the second argument, i.e. [email protected]
) as a temporary filename, even though the entry name is not necessarily a valid filename. #3471 changes this to always use a valid filename, irrespective of the attachment name.
Finally, to respond to a couple of your questions:
Maybe this is an race condition as the output seems to indicate that the tempDir is removed before the file read?
It's not evident from the logs, but there is no race condition here. The RemoveAll
line is emitted during chezmoi's cleanup (it uses Go's defer
keyword to remove the temporary directory, no matter how the function exits). The error message is only printed after the function has exited, so it appears after the cleanup has happened, even though the actual error occurred before the cleanup.
BTW: i don't want to overload this issue but maybe it could be an better idea to use MemfdCreate function (at least at linux) for not having accessible files linger, but as i'm not an developer i did not know which dependencies this have.
This is very interesting, thank you. I did not know about MemfdCreate (which calls the memfd_create
syscall). In this specific case, it's not currently possible to use it because keepassxc-cli
needs a path on the file system to write the attachment to, and MemfdCreate only creates a file descriptor, not an actual file in the filesystem (note: maybe we can use /dev/fd/$FILENO
as a filename, but this is likely OS-dependent). That said, MemfdCreate
looks like a much better way for chezmoi to create temporary files, and I'll investigate where chezmoi can use it.
from chezmoi.
Hey @twpayne, thanks for your detailed explanation (and thanks for the link to the language stuff rant! 🤣).
Regarding the memfd, i couldn't find any indication quickly whether a similar function also exists in OSX or windows, so i would guess this is sadly only useful on linux. Maybe this blog post is worth a reading for the file path problem.
from chezmoi.
@twpayne unfortunately i have to come back to this issue as the fix from #3471 has side effects in open mode.
After updating and configure open mode, the password was correctly asked for but my ssh public keys are changed:
chezmoi apply
diff --git a/.ssh/id_ed25519_underverse.pub b/.ssh/id_ed25519_underverse.pub
index c4c248ca9831d6f9d8cb7a910bdb06884e4b68b2..e4418f91ecd026655301c19a84c0d2947b3976a5 100644
--- a/.ssh/id_ed25519_underverse.pub
+++ b/.ssh/id_ed25519_underverse.pub
@@ -1 +1 @@
-ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAII3ZrFoBYwruxZLLBo6OWDjppsR1On/vuC6cgWMc0j/P underverse
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAII3ZrFoBYwruxZLLBo6OWDjppsR1On/vuC6cgWMc0j/P underverse
First i thought it is a kind of whitespace stuff...but then my keychain was not happy about the files anymore:
.ssh/id_ed25519_underverse.pub is not a public key file
So i take a closer look and the generated files do have some control sequences (seems to be ending of Bracketed Paste Mode) in front of the line:
cat -A .ssh/id_ed25519_underverse.pub
^[[?2004l^Mssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAII3ZrFoBYwruxZLLBo6OWDjppsR1On/vuC6cgWMc0j/P underverse$
The used template for this is:
cat private_dot_ssh/id_ed25519_underverse.pub.tmpl
{{- keepassxcAttribute "SSH / GPG/Underverse - ed25519" "public-key" }}
The keepassxcAttachment
and the keepassxc
functions are working and the keepassxcAttribute
is also working again after disabling the open mode.
from chezmoi.
Related Issues (20)
- Better android detection for install script
- With edit.hardlink disabled, chezmoi has nonzero exit status after exiting editor HOT 10
- Manage different platforms in a single repo HOT 2
- Some variables from .chezmoi.config are still inaccessible in templates HOT 2
- Long terminal prompts are cut off instead of wrapping HOT 2
- Merging file outside source directory leads to panic message and stacktrace dump
- How to add a directory that is a symlink and all stuff recursively in it? HOT 3
- `chezmoi unmanaged` on macOS Sonoma halts on `~/Library/Application Support/com.apple.LaunchServicesTemplateApp.dv` HOT 7
- Docs are wrong about .chezmoi.osRelease and .chezmoi.kernel type HOT 1
- chezmoi data returns strange chezmoi.config.diff.pager HOT 1
- Wrong .chezmoi.config.age.identity HOT 1
- chezmoi data -f yaml incorrectly renders "\n" as |4+ HOT 1
- Documentation contains broken links HOT 2
- .chezmoi.config.destDir is not a string HOT 1
- splitList and quoteList don't work in pair HOT 1
- chezmoi on Android can't connect to Internet/DNS HOT 4
- No "CHEZMOI_" env vars visible to plugins HOT 1
- Do not list empty directories and directories with only ignored files/subdirectories in `unmanaged` output HOT 1
- `chezmoi remove` removes the whole directory instead of removing a target HOT 3
- How to set an expiration time for "run_onchange_" script? HOT 10
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from chezmoi.