diff --git a/docs/guide/img/build.png b/docs/guide/img/build.png index 326f0b5..5241ba4 100644 Binary files a/docs/guide/img/build.png and b/docs/guide/img/build.png differ diff --git a/docs/guide/img/decoy-hidden.png b/docs/guide/img/decoy-hidden.png index 28acd2c..449e0af 100644 Binary files a/docs/guide/img/decoy-hidden.png and b/docs/guide/img/decoy-hidden.png differ diff --git a/docs/guide/img/decoy-views.png b/docs/guide/img/decoy-views.png index 717ee11..89d7ca6 100644 Binary files a/docs/guide/img/decoy-views.png and b/docs/guide/img/decoy-views.png differ diff --git a/docs/guide/img/genkey.png b/docs/guide/img/genkey.png index 9ea6d02..68080ec 100644 Binary files a/docs/guide/img/genkey.png and b/docs/guide/img/genkey.png differ diff --git a/docs/guide/img/help.png b/docs/guide/img/help.png index 5749a02..0825e65 100644 Binary files a/docs/guide/img/help.png and b/docs/guide/img/help.png differ diff --git a/docs/guide/img/init.png b/docs/guide/img/init.png index 1a0e51d..581262c 100644 Binary files a/docs/guide/img/init.png and b/docs/guide/img/init.png differ diff --git a/docs/guide/img/list.png b/docs/guide/img/list.png index 069ec99..782f673 100644 Binary files a/docs/guide/img/list.png and b/docs/guide/img/list.png differ diff --git a/docs/guide/img/migrate.png b/docs/guide/img/migrate.png new file mode 100644 index 0000000..6635c73 Binary files /dev/null and b/docs/guide/img/migrate.png differ diff --git a/docs/guide/img/mv-rm.png b/docs/guide/img/mv-rm.png index 9c8201e..b8e5411 100644 Binary files a/docs/guide/img/mv-rm.png and b/docs/guide/img/mv-rm.png differ diff --git a/docs/guide/img/on-disk.png b/docs/guide/img/on-disk.png index f03d53d..6983c9a 100644 Binary files a/docs/guide/img/on-disk.png and b/docs/guide/img/on-disk.png differ diff --git a/docs/guide/img/scripting.png b/docs/guide/img/scripting.png index 31578b5..42d51fe 100644 Binary files a/docs/guide/img/scripting.png and b/docs/guide/img/scripting.png differ diff --git a/docs/guide/shots.py b/docs/guide/shots.py index b74961e..95d7361 100755 --- a/docs/guide/shots.py +++ b/docs/guide/shots.py @@ -16,6 +16,7 @@ import glob import grp import html import os +import pty import shutil import subprocess import sys @@ -94,6 +95,28 @@ class Sandbox: stdout=subprocess.PIPE, stderr=subprocess.STDOUT, text=True) return self.tidy(p.stdout) + def run_tty(self, command, passphrase, answer): + """Run on a pseudo-terminal, typing answer at vault's [y/N] question.""" + env = self.env({"VAULT_PASSPHRASE": passphrase}) + pid, fd = pty.fork() + if pid == 0: + os.chdir(self.home) + os.execve("/bin/bash", ["bash", "-c", command], env) + out = b"" + while b"[y/N]" not in out: + out += os.read(fd, 1024) + os.write(fd, answer.encode() + b"\n") + try: + while True: + chunk = os.read(fd, 1024) + if not chunk: + break + out += chunk + except OSError: + pass + os.waitpid(pid, 0) + return self.tidy(out.decode().replace("\r\n", "\n")) + def tidy(self, text): owner = " %s %s " % (getpass.getuser(), grp.getgrgid(os.getgid()).gr_name) return text.replace(self.home, SHOWN_HOME).replace(owner, " sam sam ").rstrip("\n") @@ -278,6 +301,20 @@ def main(): t.cmd("find ~/.vault/store/records -type f | wc -l") shoot("decoy-hidden", t) + # migrate: one file is already in the vault, so it asks first + box.write("Scans/receipts/march.pdf", os.urandom(48_113)) + box.write("Scans/receipts/april.pdf", os.urandom(51_870)) + box.run("vault add Scans/receipts/march.pdf receipts", P) + t = Term(box) + t.lines.append(prompt() + 'vault migrate Scans/receipts') + for line in box.run_tty("vault migrate Scans/receipts", P, "y").split("\n"): + esc = html.escape(line) + if "[y/N]" in line: + esc = '%s' % esc + t.lines.append(esc) + t.cmd("ls Scans") + shoot("migrate", t) + # errors t = Term(box) t.cmd("vault list", "hunter2", highlight=("incorrect",)) diff --git a/docs/guide/vault-guide.tex b/docs/guide/vault-guide.tex index b8de223..dcef4be 100644 --- a/docs/guide/vault-guide.tex +++ b/docs/guide/vault-guide.tex @@ -572,6 +572,8 @@ before touching anything. Answer anything but \texttt{y} and nothing changes. With no terminal to ask on, the answer is no. For scripts, \texttt{--yes} answers yes up front. +\shot{migrate}{Moving a folder in. One file was already there, so vault asked first.} + \subsection{What gets skipped} When adding a folder, anything that isn't a plain file, such as symbolic links, sockets or devices, is skipped with a note. So are the vault and key