~sircmpwn/himitsu-devel

himitsu: rename himitsu-store to himitsu-init v1 APPLIED

Armin Preiml: 2
 rename himitsu-store to himitsu-init
 use himitsu-store -i to initialize a new keystore

 12 files changed, 53 insertions(+), 35 deletions(-)
Applied!

To https://git.sr.ht/~sircmpwn/himitsu
   734a34b..  master -> master
Export patchset (mbox)
How do I use this?

Copy & paste the following snippet into your terminal to import this patchset into git:

curl -s https://lists.sr.ht/~sircmpwn/himitsu-devel/patches/41826/mbox | git am -3
Learn more about email & git

[PATCH himitsu 1/2] rename himitsu-store to himitsu-init Export this patch

---
 .gitignore                                     |  2 +-
 Makefile                                       | 18 +++++++++---------
 README.md                                      |  2 +-
 cmd/{himitsu-init => himitsu-store}/main.ha    |  2 +-
 ...{himitsu-init.1.scd => himitsu-store.1.scd} |  8 ++++----
 docs/himitsu.7.scd                             |  4 ++--
 docs/himitsu.ini.5.scd                         |  2 +-
 docs/himitsud.1.scd                            |  4 ++--
 8 files changed, 21 insertions(+), 21 deletions(-)
 rename cmd/{himitsu-init => himitsu-store}/main.ha (99%)
 rename docs/{himitsu-init.1.scd => himitsu-store.1.scd} (78%)

diff --git a/.gitignore b/.gitignore
index ed61257..e037955 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,5 +1,5 @@
/himitsud
/himitsu-init
/himitsu-store
/hiq
.teststore/
*.1
diff --git a/Makefile b/Makefile
index a344359..459b08b 100644
--- a/Makefile
+++ b/Makefile
@@ -12,12 +12,12 @@ MANDIR=$(SHAREDIR)/man
HARESRCDIR=$(SRCDIR)/hare
THIRDPARTYDIR=$(HARESRCDIR)/third-party

all: himitsud himitsu-init hiq docs
all: himitsud himitsu-store hiq docs

himitsud:
	hare build -o $@ cmd/$@/

himitsu-init:
himitsu-store:
	hare build -o $@ cmd/$@/

hiq:
@@ -28,7 +28,7 @@ check:

DOCS=\
     himitsud.1 \
     himitsu-init.1 \
     himitsu-store.1 \
     hiq.1 \
     himitsu.ini.5 \
     himitsu-ipc.5 \
@@ -40,7 +40,7 @@ docs: $(DOCS)
himitsud.1: docs/himitsud.1.scd
	$(SCDOC) <$< >$@

himitsu-init.1: docs/himitsu-init.1.scd
himitsu-store.1: docs/himitsu-store.1.scd
	$(SCDOC) <$< >$@

hiq.1: docs/hiq.1.scd
@@ -59,7 +59,7 @@ himitsu.7: docs/himitsu.7.scd
	$(SCDOC) <$< >$@

clean:
	rm -f himitsud himitsu-init hiq $(DOCS)
	rm -f himitsud himitsu-store hiq $(DOCS)

install:
	mkdir -p $(DESTDIR)$(PREFIX)/bin
@@ -68,11 +68,11 @@ install:
	mkdir -p $(DESTDIR)$(MANDIR)/man1
	mkdir -p $(DESTDIR)$(MANDIR)/man5
	mkdir -p $(DESTDIR)$(MANDIR)/man7
	install -m755 himitsud himitsu-init hiq $(DESTDIR)$(PREFIX)/bin
	install -m755 himitsud himitsu-store hiq $(DESTDIR)$(PREFIX)/bin
	install -m644 himitsu/client/* $(DESTDIR)$(THIRDPARTYDIR)/himitsu/client
	install -m644 himitsu/query/* $(DESTDIR)$(THIRDPARTYDIR)/himitsu/query
	install -m644 himitsud.1 $(DESTDIR)$(MANDIR)/man1/himitsud.1
	install -m644 himitsu-init.1 $(DESTDIR)$(MANDIR)/man1/himitsu-init.1
	install -m644 himitsu-store.1 $(DESTDIR)$(MANDIR)/man1/himitsu-store.1
	install -m644 hiq.1 $(DESTDIR)$(MANDIR)/man1/hiq.1
	install -m644 himitsu.ini.5 $(DESTDIR)$(MANDIR)/man5/himitsu.ini.5
	install -m644 himitsu-ipc.5 $(DESTDIR)$(MANDIR)/man5/himitsu-ipc.5
@@ -81,8 +81,8 @@ install:

uninstall:
	rm -f $(DESTDIR)$(PREFIX)/bin/himitsud \
	      $(DESTDIR)$(PREFIX)/bin/himitsu-init \
	      $(DESTDIR)$(PREFIX)/bin/himitsu-store \
	      $(DESTDIR)$(PREFIX)/bin/hiq
	rm -rf $(DESTDIR)$(THIRDPARTYDIR)/himitsu

.PHONY: all himitsud himitsu-init hiq check clean install uninstall docs
.PHONY: all himitsud himitsu-store hiq check clean install uninstall docs
diff --git a/README.md b/README.md
index 483251d..07c9282 100644
--- a/README.md
+++ b/README.md
@@ -28,7 +28,7 @@ You also need a prompter. Try one of these:
Begin by initializing a keystore:

```
$ himitsu-init
$ himitsu-store
```

Then fire up the daemon:
diff --git a/cmd/himitsu-init/main.ha b/cmd/himitsu-store/main.ha
similarity index 99%
rename from cmd/himitsu-init/main.ha
rename to cmd/himitsu-store/main.ha
index 334ff69..0e079df 100644
--- a/cmd/himitsu-init/main.ha
+++ b/cmd/himitsu-store/main.ha
@@ -22,7 +22,7 @@ prompter=hiprompt-gtk`;
export fn main() void = {

	const cmd = getopt::parse(os::args,
		"himitsu-init",
		"himitsu-store",
		('r', "Change master key and re-encrypt the secstore."),
	);
	defer getopt::finish(&cmd);
diff --git a/docs/himitsu-init.1.scd b/docs/himitsu-store.1.scd
similarity index 78%
rename from docs/himitsu-init.1.scd
rename to docs/himitsu-store.1.scd
index fae9fa8..da3d8e9 100644
--- a/docs/himitsu-init.1.scd
+++ b/docs/himitsu-store.1.scd
@@ -1,16 +1,16 @@
himitsu-init(1)
himitsu-store(1)

# NAME

himitsu-init - initialize a new *himitsu*(7) key store
himitsu-store - initialize a new *himitsu*(7) key store

# SYNOPSIS

*himitsu-init [-r]*
*himitsu-store [-r]*

# DESCRIPTION

*himitsu-init* will initialize a new *himitsu*(7) key store at
*himitsu-store* will initialize a new *himitsu*(7) key store at
$XDG_DATA_HOME/himitsu and create a new *himitsu.ini*(5) configuration file at
$XDG_CONFIG_HOME/himitsu/himitsu.ini.

diff --git a/docs/himitsu.7.scd b/docs/himitsu.7.scd
index eae95c9..3896544 100644
--- a/docs/himitsu.7.scd
+++ b/docs/himitsu.7.scd
@@ -11,7 +11,7 @@ pairs, any of which may be secret.

## USAGE

To initialize a new Himitsu key store, run *himitsu-init*(1). This will create a
To initialize a new Himitsu key store, run *himitsu-store*(1). This will create a
new key store, and a new configuration file (see *himitsu.ini*(5)). To begin
servicing user requests, the Himitsu daemon must be running: see *himitsud*(1).

@@ -76,7 +76,7 @@ install "himitsu-ssh" and consult *himitsu-ssh*(7) for usage details.

# SEE ALSO

*himitsu-init*(1), *himitsud*(1), *hiq*(1), *himitsu.ini*(5), *himitsu-ipc*(5),
*himitsu-store*(1), *himitsud*(1), *hiq*(1), *himitsu.ini*(5), *himitsu-ipc*(5),
*himitsu-prompter*(5)

# AUTHORS
diff --git a/docs/himitsu.ini.5.scd b/docs/himitsu.ini.5.scd
index 8ac33d1..1978cd7 100644
--- a/docs/himitsu.ini.5.scd
+++ b/docs/himitsu.ini.5.scd
@@ -12,7 +12,7 @@ brackets (e.g. [himitsud]) on a line. Following each section, a set of key/value
pairs belonging to that section are provided. The keys are separated from the
values by an equal symbol (*=*).

The default configuration file is installed by *himitsu-init*(1).
The default configuration file is installed by *himitsu-store*(1).

# APPLICATION USAGE

diff --git a/docs/himitsud.1.scd b/docs/himitsud.1.scd
index 938bcb5..9897449 100644
--- a/docs/himitsud.1.scd
+++ b/docs/himitsud.1.scd
@@ -15,7 +15,7 @@ $XDG_RUNTIME_DIR/himitsu which accepts commands using the *himitsu-ipc*(5)
protocol. Users will generally use *hiq*(1) or other clients to interact with
it.

The user must have initialized a key store with *himitsu-init*(1) before running
The user must have initialized a key store with *himitsu-store*(1) before running
the daemon.

For a general introduction to Himitsu, see *himitsu*(7).
@@ -29,7 +29,7 @@ The following options are recognized by *himitsud*:

# SEE ALSO

*himitsu*(7), *himitsu-init*(1), *hiq*(1), *himitsu.ini*(5), *himitsu-ipc*(5),
*himitsu*(7), *himitsu-store*(1), *hiq*(1), *himitsu.ini*(5), *himitsu-ipc*(5),
*himitsu-prompter*(5)

# AUTHORS
-- 
2.41.0
The commit message should be "rename himitsu-init to himitsu-store" of 
course.

[PATCH himitsu 2/2] use himitsu-store -i to initialize a new keystore Export this patch

---
 README.md                 |  2 +-
 cmd/himitsu-store/main.ha | 21 ++++++++++++++++++---
 docs/himitsu-store.1.scd  | 16 +++++++++-------
 docs/himitsu.7.scd        |  7 ++++---
 4 files changed, 32 insertions(+), 14 deletions(-)

diff --git a/README.md b/README.md
index 07c9282..9532b9f 100644
--- a/README.md
+++ b/README.md
@@ -28,7 +28,7 @@ You also need a prompter. Try one of these:
Begin by initializing a keystore:

```
$ himitsu-store
$ himitsu-store -i
```

Then fire up the daemon:
diff --git a/cmd/himitsu-store/main.ha b/cmd/himitsu-store/main.ha
index 0e079df..266f31d 100644
--- a/cmd/himitsu-store/main.ha
+++ b/cmd/himitsu-store/main.ha
@@ -23,16 +23,20 @@ export fn main() void = {

	const cmd = getopt::parse(os::args,
		"himitsu-store",
		('i', "Initialize the secstore."),
		('r', "Change master key and re-encrypt the secstore."),
	);
	defer getopt::finish(&cmd);

	let re = false;
	let initstore = false;
	for (let i = 0z; i < len(cmd.opts); i += 1) {
		const opt = cmd.opts[i];
		switch (opt.0) {
		case 'r' =>
			re = true;
		case 'i' =>
			initstore = true;
		};
	};

@@ -51,11 +55,20 @@ export fn main() void = {
	const tty = &bufio::buffered(tty, rbuf, wbuf);
	defer io::close(tty)!;

	if (initstore) {
		init(&termios, tty);
		return;
	};

	if (re) {
		reencrypt(tty);
		reencrypt(&termios, tty);
		return;
	};

	fmt::fatalf("No action specified");
};

fn init(termios: *tty::termios, tty: io::handle) void = {
	match (secstore::open()) {
	case let store: secstore::secstore =>
		secstore::close(&store);
@@ -82,7 +95,7 @@ export fn main() void = {
		};
	};

	tty::noecho(&termios)!;
	tty::noecho(termios)!;

	fmt::errorln("Initializing a new himitsu secstore.")!;
	fmt::error("Please enter a passphrase: ")!;
@@ -121,6 +134,7 @@ export fn main() void = {
	writeconf();
};


fn writeconf() void = {
	let buf = path::init()!;
	const confdir = dirs::config("himitsu");
@@ -155,7 +169,7 @@ fn writeconf() void = {
	fmt::println("Wrote config file to", confpath)!;
};

fn reencrypt(tty: io::handle) void = {
fn reencrypt(termios: *tty::termios, tty: io::handle) void = {
	fmt::errorln("Re-encrypting the secstore.\n")!;
	fmt::errorln("There are not many safeguards in effect, so please read carefully.")!;
	fmt::errorln()!;
@@ -167,6 +181,7 @@ fn reencrypt(tty: io::handle) void = {
		dirs::data(""),
	)!;

	tty::noecho(termios)!;
	fmt::error("Please enter your passphrase: ")!;
	const pass = match (bufio::scanline(tty)!) {
	case let buf: []u8 =>
diff --git a/docs/himitsu-store.1.scd b/docs/himitsu-store.1.scd
index da3d8e9..ca58e24 100644
--- a/docs/himitsu-store.1.scd
+++ b/docs/himitsu-store.1.scd
@@ -2,23 +2,25 @@ himitsu-store(1)

# NAME

himitsu-store - initialize a new *himitsu*(7) key store
himitsu-store - manages the *himitsu*(7) key store

# SYNOPSIS

*himitsu-store [-r]*
*himitsu-store [-ir]*

# DESCRIPTION

*himitsu-store* will initialize a new *himitsu*(7) key store at
$XDG_DATA_HOME/himitsu and create a new *himitsu.ini*(5) configuration file at
$XDG_CONFIG_HOME/himitsu/himitsu.ini.
*himitsu-store* manages the *himitsu*(7) key store at $XDG_DATA_HOME/himitsu.

## OPTIONS

*-i*
	Creates a new *himitsu*(7) key store at $XDG_DATA_HOME/himitsu
	and a new *himitsu.ini*(5) configuration file at
	$XDG_CONFIG_HOME/himitsu/himitsu.ini

*-r*
	Instead of initializing a new key store, it will re-encrypt the current
	store with a newly generated master key.
	Re-encrypts the current store with a newly generated master key.

# SEE ALSO

diff --git a/docs/himitsu.7.scd b/docs/himitsu.7.scd
index 3896544..2b79501 100644
--- a/docs/himitsu.7.scd
+++ b/docs/himitsu.7.scd
@@ -11,9 +11,10 @@ pairs, any of which may be secret.

## USAGE

To initialize a new Himitsu key store, run *himitsu-store*(1). This will create a
new key store, and a new configuration file (see *himitsu.ini*(5)). To begin
servicing user requests, the Himitsu daemon must be running: see *himitsud*(1).
To initialize a new Himitsu key store, run *himitsu-store*(1) with the -i
option. This will create a new key store, and a new configuration file (see
*himitsu.ini*(5)). To begin servicing user requests, the Himitsu daemon must be
running: see *himitsud*(1).

The *hiq*(1) command is provided for querying the key store.

-- 
2.41.0
Applied!

To https://git.sr.ht/~sircmpwn/himitsu
   734a34b..  master -> master