1
0
mirror of https://github.com/samba-team/samba.git synced 2025-02-03 13:47:25 +03:00

smbstatus: add machine readable time to connections

Time has the format "2022-03-31T12:23:30+0200".

Signed-off-by: Jule Anger <janger@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
This commit is contained in:
Jule Anger 2022-05-09 09:59:32 +02:00
parent 7585f8d201
commit 143d9392d6

View File

@ -19,6 +19,7 @@
#include "includes.h"
#include "smbprofile.h"
#include "lib/util/time_basic.h"
#include "conn_tdb.h"
#include "status_json.h"
#include "../libcli/security/security.h"
@ -130,6 +131,9 @@ int traverse_connections_json(struct traverse_state *state,
{
struct json_object sub_json;
struct json_object connections_json;
struct timeval tv;
struct timeval_buf tv_buf;
char *time = NULL;
int result = 0;
char *sess_id_str = NULL;
char *tcon_id_str = NULL;
@ -176,6 +180,15 @@ int traverse_connections_json(struct traverse_state *state,
if (result < 0) {
goto failure;
}
nttime_to_timeval(&tv, crec->start);
time = timeval_str_buf(&tv, true, true, &tv_buf);
if (time == NULL) {
goto failure;
}
result = json_add_string(&sub_json, "connected_at", time);
if (result < 0) {
goto failure;
}
result = json_add_object(&connections_json, tcon_id_str, &sub_json);
if (result < 0) {