]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
smbstatus: add machine readable time to connections
authorJule Anger <janger@samba.org>
Mon, 9 May 2022 07:59:32 +0000 (09:59 +0200)
committerJule Anger <janger@samba.org>
Mon, 8 Aug 2022 12:56:28 +0000 (12:56 +0000)
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>
source3/utils/status_json.c

index f4f412d60522a316ddbd5c73a643d505d8ad0d17..3f76cea3c7f006faf8ec388d939a3ac66499b51e 100644 (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) {