openziti / ziti-tunnel-sdk-c

Apache License 2.0
43 stars 16 forks source link

couldn't get it working: on_off_identity subcommand #493

Closed qrkourier closed 1 year ago

qrkourier commented 2 years ago

I tried to disable an identity with the on_off_identity subcommand, but I couldn't find a way to get it working based on the built-in usage hints. I'm assuming the correct value for --identity is the filesystem path to the identity config file.

❯ /opt/openziti/bin/ziti-edge-tunnel on_off_identity --identity /opt/openziti/etc/identities/webhookz1-client1.json --onoff
Unknown option ':'
on_off_identity: unrecognized option '--onoff'
Unknown option '?'

❯ /opt/openziti/bin/ziti-edge-tunnel on_off_identity --identity /opt/openziti/etc/identities/webhookz1-client1.json -o     
Unknown option ':'
on_off_identity: option requires an argument -- 'o'
Unknown option '?'

❯ /opt/openziti/bin/ziti-edge-tunnel on_off_identity -h                                                                  
ziti-edge-tunnel on_off_identity: enable/disable the identities information
usage: ziti-edge-tunnel on_off_identity [-i <identity>] [-o <onoff>]

        -i|--identity   identity info that needs to be enabled/disabled
        -o|--onoff      enable/disable the identity

❯ /opt/openziti/bin/ziti-edge-tunnel on_off_identity --identity /opt/openziti/etc/identities/webhookz1-client1.json -o disable
Unknown option ':'
qrkourier commented 2 years ago
❯ /opt/openziti/bin/ziti-edge-tunnel version
v0.19.9-local
qrkourier commented 1 year ago

In v0.21.0 it still doesn't seem to be possible to toggle identities' active status with on_off_identity. The usage hints built in to the CLI don't make sense to me.

"on_off_identity", "enable/disable the identities information", "[-i <identity>] [-o <onoff>]

From reading ziti-edge-tunnel.c, I gather that an arg to option -o of a upper or lower "t" is interpreted as true, which I'm guessing means to invert the status of the identity. However, I can only get a segfault with the many combinations of options and arguments I've tried.

Core was generated by `ziti-edge-tunnel on_off_identity --identity /opt/openziti/etc/identities/mfa3.j'.
Program terminated with signal SIGSEGV, Segmentation fault.
#0  0x00007fd2fc4a54c9 in arena_for_chunk (ptr=0x7ffc06dcb7fa) at ./malloc/arena.c:156
156     ./malloc/arena.c: No such file or directory.
(gdb) bt
#0  0x00007fd2fc4a54c9 in arena_for_chunk (ptr=0x7ffc06dcb7fa) at ./malloc/arena.c:156
#1  arena_for_chunk (ptr=0x7ffc06dcb7fa) at ./malloc/arena.c:160
#2  __GI___libc_free (mem=<optimized out>) at ./malloc/malloc.c:3390
#3  0x000055684e826ce1 in _free_string (s=0x7ffc06dca890) at /github/workspace/build/_deps/ziti-sdk-c-src/library/model_support.c:1113
#4  0x000055684e8298c3 in model_free (meta=<optimized out>, obj=<optimized out>) at /github/workspace/build/_deps/ziti-sdk-c-src/library/model_support.c:470
#5  model_free (obj=0x7ffc06dca890, meta=0x55684e90d580 <tunnel_on_off_identity_META>) at /github/workspace/build/_deps/ziti-sdk-c-src/library/model_support.c:456
#6  0x000055684e84ba1c in free_tunnel_on_off_identity (v=<optimized out>) at /github/workspace/lib/ziti-tunnel-cbs/ziti_tunnel_ctrl.c:1251
#7  0x000055684e81185f in on_off_identity_opts (argc=<optimized out>, argv=<optimized out>) at /github/workspace/programs/ziti-edge-tunnel/ziti-edge-tunnel.c:2378
#8  0x000055684e812585 in commandline_run (command=<optimized out>, argc=3, argv=0x7ffc06dcaa60) at /github/workspace/build/_deps/subcommand-src/commandline.h:83
#9  0x000055684e8098ce in main (argc=4, argv=0x7ffc06dcaa58) at /github/workspace/programs/ziti-edge-tunnel/ziti-edge-tunnel.c:3198
dovholuknf commented 1 year ago

Can you try to toggle from the new preview UI? I'd like to know if you get the same issue image

qrkourier commented 1 year ago

Toggling in the UI works great! I confirmed by parsing the output of ZET's tunnel_status command for the value of Active.