moss

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

commit 71c66d37b481c905ff3e3a4a96ff69d8603ca88b
parent 5aa1f9c25aecf99e7257cd1699c9e1b560613d0b
Author: Daniel Barlow <dan@telent.net>
Date:   Wed, 11 Aug 2021 08:58:28 +0100

tighten file permissions

Diffstat:
Mfeatures/moss.feature | 8++++++++
Mfeatures/step_definitions/steps.rb | 12++++++++++++
Mmoss.rb | 2++
3 files changed, 22 insertions(+), 0 deletions(-)

diff --git a/features/moss.feature b/features/moss.feature @@ -93,3 +93,11 @@ Feature: command-line password management 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 + 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 + And the store file "home/" is readable only by me + And my identity file is readable only by me diff --git a/features/step_definitions/steps.rb b/features/step_definitions/steps.rb @@ -183,3 +183,15 @@ end Then("I can run git {string}") do |command| @i_see = shell "#{MOSS} git #{command}" end + +Then("the store file {string} is readable only by me") do |store_file| + pathname = store_path(store_file) + mode = File.stat(pathname).mode + expect(mode & 077).to be_zero +end + +Then("my identity file is readable only by me") do + pathname= store_path("../identity") + mode = File.stat(pathname).mode + expect(mode & 077).to be_zero +end diff --git a/moss.rb b/moss.rb @@ -3,6 +3,8 @@ require 'pathname' require 'tempfile' require 'json' +File.umask(077) + # don't change these lines without changing the sed commands in Makefile AGE='age' AGE_KEYGEN='age-keygen'