]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
smbstatus: add general information to the json output
authorJule Anger <janger@samba.org>
Thu, 31 Mar 2022 09:04:52 +0000 (11:04 +0200)
committerJule Anger <janger@samba.org>
Mon, 8 Aug 2022 12:56:28 +0000 (12:56 +0000)
Adds timestamp, samba version and path to smb.conf to a given json
object.

Signed-off-by: Jule Anger <janger@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
source3/utils/status.c
source3/utils/status_json.c
source3/utils/status_json.h
source3/utils/status_json_dummy.c

index 20a49a69b6765a8cd1fc47aea1c355c0c44eeca0..28e673db09a03750bfd032a4325376253bd58ab0 100644 (file)
@@ -965,6 +965,7 @@ int main(int argc, const char *argv[])
 
 #ifdef HAVE_JANSSON
        state.root_json = json_new_object();
+       add_general_information_to_json(&state);
 #endif /* HAVE_JANSSON */
 
        if (getuid() != geteuid()) {
index e9e04026a153bfcb40678980c113edff43851423..59d1a6bf85e34d8a748cad434e48f0840a411ad6 100644 (file)
 #include "audit_logging.h" /* various JSON helpers */
 #include "auth/common_auth.h"
 
+int add_general_information_to_json(struct traverse_state *state)
+{
+       int result;
+
+       result = json_add_timestamp(&state->root_json);
+       if (result < 0) {
+               return -1;
+       }
+
+       result = json_add_string(&state->root_json, "version", samba_version_string());
+       if (result < 0) {
+               return -1;
+       }
+
+       result = json_add_string(&state->root_json, "smb_conf", get_dyn_CONFIGFILE());
+       if (result < 0) {
+               return -1;
+       }
+
+       return 0;
+}
+
 int add_section_to_json(struct traverse_state *state,
                        const char *key)
 {
index abae91c65a9156face0d67a7b6b0754f08b007da..b1c05c835976aa6ae5d72d8f59fdffc70cf498c9 100644 (file)
@@ -25,4 +25,6 @@
 int add_section_to_json(struct traverse_state *state,
                        const char *key);
 
+int add_general_information_to_json(struct traverse_state *state);
+
 #endif
index 0f6dd832705c65e0849335e0dac0d0ce79cade4c..bedd014b436053fdc12dc8b15531dd59394838f6 100644 (file)
@@ -28,3 +28,8 @@ int add_section_to_json(struct traverse_state *state,
 {
        return 0;
 }
+
+int add_general_information_to_json(struct traverse_state *state)
+{
+       return 0;
+}