summaryrefslogtreecommitdiff
path: root/subplot
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2021-04-09 11:54:19 +0300
committerLars Wirzenius <liw@liw.fi>2021-04-09 17:17:35 +0300
commitd0b0245edbb2f6ed8285358d83b98f3334bf1b12 (patch)
tree988f72832b8a5015f4dbfb49473eba022d089666 /subplot
parent2d6c1c81bfb1c0be8dfaced1c70e825e46c66430 (diff)
downloadobnam2-d0b0245edbb2f6ed8285358d83b98f3334bf1b12.tar.gz
feat: add "obnam init" subcommand
This reads a passphrase and derives two passwords from that, and stores them next to the configuration file. The passwords aren't yet used for anything, that will come later.
Diffstat (limited to 'subplot')
-rw-r--r--subplot/data.py15
-rw-r--r--subplot/data.yaml6
2 files changed, 21 insertions, 0 deletions
diff --git a/subplot/data.py b/subplot/data.py
index 1455bf4..3833f2e 100644
--- a/subplot/data.py
+++ b/subplot/data.py
@@ -3,6 +3,7 @@ import logging
import os
import random
import socket
+import stat
import yaml
@@ -148,3 +149,17 @@ def manifests_match(ctx, expected=None, actual=None):
assert_eq(actual_objs, [])
logging.debug(f"manifests {expected} and {actual} match")
+
+
+def file_is_readable_by_owner(ctx, filename=None):
+ assert_eq = globals()["assert_eq"]
+
+ st = os.lstat(filename)
+ mode = stat.S_IMODE(st.st_mode)
+ logging.debug("file mode: %o", mode)
+ assert_eq(mode, 0o400)
+
+
+def file_does_not_contain(ctx, filename=None, pattern=None):
+ data = open(filename).read()
+ assert pattern not in data
diff --git a/subplot/data.yaml b/subplot/data.yaml
index 64348d6..699c5b1 100644
--- a/subplot/data.yaml
+++ b/subplot/data.yaml
@@ -39,3 +39,9 @@
- then: "manifests {expected} and {actual} match"
function: manifests_match
+
+- then: "file {filename} is only readable by owner"
+ function: file_is_readable_by_owner
+
+- then: "file {filename} does not contain \"{pattern:text}\""
+ function: file_does_not_contain