moss

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

commit 61ae2d15fe7449863893666faa4068307e477df4
parent 2199dbf77ef479e2e72c131bf64ef304e32e2547
Author: Daniel Barlow <dan@telent.net>
Date:   Wed, 11 Aug 2021 10:46:30 +0100

switch from MOSS_STORE to MOSS_HOME

Diffstat:
MREADME.md | 7+++++++
Mfeatures/moss.feature | 6+++---
Mfeatures/step_definitions/steps.rb | 20++++++++++----------
Mmoss.rb | 2+-
4 files changed, 21 insertions(+), 14 deletions(-)

diff --git a/README.md b/README.md @@ -32,6 +32,13 @@ you have age 1.0.0-rc3 or later $ moss git init # if you want to share it with other machines $ moss git remote add me@githost.example.com:/home/git/passwords +moss keeps its secrets in + +* `$MOSS_HOME/store`, if the MOSS_HOME environemt variable exists, or +* `$XDG_DATA_HOME/moss/store`, if the XDG_DATA_HOME environment variable exists, or +* `$HOME/.local/share/moss/store` : $HOME is assumed to exist + + ## Storing a secret $ echo 'supersekritpw' | moss add folder/secretname diff --git a/features/moss.feature b/features/moss.feature @@ -81,21 +81,21 @@ Feature: command-line password management Then the store directory is under XDG_DATA_HOME Scenario: I can create a new store - Given I set MOSS_STORE to a unique temporary pathname + Given I set MOSS_HOME to a unique temporary pathname When I create a moss instance with identity "me.key" Then the instance store exists And the instance identity is "me.key" And the store root has .recipients for the identity "me.key" Scenario: I can create a new store with an encrypted key - Given I set MOSS_STORE to a unique temporary pathname + Given I set MOSS_HOME to a unique temporary pathname When I interactively create a moss instance with identity "encrypted.key" and passphrase "hello foo" Then the instance store exists And the instance identity is "encrypted.key" And the store root has recipient "age1qqawnse9rfxjun2xmklk3r2pudlfjx0z4utjuwlmq7t9l60z9e2sap9vc8" Scenario: Files in the store are not readable by other users - Given I set MOSS_STORE to a unique temporary pathname + Given I set MOSS_HOME to a unique temporary pathname When I create a moss instance with identity "me.key" When I generate a secret for "home/ebay" with length 20 Then the store file "home/ebay.age" is readable only by me diff --git a/features/step_definitions/steps.rb b/features/step_definitions/steps.rb @@ -12,7 +12,7 @@ end IDENTITY_FILE = "fixtures/keys/me.key" def store_path(s) - Pathname.new(ENV["MOSS_STORE"]).join(s) + Pathname.new(ENV["MOSS_HOME"]).join("store", s) end def add_to_store(path, content) @@ -28,19 +28,19 @@ def recipient_for_identity(identity_file) raise "can't get pubkey for identity #{identity_file}" end -Given("I set MOSS_STORE to a unique temporary pathname") do - ENV["MOSS_STORE"] = Dir.mktmpdir + "/store" +Given("I set MOSS_HOME to a unique temporary pathname") do + ENV["MOSS_HOME"] = Dir.mktmpdir end Given("I am using a temporary password store") do - ENV["MOSS_STORE"] = Dir.mktmpdir + "/store" + ENV["MOSS_HOME"] = Dir.mktmpdir add_to_store("../identity", File.read(IDENTITY_FILE)) add_to_store(".recipients", recipient_for_identity(IDENTITY_FILE)) end Given("I am using the example password store") do - ENV["MOSS_STORE"] = "fixtures/store" + ENV["MOSS_HOME"] = "fixtures" end When("I generate a secret for {string} with length {int}") do |name, length| @@ -130,16 +130,16 @@ Given("there are recipient files in different subtrees") do |table| end Given("the store is version-controlled") do - shell "cd #{ENV["MOSS_STORE"]} && git init --initial-branch=main" + shell "cd #{ENV["MOSS_HOME"]}/store && git init --initial-branch=main" end Then("the change to {string} is committed to version control") do |name| - log = shell "cd #{ENV["MOSS_STORE"]} && git log #{name}" + log = shell "cd #{ENV["MOSS_HOME"]}/store && git log #{name}" expect(log).to match /new secret/ end Given("I do not specify a store") do - ENV.delete('MOSS_STORE') + ENV.delete('MOSS_HOME') end Then("the store directory is under XDG_DATA_HOME") do @@ -158,9 +158,9 @@ When("I interactively create a moss instance with identity {string} and passphra end Then("the instance store exists") do - expect(Pathname.new(ENV['MOSS_STORE'])).to be_directory + expect(Pathname.new(ENV['MOSS_HOME']).join("store")).to be_directory end - + Then("the instance identity is {string}") do |keyfile| expect(store_path("../identity").read).to eq File.read("fixtures/keys/#{keyfile}") end diff --git a/moss.rb b/moss.rb @@ -144,7 +144,7 @@ class Moss end -MOSS = Moss.new(Pathname.new(ENV['MOSS_STORE'] || "#{xdg_data_home}/moss/store").parent) +MOSS = Moss.new(ENV['MOSS_HOME'] || "#{xdg_data_home}/moss") def random_alnum(length) bytes = File.open("/dev/urandom", "rb") do |random|