From fa759a0c4b0b720f9d070e9859079141184b2de1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89rico=20Rolim?= Date: Fri, 9 Oct 2020 00:25:20 -0300 Subject: [PATCH] Create initial encryption script. --- .gitignore | 1 + encrypt-otp.in | 16 ++++++++++++++++ makefile | 10 ++++++++-- 3 files changed, 25 insertions(+), 2 deletions(-) create mode 100644 encrypt-otp.in diff --git a/.gitignore b/.gitignore index 38d6578..0ee91fb 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ cbc-file get-otp +encrypt-otp diff --git a/encrypt-otp.in b/encrypt-otp.in new file mode 100644 index 0000000..4adb127 --- /dev/null +++ b/encrypt-otp.in @@ -0,0 +1,16 @@ +#!/bin/sh +dest="${OTP_ACCOUNTS:-$HOME/.local/share/otp_accounts}" +file="$1" + +if [ ! -e "$file" ]; then + echo "'$file' doesn't exist!" + exit 1 +fi + +if @PREFIX@/libexec/cbc-file lock "$file" > "$dest"; then + echo "'$dest' successfully generated!" + exit 0 +else + echo "couldn't create '$dest'" + exit 1 +fi diff --git a/makefile b/makefile index 07a63a8..f7fd7f9 100644 --- a/makefile +++ b/makefile @@ -3,11 +3,13 @@ LDLIBS = -lbearssl -largon2 OPT = -O2 CFLAGS = -std=c99 $(OPT) -Wall -Wextra -Werror=implicit -pedantic -SCRIPT = get-otp +SCRIPT = get-otp encrypt-otp all: $(EXE) $(SCRIPT) -$(SCRIPT): $(SCRIPT).in +get-otp: get-otp.in +encrypt-otp: encrypt-otp.in +%: %.in sed -e 's|@PREFIX@|$(PREFIX)|' $^ > $@ install: all @@ -15,3 +17,7 @@ install: all mkdir -p $(DESTDIR)$(PREFIX)/libexec install -Dm755 cbc-file $(DESTDIR)$(PREFIX)/libexec/ install -Dm755 get-otp $(DESTDIR)$(PREFIX)/bin/ + install -Dm755 encrypt-otp $(DESTDIR)$(PREFIX)/bin/ + +clean: + rm -f $(EXE) $(SCRIPT)