~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
3 2

[PATCH himitsu v3] himitsu-init: prompt before overwriting secstore

Details
Message ID
<20230420114903.1653-1-sam@samnystrom.dev>
DKIM signature
missing
Download raw message
Patch: +21 -2
---
 cmd/himitsu-init/main.ha | 23 +++++++++++++++++++++--
 1 file changed, 21 insertions(+), 2 deletions(-)

diff --git a/cmd/himitsu-init/main.ha b/cmd/himitsu-init/main.ha
index 0989c6d..0608690 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;
@@ -24,7 +25,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...];
@@ -32,7 +32,26 @@ export fn main() void = {
	const tty = &bufio::buffered(tty, rbuf, wbuf);
	defer io::close(tty)!;

	// TODO: Prompt before overwriting existing secstore
	match (secstore::open()) {
	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.");
		};
	case => yield;
	};

	tty::noecho(&termios)!;

	fmt::errorln("Initializing a new himitsu secstore.")!;
	fmt::error("Please enter a passphrase: ")!;
	const pass1 = match (bufio::scanline(tty)!) {
-- 
2.40.0
Details
Message ID
<bf58f26c3e2fab1a1e50a1e783eef54e@samnystrom.dev>
In-Reply-To
<20230420114903.1653-1-sam@samnystrom.dev> (view parent)
DKIM signature
missing
Download raw message
CC'ing apreiml on this since they've pushed commit 5a4df343 to
himitsu and this patch does pretty much the same thing.
Details
Message ID
<80232c92-c3d3-a454-8784-dcfc69c91335@strohwolke.at>
In-Reply-To
<bf58f26c3e2fab1a1e50a1e783eef54e@samnystrom.dev> (view parent)
DKIM signature
missing
Download raw message
On 5/5/23 05:09, sam@samnystrom.dev wrote:
> CC'ing apreiml on this since they've pushed commit 5a4df343 to
> himitsu and this patch does pretty much the same thing.

Sorry, I've overlooked that one. If you want to rebase, we can use your 
variant. But I think it should only continue on errors::noentry. And 
it's probably better to remove the himitsu dir before creating a new 
one, since otherwise the secret files of the previous store will be 
orphaned.
Details
Message ID
<d2eef15b1ba9c3d9049c83e5198914db@samnystrom.dev>
In-Reply-To
<80232c92-c3d3-a454-8784-dcfc69c91335@strohwolke.at> (view parent)
DKIM signature
missing
Download raw message
Sure, I'll send a v4 patch later today.
Reply to thread Export thread (mbox)