NHAS / wag

Simple Wireguard 2FA
BSD 3-Clause "New" or "Revised" License
516 stars 28 forks source link

No such file or directory #4

Closed paulb-smartit closed 2 years ago

paulb-smartit commented 2 years ago

Edited config.json and added an IP address to a policy - 10.0.4.125/32 then tried to use reload.

            "group:infrastructure": {
                "Mfa": [
                    "10.0.4.24/32",
                    "10.0.4.125/32"
                ]
            },
sudo ./wag reload
2022/09/08 18:59:10 Unable to reload config:  Unable to load configuration file from : open : no such file or directory

Stop and start wag and if fires up as it should with the new rule.

Have to say I'm rather impressed by this so far. I was expecting it to add in lots of iptables rules that I could see happening, but I see it uses xdp ebpf - which must be where the cleverness hides.

If you have a mind for future expansion, I'd consider further authentication modules, maybe as plugins. LDAP, OpenIDC, maybe SAML, even a simple database auth.

Keep up the excellent work

NHAS commented 2 years ago

This will probably be from the config change that I made to fix the -config bug.

I was originally managing the state with IPtables and it was horrific, eBPF and XDP really work quite well in this instance, Im hoping to move the forwarding into the eBPF program if at all possible to further reduce the IPtables rules that I have to add.

As for centralised management, I think that'll be my next goal, at the moment its finding and fixing pain points like these.

Thanks for your compliments!

NHAS commented 2 years ago

I can replicate this, but only when the configuration file is moved after wag has been started. From a UX perspective I suppose having the reload command take the -config argument may be misleading, as the reload command does not take arguments and purely reloads from previous file location.

paulb-smartit commented 2 years ago

I'm not moving anything, just an edit (with vi) and reload. Don't know if it causes a change in the file descriptor or something the process is referencing.

NHAS commented 2 years ago

Hmmmm, I cant replicate that. The program only references the filepath, so nothing fancy is going on with the descriptors.

Im assuming you're running wag with everything in one folder?

NHAS commented 2 years ago

Ahhh, actually I see. On reload its wiping the path it tries to read. So then on the subsequent reload it has no path.

Sweet. latest commits should fix that.

paulb-smartit commented 2 years ago

Hmmmm, I cant replicate that. The program only references the filepath, so nothing fancy is going on with the descriptors.

Im assuming you're running wag with everything in one folder?

Yes, all in /opt/wag

Currently, two terminal windows side by side, so I can see wag running and the effect of reload.

As for centralised management, I think that'll be my next goal, at the moment its finding and fixing pain points like these.

If you get this core stable, it'll be a great base to build on. It just seems very slick in the way it handles the acl's. It's very well suited to my needs.

paulb-smartit commented 2 years ago

Boom, result!

2022/09/08 19:40:53 able to reload config
2022/09/08 19:40:53 Config reloaded
NHAS commented 2 years ago

The line able to reload config should no longer be printed in the fixed version. Can you just make sure that reloading twice works?

NHAS commented 2 years ago

(Otherwise I may have pushed an old version of wag into release)

paulb-smartit commented 2 years ago

Ohh

2022/09/08 19:43:15 Wag started successfully, Ctrl + C to stop
2022/09/08 19:43:45 able to reload config
2022/09/08 19:43:45 Config reloaded
2022/09/08 19:44:00 Unable to reload config:  Unable to load configuration file from : open : no such file or directory
NHAS commented 2 years ago

Yep, thats still the old version!

paulb-smartit commented 2 years ago
$ git pull
From https://github.com/NHAS/wag
 * [new tag]         v1.0.4     -> v1.0.4
Already up to date.
NHAS commented 2 years ago

Should look like this on multiple config reloads now:

2022/09/09 07:43:38 Wag started successfully, Ctrl + C to stop
2022/09/09 07:43:41 Config reloaded
2022/09/09 07:45:32 Config reloaded
2022/09/09 07:45:33 Config reloaded
2022/09/09 07:45:33 Config reloaded

Have you rerun go build?

I did also do a binary release here: https://github.com/NHAS/wag/releases/tag/v1.0.4

paulb-smartit commented 2 years ago

I said I was a go novice

2022/09/08 19:46:51 Wag started successfully, Ctrl + C to stop
2022/09/08 19:46:55 Config reloaded
2022/09/08 19:46:56 Config reloaded
2022/09/08 19:46:57 Config reloaded
2022/09/08 19:46:57 Config reloaded
NHAS commented 2 years ago

Sweet! Glad thats all working for ya

paulb-smartit commented 2 years ago

Many thanks