-
Notifications
You must be signed in to change notification settings - Fork 119
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
only backup cleartext file if it exists #176
Conversation
@shivak What scenarios cause this complaint? Maybe this fixes your problem https://github.com/ryantm/agenix/pull/157/files ? |
I run into this in the following situation: $ mkdir -p secrets/wireguard
$ wg genkey | agenix -v -e secrets/wireguard/red.age -i ~/.ssh/id_ed25519
+ test 4 -gt 0
+ case "$1" in
+ shift
+ test 3 -gt 0
+ export FILE=secrets/wireguard/red.age
+ FILE=secrets/wireguard/red.age
+ shift
+ test 2 -gt 0
+ case "$1" in
+ shift
+ test 1 -gt 0
+ DEFAULT_DECRYPT+=(--identity "$1")
+ shift
+ test 0 -gt 0
+ RULES=./secrets.nix
+ trap cleanup 0 2 3 15
+ '[' 0 -eq 1 ']'
+ '[' 0 -eq 1 ']'
+ edit secrets/wireguard/red.age
+ FILE=secrets/wireguard/red.age
++ keys secrets/wireguard/red.age
++ /nix/store/513i3g7cqxzy6a2smnika69qwy9rwbga-nix-2.13.3/bin/nix-instantiate --json --eval --strict -E '(let rules = import ./secrets.nix; in rules."secrets/wireguard/red.age".publicKeys)'
++ /nix/store/hagvhrwy8jzj97kc7nyy9vr18xkg7xvk-jq-1.6-bin/bin/jq -r '.[]'
+ KEYS='ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAICfle747LQBahWbu5VId7zGOlxeILis9BPh/RexQtfQJ [email protected]
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIDvEursdg5B0QAKd8jWzHN+OfYX0OTuy3M3dMzKUDW6g [email protected]
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIMeir8vZy/O5V1sPRdXybU0jhT8LlRoIdIYq4qxgLjAR root@red'
++ /nix/store/jsk5vfpxnjmh89ddyk9lh2nzpl8dky23-mktemp-1.7/bin/mktemp -d
+ CLEARTEXT_DIR=/tmp/tmp.IDEYZozAzO
++ basename secrets/wireguard/red.age
+ CLEARTEXT_FILE=/tmp/tmp.IDEYZozAzO/red.age
+ DEFAULT_DECRYPT+=(-o "$CLEARTEXT_FILE")
+ decrypt secrets/wireguard/red.age 'ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAICfle747LQBahWbu5VId7zGOlxeILis9BPh/RexQtfQJ [email protected]
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIDvEursdg5B0QAKd8jWzHN+OfYX0OTuy3M3dMzKUDW6g [email protected]
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIMeir8vZy/O5V1sPRdXybU0jhT8LlRoIdIYq4qxgLjAR root@red'
+ FILE=secrets/wireguard/red.age
+ KEYS='ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAICfle747LQBahWbu5VId7zGOlxeILis9BPh/RexQtfQJ [email protected]
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIDvEursdg5B0QAKd8jWzHN+OfYX0OTuy3M3dMzKUDW6g [email protected]
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIMeir8vZy/O5V1sPRdXybU0jhT8LlRoIdIYq4qxgLjAR root@red'
+ '[' -z 'ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAICfle747LQBahWbu5VId7zGOlxeILis9BPh/RexQtfQJ [email protected]
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIDvEursdg5B0QAKd8jWzHN+OfYX0OTuy3M3dMzKUDW6g [email protected]
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIMeir8vZy/O5V1sPRdXybU0jhT8LlRoIdIYq4qxgLjAR root@red' ']'
+ '[' -f secrets/wireguard/red.age ']'
+ cp /tmp/tmp.IDEYZozAzO/red.age /tmp/tmp.IDEYZozAzO/red.age.before
cp: cannot stat '/tmp/tmp.IDEYZozAzO/red.age': No such file or directory
+ '[' -t 0 ']'
+ EDITOR='cp /dev/stdin'
+ cp /dev/stdin /tmp/tmp.IDEYZozAzO/red.age
+ '[' '!' -f /tmp/tmp.IDEYZozAzO/red.age ']'
+ '[' -f secrets/wireguard/red.age ']'
+ ENCRYPT=()
+ IFS=
+ read -r key
+ ENCRYPT+=(--recipient "$key")
+ IFS=
+ read -r key
+ ENCRYPT+=(--recipient "$key")
+ IFS=
+ read -r key
+ ENCRYPT+=(--recipient "$key")
+ IFS=
+ read -r key
++ /nix/store/jsk5vfpxnjmh89ddyk9lh2nzpl8dky23-mktemp-1.7/bin/mktemp -d
+ REENCRYPTED_DIR=/tmp/tmp.K2avYXIoZS
++ basename secrets/wireguard/red.age
+ REENCRYPTED_FILE=/tmp/tmp.K2avYXIoZS/red.age
+ ENCRYPT+=(-o "$REENCRYPTED_FILE")
+ /nix/store/176fb66dbfj3294chdnha0nlqyj3n3ax-rage-0.9.0/bin/rage --recipient 'ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAICfle747LQBahWbu5VId7zGOlxeILis9BPh/RexQtfQJ [email protected]' --recipient 'ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIDvEursdg5B0QAKd8jWzHN+OfYX0OTuy3M3dMzKUDW6g [email protected]' --recipient 'ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIMeir8vZy/O5V1sPRdXybU0jhT8LlRoIdIYq4qxgLjAR root@red' -o /tmp/tmp.K2avYXIoZS/red.age
+ mv -f /tmp/tmp.K2avYXIoZS/red.age secrets/wireguard/red.age
+ cleanup
+ '[' -n x ']'
+ rm -rf /tmp/tmp.IDEYZozAzO
+ '[' -n x ']'
+ rm -rf /tmp/tmp.K2avYXIoZS
+ exit 0
+ cleanup
+ '[' -n x ']'
+ rm -rf /tmp/tmp.IDEYZozAzO
+ '[' -n x ']'
+ rm -rf /tmp/tmp.K2avYXIoZS |
I faced the same problem in #211 |
Running into this when creating a fresh file with # agenix -e my-credentials.age
cp: cannot stat '/run/user/1000/tmp.DVnIKHCzPb/my-credentials.age': No such file or directory where |
@ryantm could we merge this, please? |
Why is this |
I think that |
Avoids complaints from `cp` about nonexistent files.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If someone wants to fix it to be -f && fine but lets merge if this is causing people pain.
Avoids complaints from
cp
about nonexistent files.