~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] agent: allow specifying a custom path

Details
Message ID
<20240708170708.7738-2-hugo@whynothugo.nl>
DKIM signature
pass
Download raw message
Patch: +26 -5
Allow specifying a custom address for the socket. I chose the `-a` flag
simply because it matches with ssh-agent.

The default path remains the same.

I also removed some TODOs for hissh-agent to fork itself. Daemons
shouldn't fork themselves; this breaks service supervision. For
scenarios where this is necessary, there exist plenty of methods
to force a process into background without every daemon implementing
this itself.
---
 cmd/hissh-agent/main.ha | 31 ++++++++++++++++++++++++++-----
 1 file changed, 26 insertions(+), 5 deletions(-)

diff --git a/cmd/hissh-agent/main.ha b/cmd/hissh-agent/main.ha
index f38d499..6f61c04 100644
--- a/cmd/hissh-agent/main.ha
+++ b/cmd/hissh-agent/main.ha
@@ -8,6 +8,7 @@ use errors;
use fmt;
use format::ssh;
use fs;
use getopt;
use himitsu::client;
use himitsu::query;
use himitsu::remember;
@@ -30,12 +31,32 @@ type server = struct {
};

export fn main() void = {
	// TODO: Parse options (foreground/background, socket path)
	// TODO: Fork to background
	const path = path::init()!;
	path::set(&path, dirs::runtime()!, "hissh-agent")!;
	const cmd = getopt::parse(os::args,
		"hissh import",
		('a', "address", "bind to the unix-domain socket address"),
	);
	defer getopt::finish(&cmd);

	let address: (str | void) = void;
	for (let i = 0z; i < len(cmd.opts); i += 1) {
		const opt = cmd.opts[i];
		switch (opt.0) {
		case 'a' =>
			address = strings::dup(opt.1);
		case =>
			fmt::fatalf("unknown option");
		};
	};

	const sockpath = match (address) {
	case let s: str =>
		yield s;
	case void =>
		const path = path::init()!;
		path::set(&path, dirs::runtime()!, "hissh-agent")!;
		yield path::string(&path);
	};

	const sockpath = path::string(&path);
	const socket = match (unix::listen(sockpath)) {
	case let sock: net::socket =>
		yield sock;
-- 
2.45.2
Details
Message ID
<D2KBO2RJRKFV.1U4UQBG485KID@whynothugo.nl>
In-Reply-To
<20240708170708.7738-2-hugo@whynothugo.nl> (view parent)
DKIM signature
pass
Download raw message
On Mon Jul 8, 2024 at 7:07 PM CEST, Hugo Osvaldo Barrera wrote:
> Allow specifying a custom address for the socket. I chose the `-a` flag
> simply because it matches with ssh-agent.
>
> ...

Sorry, forgot about format.subjectPrefix. This patch is for `himitsu-ssh`.
Details
Message ID
<D2KS9JGHZZME.D9CA2V1R3DNF@strohwolke.at>
In-Reply-To
<20240708170708.7738-2-hugo@whynothugo.nl> (view parent)
DKIM signature
pass
Download raw message
Thanks!

Just yesterday I was trying to figure out why and if we need to fork it.
Thanks for the clarification :).

To https://git.sr.ht/~sircmpwn/himitsu-ssh
   0cf03a1..09b33fe  master -> master
Reply to thread Export thread (mbox)