Skip to content

occtl generates an invalid JSON output with --debug parameter

Description of problem:

occtl utility generates an invalid JSON output when the --debug parameter is specified.

Version of ocserv used:

ocserv 1.1.7

Distributor of ocserv

Compiled from source on Ubuntu 23.04

How reproducible:

Run the following command:

sudo ./occtl --debug --json --socket-file occtl.sock show status

Actual results:

utility@f3b163e1eaa2:/tmp/ocserv$ sudo ./occtl --debug --json --socket-file occtl.sock show status
  {
    "Status":  "online",
    "Server PID":  1,
    "Sec-mod PID":  50,
    "Sec-mod instance count":  2,
    "Up since":  "2023-06-16 19:46",
    "_Up since":  "41m:50s",
    "raw_up_since":  1686944783,
    "uptime":  2510,
    "Active sessions":  1,
    "Total sessions":  3,
    "Total authentication failures":  0,
    "IPs in ban list":  0,
    "Sec-mod client entries":  1,
    "TLS DB entries":  0
    "Last stats reset":  "2023-06-16 19:46",
    "_Last stats reset":  "41m:50s",
    "raw_last_stats_reset":  1686944783,
    "Sessions handled":  3,
    "Timed out sessions":  0,
    "Timed out (idle) sessions":  0,
    "Closed due to error sessions":  0,
    "Authentication failures":  0,
    "Average auth time":  "    0s",
    "raw_avg_auth_time":  0,
    "Max auth time":  "    1s",
    "raw_max_auth_time":  1,
    "Average session time":  " 5m:00s",
    "raw_avg_session_time":  300,
    "Max session time":  " 7m:00s",
    "raw_max_session_time":  420,
    "Min MTU":  1358,
    "Max MTU":  1378,
    "RX":  "356.0 KB",
    "raw_rx":  356000,
    "TX":  "1.1 MB",
    "raw_tx":  1073000
  }

Expected results:

TLS DB entries property should be followed by a comma after its value.