~sircmpwn/himitsu-devel

This thread contains a patchset. You're looking at the original emails, but you may wish to use the patch review UI. Review patch
2 2

[PATCH himitsu v4 1/2] secstore: add function to remove the store

Details
Message ID
<20230506011838.14069-1-sam@samnystrom.dev>
DKIM signature
missing
Download raw message
Patch: +7 -0
This preserves the secstore path as an implementation detail of the
library.
---
 secstore/secstore.ha | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/secstore/secstore.ha b/secstore/secstore.ha
index e81156e..f02bf11 100644
--- a/secstore/secstore.ha
+++ b/secstore/secstore.ha
@@ -37,6 +37,13 @@ export fn create(passphrase: []u8) (secstore | error) = {
	return createat(passphrase, dir);
};

// Deletes the Himitsu secstore directory. This is not reversible and will
// result in the loss of all keys in the secstore.
export fn remove() (void | fs::error) = {
	let dir = dirs::data("himitsu");
	return fs::rmdirall(os::cwd, dir);
};

fn createat(passphrase: []u8, dir: const str) (secstore | error) = {
	let key: [32 + 16]u8 = [0...];
	defer bytes::zero(key);
-- 
2.40.1

[PATCH himitsu v4 2/2] himitsu-init: prompt before overwriting secstore

Details
Message ID
<20230506011838.14069-2-sam@samnystrom.dev>
In-Reply-To
<20230506011838.14069-1-sam@samnystrom.dev> (view parent)
DKIM signature
missing
Download raw message
Patch: +23 -5
---
 cmd/himitsu-init/main.ha | 28 +++++++++++++++++++++++-----
 1 file changed, 23 insertions(+), 5 deletions(-)

diff --git a/cmd/himitsu-init/main.ha b/cmd/himitsu-init/main.ha
index 865dc24..f0de681 100644
--- a/cmd/himitsu-init/main.ha
+++ b/cmd/himitsu-init/main.ha
@@ -1,3 +1,4 @@
use ascii;
use bufio;
use bytes;
use dirs;
@@ -43,7 +44,6 @@ export fn main() void = {
	};

	const termios = tty::termios_query(tty)!;
	tty::noecho(&termios)!;
	defer tty::termios_restore(&termios);

	let rbuf: [os::BUFSIZ]u8 = [0...];
@@ -57,15 +57,33 @@ export fn main() void = {
	};

	match (secstore::open()) {
	case let s: secstore::secstore =>
		secstore::close(&s);
		fmt::fatal("Error: secstore already exists.");
	case let e: secstore::error =>
	case let store: secstore::secstore =>
		secstore::close(&store);
		fmt::error("A himitsu secstore already exists. Do you want to overwrite it? [y/N]: ")!;
		const answer = match (bufio::scanline(tty)!) {
		case let buf: []u8 =>
			yield buf;
		case io::EOF =>
			fmt::fatal("Skipping secstore initialization.");
		};
		defer free(answer);
		const answer = strings::fromutf8(answer)!;
		if (ascii::strcasecmp(answer, "y") != 0 && ascii::strcasecmp(answer, "yes") != 0) {
			fmt::fatal("Skipping secstore initialization.");
		};
		match (secstore::remove()) {
		case void => void;
		case let err: fs::error =>
			fmt::fatal("Error removing existing secstore:", fs::strerror(err));
		};
	case let err: secstore::error =>
		if (!(e is fs::error && e: fs::error is errors::noentry)) {
			fmt::fatal("Error:", secstore::strerror(e));
		};
	};

	tty::noecho(&termios)!;

	fmt::errorln("Initializing a new himitsu secstore.")!;
	fmt::error("Please enter a passphrase: ")!;
	const pass1 = match (bufio::scanline(tty)!) {
-- 
2.40.1

Re: [PATCH himitsu v4 2/2] himitsu-init: prompt before overwriting secstore

Details
Message ID
<CSK32AZ2ESRW.3SGOABKN5HR3E@framework>
In-Reply-To
<20230506011838.14069-2-sam@samnystrom.dev> (view parent)
DKIM signature
missing
Download raw message
Thanks!

Pushed to git@git.sr.ht:~sircmpwn/himitsu
  de42db6..aa1ca5a  master -> master
Reply to thread Export thread (mbox)