[SCM] Samba Shared Repository - branch master updated
Jule Anger
janger at samba.org
Mon Aug 8 14:02:02 UTC 2022
The branch, master has been updated
via 80d069a72c4 s3:tests: Add a test to check json output of smbstatus profile
via 803899fdc3c smbstatus: add JSON support for smbstatus --profile
via 0ed54cc6078 smbstatus: fix indentation in profile_separator()
via 03ed8d3a07c smbstatus: add a method to add profile items to json
via 74028253e1c s3:tests: Add a test to check json output of smbstatus
via 5d6ed73b38e smbstatus: add JSON support for smbstatus
via 78c6740299f smbstatus: add machine readable creation_time to notify
via ed1c94be4f6 smbstatus: add server_id to notifies
via 8154df9d1f3 smbstatus: add a notifies dictionary
via fed1569f03c smbstatus: add file_id information to byte-range locks in json output
via c47d9d28f12 smbstatus: add locks to byte-range locked files in json output
via eca61089cda smbstatus: add server_id to byte-range locks
via dc3b10cda68 smbstatus: add a basic byte-range locks dictionary
via 6b6b586b8d5 smbstatus: add service path to byte-range locks
via fb809a11712 smbstatus: add machine readable time info to locked files
via 43d811adf6c smbstatus: add general caching information about open files to json output
via c0620250cf3 smbstatus: add sharemode information about open files to json output
via 003684dc678 smbstatus: add server_id to open files dictionary
via 1973c3a9ac9 smbstatus: add lease information about open files to json output
via 595b0198ec3 smbstatus: add oplock information about open files to json output
via dd9dd5bff02 smbstatus: add access mode information about open files to json output
via 8d26456742a smbstatus: add opens to files in json output
via 27d026aca69 smbstatus: add file_id information about open files to json output
via 95712e61b87 smbstatus: add a basic dictionary with open files
via 3ec6e7e31d5 smbstatus: add encryption and signing to sessions
via fd1bfb79bdb smbstatus: add server_id to sessions
via 836fd468c0d smbstatus: add a sessions dictionary
via 1abae1c255c smbstatus: add encryption and signing to connections
via 143d9392d66 smbstatus: add machine readable time to connections
via 7585f8d201f conn_tdb: change type of connections_data.start to NTTIME
via 963e1588681 smbstatus: add session_id to connections dictionary
via 696975554a9 conn_tdb: add sess_id to struct connections_data
via 7d76fe5f443 smbstatus: add server_id to connections
via 138befe4391 smbstatus: add a connections dictionary
via 05362a27995 smbstatus: add general information to the json output
via a64c9078746 smbstatus: add method add_section_to_json
via 15fed37afb6 smbstatus: add json items to traverse_struct
via f604e4d4cd9 smbstatus: add frame files for json specific methods
via b35f13a3d0d smbstatus: use new enum crypto_degree
via 92be53754bf smbstatus: add enum to handle partial encryption and signing
via cb8a0d9aecd smbstatus: move the output of the content to their own methods
via e514bdbc1c7 smbstatus: move the output of the title lines to their own methods
via d9c1ff4c2f1 smbstatus: pass the traverse_state to the traverse methods
via caae58fad82 smbstatus: add struct traverse_state
via 04f1d339c62 smbstatus: use variables in print_share_mode instead of printing directly
via 4f21c6fdf90 smbstatus: print errors to stderr instead of stdout
via 4ef2d36615e audit_logging: add method to replace the object for a given key with a new object
via 6412c39bbfa smbstatus: delete wrong EXCLUSIVE+BATCH oplock
from 82d931d23d1 s3: smbd: Oops. DBG_ERR messages I used to debug parse_dfs_path(), should have been DBG_DEBUG.
https://git.samba.org/?p=samba.git;a=shortlog;h=master
- Log -----------------------------------------------------------------
commit 80d069a72c48cbbcf1f42c783318798d698f7dda
Author: Jule Anger <janger at samba.org>
Date: Thu Mar 31 14:40:17 2022 +0200
s3:tests: Add a test to check json output of smbstatus profile
Signed-off-by: Jule Anger <janger at samba.org>
Reviewed-by: Ralph Boehme <slow at samba.org>
Autobuild-User(master): Jule Anger <janger at samba.org>
Autobuild-Date(master): Mon Aug 8 14:01:45 UTC 2022 on sn-devel-184
commit 803899fdc3cf64cda5f3f070b3546aa1c855c978
Author: Jule Anger <janger at samba.org>
Date: Fri Mar 25 14:16:27 2022 +0100
smbstatus: add JSON support for smbstatus --profile
Signed-off-by: Jule Anger <janger at samba.org>
Reviewed-by: Ralph Boehme <slow at samba.org>
commit 0ed54cc6078a99553588cfe69d4f7b47b6e0a293
Author: Ralph Boehme <slow at samba.org>
Date: Thu Aug 4 18:43:05 2022 +0200
smbstatus: fix indentation in profile_separator()
Signed-off-by: Ralph Boehme <slow at samba.org>
Reviewed-by: Jule Anger <janger at samba.org>
commit 03ed8d3a07c37f7e85e700b6db747fc0db97e24a
Author: Jule Anger <janger at samba.org>
Date: Fri Aug 5 13:05:26 2022 +0200
smbstatus: add a method to add profile items to json
The method changes the json item of a given traverse_state.
The root dictionary contains for each section a dictionary, which has
a dictionary for each subsection.
Signed-off-by: Jule Anger <janger at samba.org>
Reviewed-by: Ralph Boehme <slow at samba.org>
commit 74028253e1cccdc5c140fe7e9ec5f3e411d9400e
Author: Jule Anger <janger at samba.org>
Date: Tue Mar 22 16:12:41 2022 +0100
s3:tests: Add a test to check json output of smbstatus
Signed-off-by: Jule Anger <janger at samba.org>
Reviewed-by: Ralph Boehme <slow at samba.org>
commit 5d6ed73b38eb5bde91adfb12bded6b55c13a1f55
Author: Jule Anger <janger at samba.org>
Date: Thu Mar 24 15:46:50 2022 +0100
smbstatus: add JSON support for smbstatus
Adds the option --json for all informations except the profiling.
With --json sets the json_output variable to true, so that the json dictionary
can be created and printed.
Signed-off-by: Jule Anger <janger at samba.org>
Reviewed-by: Ralph Boehme <slow at samba.org>
commit 78c6740299fb96381dded6d7257505fe296675f6
Author: Jule Anger <janger at samba.org>
Date: Mon Aug 1 11:04:23 2022 +0200
smbstatus: add machine readable creation_time to notify
Signed-off-by: Jule Anger <janger at samba.org>
Reviewed-by: Ralph Boehme <slow at samba.org>
commit ed1c94be4f644a40cfad3afc80dbef7a63788ad2
Author: Jule Anger <janger at samba.org>
Date: Mon May 2 10:58:24 2022 +0200
smbstatus: add server_id to notifies
Signed-off-by: Jule Anger <janger at samba.org>
Reviewed-by: Ralph Boehme <slow at samba.org>
commit 8154df9d1f3b4b49799fc191a9a3c04d704f3d1a
Author: Jule Anger <janger at samba.org>
Date: Mon Aug 1 11:19:37 2022 +0200
smbstatus: add a notifies dictionary
Adds an empty json dictionary under the key "notifies" and adds foreach
notify a dictionary with information to the notify dictionary. Uses the
pid as key.
Only print to stdout, if json_output is not set.
Signed-off-by: Jule Anger <janger at samba.org>
Reviewed-by: Ralph Boehme <slow at samba.org>
commit fed1569f03cb2e8d5cea81074c3e076badbe51a0
Author: Jule Anger <janger at samba.org>
Date: Mon Aug 1 11:15:44 2022 +0200
smbstatus: add file_id information to byte-range locks in json output
Adds a dictionary with file_id information (devid, inode and extid) for
each byte-range locked file.
Signed-off-by: Jule Anger <janger at samba.org>
Reviewed-by: Ralph Boehme <slow at samba.org>
commit c47d9d28f122821bc316725804de498c3fee3806
Author: Jule Anger <janger at samba.org>
Date: Thu Mar 31 10:31:31 2022 +0200
smbstatus: add locks to byte-range locked files in json output
At the moment, there is only information about the byte-range locked files.
Adds a list of its locks for each file. An open is represented as
a dictionary. Contains all information (pid, dev_inode, read_write, start
and size) about the lock.
Signed-off-by: Jule Anger <janger at samba.org>
Reviewed-by: Ralph Boehme <slow at samba.org>
commit eca61089cdabd22057fce63adf6dba15128af27a
Author: Jule Anger <janger at samba.org>
Date: Mon May 2 10:57:28 2022 +0200
smbstatus: add server_id to byte-range locks
Signed-off-by: Jule Anger <janger at samba.org>
Reviewed-by: Ralph Boehme <slow at samba.org>
commit dc3b10cda6839f6ff21bec2c39518c0dd2c83efe
Author: Jule Anger <janger at samba.org>
Date: Thu Mar 31 10:30:30 2022 +0200
smbstatus: add a basic byte-range locks dictionary
Adds an empty json dictionary under the key "byte_range_locks"
and adds foreach locked file a dictionary with information
(path and filename) to the byte-range locks dictionary.
Only print to stdout, if json_output is not set.
Signed-off-by: Jule Anger <janger at samba.org>
Reviewed-by: Ralph Boehme <slow at samba.org>
commit 6b6b586b8d594eebe5aec4b97c6d3fa7d0aae16c
Author: Jule Anger <janger at samba.org>
Date: Mon Apr 25 12:15:57 2022 +0200
smbstatus: add service path to byte-range locks
The service/share path was added in 39ddd0a520bc and removed in
3a7d372e2eb5.
Signed-off-by: Jule Anger <janger at samba.org>
Reviewed-by: Ralph Boehme <slow at samba.org>
commit fb809a11712375a1583bc6a94bad0986ec7aad06
Author: Jule Anger <janger at samba.org>
Date: Mon May 9 10:00:22 2022 +0200
smbstatus: add machine readable time info to locked files
Time has the format "2022-03-31T12:23:30+0200".
Signed-off-by: Jule Anger <janger at samba.org>
Reviewed-by: Ralph Boehme <slow at samba.org>
commit 43d811adf6ce49910e12286ebf5121574d590405
Author: Jule Anger <janger at samba.org>
Date: Mon Aug 1 12:02:15 2022 +0200
smbstatus: add general caching information about open files to json output
Adds a dictionary named "caching" to a opens dictionary.
Represents both oplock and leases caching. The dictionary contains a
boolean for each type (READE, WRITE and HANDLE), the hex value and a string
representation.
If no oplocks are used, the dictionary is left empty.
Signed-off-by: Jule Anger <janger at samba.org>
Reviewed-by: Ralph Boehme <slow at samba.org>
commit c0620250cf3e783b5adc43116a3e6896602a479c
Author: Jule Anger <janger at samba.org>
Date: Mon Aug 1 12:01:41 2022 +0200
smbstatus: add sharemode information about open files to json output
Signed-off-by: Jule Anger <janger at samba.org>
Reviewed-by: Ralph Boehme <slow at samba.org>
commit 003684dc67854ed1dbb23d46241758786ca87239
Author: Jule Anger <janger at samba.org>
Date: Mon May 2 10:56:27 2022 +0200
smbstatus: add server_id to open files dictionary
Signed-off-by: Jule Anger <janger at samba.org>
Reviewed-by: Ralph Boehme <slow at samba.org>
commit 1973c3a9ac953f2e8c9ef83ce77a2339cf20c019
Author: Jule Anger <janger at samba.org>
Date: Wed Mar 30 17:05:02 2022 +0200
smbstatus: add lease information about open files to json output
Adds a dictionary named "lease" to a opens dictionary.
If leases are used, the dictionary contains a boolean for each type
(READE, WRITE and HANDLE or UNKNOWN) and a string representation of
the lease. Otherwise the dict is left empty.
Signed-off-by: Jule Anger <janger at samba.org>
Reviewed-by: Ralph Boehme <slow at samba.org>
commit 595b0198ec3678018a7a4f551c6324ea88e7f601
Author: Jule Anger <janger at samba.org>
Date: Wed Mar 30 15:40:56 2022 +0200
smbstatus: add oplock information about open files to json output
Adds a dictionary named "oplock" to a opens dictionary.
Contains a string representation and booleans for each oplock type
(EXCLUSIVE, BATCH, LEVEL_II, LEASE).
Signed-off-by: Jule Anger <janger at samba.org>
Reviewed-by: Ralph Boehme <slow at samba.org>
commit dd9dd5bff02d32c752c29ce1c55093257e41f7c6
Author: Jule Anger <janger at samba.org>
Date: Wed Mar 30 15:39:42 2022 +0200
smbstatus: add access mode information about open files to json output
Adds a dictionary named "access_mask" to a open dictionary.
Contains the hex value of the mask, a text representation and booleans
for each attribute.
Signed-off-by: Jule Anger <janger at samba.org>
Reviewed-by: Ralph Boehme <slow at samba.org>
commit 8d26456742a08991016320fa9cf46598b15affe0
Author: Jule Anger <janger at samba.org>
Date: Wed Mar 30 15:36:13 2022 +0200
smbstatus: add opens to files in json output
At the moment, there is only information about the open files.
Adds a list of its opens for each file. An open is represented as
a dictionary. Contains only the basic information (pid, uid and
time) about the open.
Signed-off-by: Jule Anger <janger at samba.org>
Reviewed-by: Ralph Boehme <slow at samba.org>
commit 27d026aca6963edc29e56fa8cb524242a9de192c
Author: Jule Anger <janger at samba.org>
Date: Wed Mar 30 15:14:13 2022 +0200
smbstatus: add file_id information about open files to json output
Adds a dictionary with file_id information (devid, inode and extid) for
each locked file.
Signed-off-by: Jule Anger <janger at samba.org>
Reviewed-by: Ralph Boehme <slow at samba.org>
commit 95712e61b874404d462b41459e8fe658002ec52f
Author: Jule Anger <janger at samba.org>
Date: Wed Mar 30 15:11:11 2022 +0200
smbstatus: add a basic dictionary with open files
Adds an empty json dictionary under the key "open_files" and adds foreach
locked file a dictionary with information (path, filename and pending
deletes) to the locked files dictionary. Uses path and filename as key.
Only print to stdout, if json_output is not set.
Signed-off-by: Jule Anger <janger at samba.org>
Reviewed-by: Ralph Boehme <slow at samba.org>
commit 3ec6e7e31d569fd75354eda967da72a0fe34837e
Author: Jule Anger <janger at samba.org>
Date: Mon May 9 12:26:30 2022 +0200
smbstatus: add encryption and signing to sessions
Signed-off-by: Jule Anger <janger at samba.org>
Reviewed-by: Ralph Boehme <slow at samba.org>
commit fd1bfb79bdba956a7096420763b8b061d4d703d2
Author: Jule Anger <janger at samba.org>
Date: Mon May 2 10:57:56 2022 +0200
smbstatus: add server_id to sessions
Signed-off-by: Jule Anger <janger at samba.org>
Reviewed-by: Ralph Boehme <slow at samba.org>
commit 836fd468c0dc0e13c8f0f7341260947b20ec6243
Author: Jule Anger <janger at samba.org>
Date: Thu Mar 24 14:09:35 2022 +0100
smbstatus: add a sessions dictionary
Adds an empty json dictionary under the key "sessions" and adds foreach
session a dictionary with information to the session dictionary. Uses the
session_id as key.
uid_str and gid_str are needed because both receive their own JSON field.
Only print to stdout, if json_output is not set.
Signed-off-by: Jule Anger <janger at samba.org>
Reviewed-by: Ralph Boehme <slow at samba.org>
commit 1abae1c255c32c7da713e218c1c8b35f37c60c1c
Author: Jule Anger <janger at samba.org>
Date: Mon May 9 10:11:38 2022 +0200
smbstatus: add encryption and signing to connections
Signed-off-by: Jule Anger <janger at samba.org>
Reviewed-by: Ralph Boehme <slow at samba.org>
commit 143d9392d663781cf9414bcdebca4bf6a1656401
Author: Jule Anger <janger at samba.org>
Date: Mon May 9 09:59:32 2022 +0200
smbstatus: add machine readable time to connections
Time has the format "2022-03-31T12:23:30+0200".
Signed-off-by: Jule Anger <janger at samba.org>
Reviewed-by: Ralph Boehme <slow at samba.org>
commit 7585f8d201f347864514c73ecdf418dab7717310
Author: Jule Anger <janger at samba.org>
Date: Mon Jul 18 11:33:12 2022 +0200
conn_tdb: change type of connections_data.start to NTTIME
connections_data.start previously had the type time_t, but time_t
only had a precision for seconds. NTTIME has a higer precision,
which is useful for debugging.
Signed-off-by: Jule Anger <janger at samba.org>
Reviewed-by: Ralph Boehme <slow at samba.org>
commit 963e158868116a5762693c3b1bbbbdfc902335a4
Author: Jule Anger <janger at samba.org>
Date: Thu Jul 7 10:09:05 2022 +0200
smbstatus: add session_id to connections dictionary
Signed-off-by: Jule Anger <janger at samba.org>
Reviewed-by: Ralph Boehme <slow at samba.org>
commit 696975554a9b11fd707c3093208d24732fd92e41
Author: Jule Anger <janger at samba.org>
Date: Thu Jul 7 10:08:36 2022 +0200
conn_tdb: add sess_id to struct connections_data
Save the session global id as sess_id in the connections_data struct.
Signed-off-by: Jule Anger <janger at samba.org>
Reviewed-by: Ralph Boehme <slow at samba.org>
commit 7d76fe5f4432e9dcac12ca381dfe7465ae14f497
Author: Jule Anger <janger at samba.org>
Date: Mon May 2 10:55:52 2022 +0200
smbstatus: add server_id to connections
Signed-off-by: Jule Anger <janger at samba.org>
Reviewed-by: Ralph Boehme <slow at samba.org>
commit 138befe439152b6eaf990f5c33676b373c5dac6e
Author: Jule Anger <janger at samba.org>
Date: Thu Mar 31 10:20:20 2022 +0200
smbstatus: add a connections dictionary
Adds an empty json dictionary under the key "tcons" and adds foreach
connection a dictionary with information to the shares dictionary.
Only print to stdout, if json_output is not set.
Signed-off-by: Jule Anger <janger at samba.org>
Reviewed-by: Ralph Boehme <slow at samba.org>
commit 05362a2799573ed314bbeb907dab11829732babe
Author: Jule Anger <janger at samba.org>
Date: Thu Mar 31 11:04:52 2022 +0200
smbstatus: add general information to the json output
Adds timestamp, samba version and path to smb.conf to a given json
object.
Signed-off-by: Jule Anger <janger at samba.org>
Reviewed-by: Ralph Boehme <slow at samba.org>
commit a64c9078746aaea0757a8bb480b77ce55d1a4168
Author: Jule Anger <janger at samba.org>
Date: Thu Mar 31 10:17:47 2022 +0200
smbstatus: add method add_section_to_json
The method adds an empty json object (value) under a given section name
(key) to a given json object.
Signed-off-by: Jule Anger <janger at samba.org>
Reviewed-by: Ralph Boehme <slow at samba.org>
commit 15fed37afb6e8eed4f5ce7af168bc9f259048aad
Author: Jule Anger <janger at samba.org>
Date: Thu Mar 24 15:46:35 2022 +0100
smbstatus: add json items to traverse_struct
Signed-off-by: Jule Anger <janger at samba.org>
Reviewed-by: Ralph Boehme <slow at samba.org>
commit f604e4d4cd9eae0cbbd9b60c7912a55ec97517c1
Author: Jule Anger <janger at samba.org>
Date: Thu Mar 24 14:38:46 2022 +0100
smbstatus: add frame files for json specific methods
Signed-off-by: Jule Anger <janger at samba.org>
Reviewed-by: Ralph Boehme <slow at samba.org>
commit b35f13a3d0d7e661a1acfd3d4257808ad044d8cd
Author: Jule Anger <janger at samba.org>
Date: Mon Jul 11 11:05:12 2022 +0200
smbstatus: use new enum crypto_degree
Signed-off-by: Jule Anger <janger at samba.org>
Reviewed-by: Ralph Boehme <slow at samba.org>
commit 92be53754bf7de4582aa3c3d4b2540ac0051bd58
Author: Jule Anger <janger at samba.org>
Date: Mon Jul 11 10:40:16 2022 +0200
smbstatus: add enum to handle partial encryption and signing
Signed-off-by: Jule Anger <janger at samba.org>
Reviewed-by: Ralph Boehme <slow at samba.org>
commit cb8a0d9aecd01f831f07beaa89c34f7c7591f389
Author: Jule Anger <janger at samba.org>
Date: Thu Mar 24 11:36:56 2022 +0100
smbstatus: move the output of the content to their own methods
Signed-off-by: Jule Anger <janger at samba.org>
Reviewed-by: Ralph Boehme <slow at samba.org>
commit e514bdbc1c7f30ce6ee16c8b726c2e032ce5775f
Author: Jule Anger <janger at samba.org>
Date: Thu Mar 24 16:34:10 2022 +0100
smbstatus: move the output of the title lines to their own methods
Signed-off-by: Jule Anger <janger at samba.org>
Reviewed-by: Ralph Boehme <slow at samba.org>
commit d9c1ff4c2f10b4205d25dba9a45cd5d0ac7fc637
Author: Jule Anger <janger at samba.org>
Date: Thu Mar 24 16:27:10 2022 +0100
smbstatus: pass the traverse_state to the traverse methods
The state cannot be used as a context, so a NULL context tmp_ctx must be created.
Signed-off-by: Jule Anger <janger at samba.org>
Reviewed-by: Ralph Boehme <slow at samba.org>
commit caae58fad825b26578b2068dd9abe7a068affd83
Author: Jule Anger <janger at samba.org>
Date: Wed Mar 23 15:17:48 2022 +0100
smbstatus: add struct traverse_state
Signed-off-by: Jule Anger <janger at samba.org>
Reviewed-by: Ralph Boehme <slow at samba.org>
commit 04f1d339c628027fb011d6e2c2b716f5faf6e673
Author: Jule Anger <janger at samba.org>
Date: Wed Mar 23 09:13:58 2022 +0100
smbstatus: use variables in print_share_mode instead of printing directly
Signed-off-by: Jule Anger <janger at samba.org>
Reviewed-by: Ralph Boehme <slow at samba.org>
commit 4f21c6fdf90b0af8370fc17b270b5da2a1ff0209
Author: Jule Anger <janger at samba.org>
Date: Wed Mar 23 08:58:54 2022 +0100
smbstatus: print errors to stderr instead of stdout
Signed-off-by: Jule Anger <janger at samba.org>
Reviewed-by: Ralph Boehme <slow at samba.org>
commit 4ef2d36615eccb3d2b7965693afe91fb4de67445
Author: Jule Anger <janger at samba.org>
Date: Tue Mar 22 16:06:37 2022 +0100
audit_logging: add method to replace the object for a given key with a new object
Signed-off-by: Jule Anger <janger at samba.org>
Reviewed-by: Ralph Boehme <slow at samba.org>
commit 6412c39bbfaa5ab916b5637023c842c47c970b89
Author: Jule Anger <janger at samba.org>
Date: Mon May 9 12:09:18 2022 +0200
smbstatus: delete wrong EXCLUSIVE+BATCH oplock
It is not possible to have an EXCLUSIVE+BATCH oplock, because a BATCH
oplock includes an EXCLUSIVE oplock. Therefore, an EXCLUSIVE+BATCH-Oplock
and a BATCH-Oplock are the same thing.
Signed-off-by: Jule Anger <janger at samba.org>
Reviewed-by: Ralph Boehme <slow at samba.org>
-----------------------------------------------------------------------
Summary of changes:
lib/audit_logging/audit_logging.c | 46 +
lib/audit_logging/audit_logging.h | 4 +
source3/script/tests/test_smbstatus.sh | 249 ++++++
source3/utils/conn_tdb.c | 3 +-
source3/utils/conn_tdb.h | 3 +-
source3/utils/net_status.c | 4 +-
source3/utils/status.c | 635 +++++++++----
source3/utils/{status_profile.h => status.h} | 30 +-
source3/utils/status_json.c | 1230 ++++++++++++++++++++++++++
source3/utils/status_json.h | 77 ++
source3/utils/status_json_dummy.c | 101 +++
source3/utils/status_profile.c | 46 +-
source3/utils/status_profile.h | 4 +-
source3/utils/status_profile_dummy.c | 3 +-
source3/utils/wscript_build | 5 +
15 files changed, 2253 insertions(+), 187 deletions(-)
copy source3/utils/{status_profile.h => status.h} (58%)
create mode 100644 source3/utils/status_json.c
create mode 100644 source3/utils/status_json.h
create mode 100644 source3/utils/status_json_dummy.c
Changeset truncated at 500 lines:
diff --git a/lib/audit_logging/audit_logging.c b/lib/audit_logging/audit_logging.c
index 87378e1bb95..43acf9512c9 100644
--- a/lib/audit_logging/audit_logging.c
+++ b/lib/audit_logging/audit_logging.c
@@ -905,6 +905,52 @@ int json_add_guid(struct json_object *object,
return ret;
}
+/*
+ * @brief Replaces the object for a given key with a given json object.
+ *
+ * If key already exists, the value will be replaced. Otherwise the given
+ * value will be added under the given key.
+ *
+ * @param object the JSON object to be updated.
+ * @param key the key which will be updated.
+ * @param new_obj the new value object to be inserted.
+ *
+ * @return 0 the operation was successful
+ * -1 the operation failed (e.j. if one of the paramters is invalid)
+ */
+int json_update_object(struct json_object *object,
+ const char *key,
+ struct json_object *new_obj)
+{
+ int ret = 0;
+
+ if (json_is_invalid(object)) {
+ DBG_ERR("Unable to update key [%s], "
+ "target object is invalid\n",
+ key);
+ return JSON_ERROR;
+ }
+ if (json_is_invalid(new_obj)) {
+ DBG_ERR("Unable to update key [%s], "
+ "new object is invalid\n",
+ key);
+ return JSON_ERROR;
+ }
+
+ if (key == NULL) {
+ DBG_ERR("Unable to add null String as key\n");
+ return JSON_ERROR;
+ }
+
+ ret = json_object_set(object->root, key, new_obj->root);
+ if (ret != 0) {
+ DBG_ERR("Unable to update object\n");
+ return ret;
+ }
+
+ return ret;
+}
+
/*
* @brief Convert a JSON object into a string
*
diff --git a/lib/audit_logging/audit_logging.h b/lib/audit_logging/audit_logging.h
index 86e9134a86a..49576ece68d 100644
--- a/lib/audit_logging/audit_logging.h
+++ b/lib/audit_logging/audit_logging.h
@@ -87,6 +87,10 @@ _WARN_UNUSED_RESULT_ int json_add_guid(struct json_object *object,
const char *name,
const struct GUID *guid);
+_WARN_UNUSED_RESULT_ int json_update_object(struct json_object *object,
+ const char *key,
+ struct json_object *new_obj);
+
_WARN_UNUSED_RESULT_ struct json_object json_get_array(
struct json_object *object, const char *name);
_WARN_UNUSED_RESULT_ struct json_object json_get_object(
diff --git a/source3/script/tests/test_smbstatus.sh b/source3/script/tests/test_smbstatus.sh
index a7ebabd12f4..0eb186e3d86 100755
--- a/source3/script/tests/test_smbstatus.sh
+++ b/source3/script/tests/test_smbstatus.sh
@@ -237,6 +237,247 @@ EOF
return 0
}
+test_smbstatus_json()
+{
+ local cmdfile=$PREFIX/smbclient_commands
+ local tmpfile=$PREFIX/smbclient_lock_file
+ local file=smbclient_lock_file
+ local status_json=smbstatus_output_json
+ local status_json_long=smbstatus_output_json_long
+
+ cat > $tmpfile <<EOF
+Hello World!
+EOF
+ cat > $cmdfile <<EOF
+lcd $PREFIX_ABS
+put $file
+open $file
+posix
+!UID_WRAPPER_INITIAL_RUID=0 UID_WRAPPER_INITIAL_EUID=0 $SMBSTATUS --json > $status_json
+!UID_WRAPPER_INITIAL_RUID=0 UID_WRAPPER_INITIAL_EUID=0 $SMBSTATUS --json -vBN > $status_json_long
+close 1
+rm $file
+quit
+EOF
+
+ cmd="CLI_FORCE_INTERACTIVE=yes $SMBCLIENT -U$USERNAME%$PASSWORD //$SERVER/tmp -I $SERVER_IP $ADDARGS --quiet < $cmdfile 2>&1"
+ out=$(eval $cmd)
+ echo $out
+ ret=$?
+
+ rm -f $cmdfile
+ rm -f $tmpfile
+
+ if [ $ret -ne 0 ]; then
+ echo "Failed to run smbclient with error $ret"
+ echo "$out"
+ return 1
+ fi
+
+ echo $out | grep -c 'JSON support not available, please install lib Jansson'
+ ret=$?
+ if [ $ret -eq 0 ]; then
+ subunit_start_test "test_smbstatus_json"
+ subunit_skip_test "test_smbstatus_json" <<EOF
+Test needs Jansson
+EOF
+ return 0
+ fi
+
+ out=$(cat $PREFIX/$status_json)
+ ret=$?
+ if [ $ret -ne 0 ]; then
+ echo "Failed: Could not print json output with error $ret"
+ echo "$out"
+ return 1
+ fi
+
+ out=$(cat $PREFIX/$status_json | jq ".")
+ echo $out | grep -c 'jq: not found'
+ ret=$?
+ if [ $ret -eq 0 ]; then
+ subunit_start_test "test_smbstatus_json"
+ subunit_skip_test "test_smbstatus_json" <<EOF
+Test needs jq
+EOF
+ return 0
+ fi
+
+ out=$(cat $PREFIX/$status_json | jq ".")
+ ret=$?
+ if [ $ret -ne 0 ]; then
+ echo "Failed: Could not parse json output from smbstatus with error $ret"
+ echo "$out"
+ return 1
+ fi
+
+ # keys in --json
+ expected='["open_files","sessions","smb_conf","tcons","timestamp","version"]'
+ out=$(cat $PREFIX/$status_json | jq keys -c)
+ if [ "$expected" != "$out" ]; then
+ echo "Failed: Unexpected keys in smbstatus --json"
+ echo "Expected: $expected"
+ echo "Output: $out"
+ return 1
+ fi
+
+ # keys in --json -vBN
+ expected='["byte_range_locks","notifies","open_files","sessions","smb_conf","tcons","timestamp","version"]'
+ out=$(cat $PREFIX/$status_json_long | jq keys -c)
+ if [ "$expected" != "$out" ]; then
+ echo "Failed: Unexpected keys in smbstatus --json"
+ echo "Expected: $expected"
+ echo "Output: $out"
+ return 1
+ fi
+
+ # shares information in --json
+ out=$(cat $PREFIX/$status_json | jq ".tcons|.[].machine")
+ if [ "\"$SERVER_IP\"" != "$out" ]; then
+ echo "Failed: Unexpected value for tcons.machine in smbstatus --json"
+ echo "Expected: $SERVER_IP"
+ echo "Output: $out"
+ return 1
+ fi
+ out=$(cat $PREFIX/$status_json | jq ".tcons|.[].service")
+ if [ '"tmp"' != "$out" ]; then
+ echo "Failed: Unexpected value for tcons.service in smbstatus --json"
+ echo "Expected: tmp"
+ echo "Output: $out"
+ return 1
+ fi
+
+ # session information in --json
+ out=$(cat $PREFIX/$status_json | jq ".sessions|.[].username")
+ if [ "\"$USER\"" != "$out" ]; then
+ echo "Failed: Unexpected value for sessions.username in smbstatus --json"
+ echo "Expected: $USER"
+ echo "Output: $out"
+ return 1
+ fi
+ out=$(cat $PREFIX/$status_json | jq -c ".sessions|.[].signing")
+ expected='{"cipher":"AES-128-GMAC","degree":"partial"}'
+ if [ "$expected" != "$out" ]; then
+ echo "Failed: Unexpected value for sessions.signing in smbstatus --json"
+ echo "Expected: partial(AES-128-GMAC)"
+ echo "Output: $out"
+ return 1
+ fi
+ out=$(cat $PREFIX/$status_json | jq ".sessions|.[].remote_machine")
+ if [ "\"$SERVER_IP\"" != "$out" ]; then
+ echo "Failed: Unexpected value for sessions.remote_machine in smbstatus --json"
+ echo "Expected: $SERVER_IP"
+ echo "Output: $out"
+ return 1
+ fi
+
+ # open_files information in --json
+ out=$(cat $PREFIX/$status_json | jq ".open_files|.[].filename")
+ if [ "\"$file\"" != "$out" ]; then
+ echo "Failed: Unexpected value for open_files.denymode in smbstatus --json"
+ echo "Expected: \"$file\""
+ echo "Output: $out"
+ return 1
+ fi
+ out=$(cat $PREFIX/$status_json | jq ".open_files|.[].opens|.[].access_mask.hex")
+ if [ '"0x00000003"' != "$out" ]; then
+ echo "Failed: Unexpected value for open_files.access_mask.hex in smbstatus --json"
+ echo "Expected: 0x00000003"
+ echo "Output: $out"
+ return 1
+ fi
+
+ rm $PREFIX/$status_json
+ rm $PREFIX/$status_json_long
+
+ return 0
+}
+test_smbstatus_json_profile()
+{
+ local status_json=smbstatus_output_json_profile
+
+ cmd="UID_WRAPPER_INITIAL_RUID=0 UID_WRAPPER_INITIAL_EUID=0 $SMBSTATUS --json --profile > $PREFIX/$status_json"
+ out=$(eval $cmd)
+ ret=$?
+
+ if [ $ret -ne 0 ]; then
+ echo "Failed to run smbstatus -jP with error $ret"
+ echo "$out"
+ return 1
+ fi
+
+ echo $out | grep -c 'JSON support not available, please install lib Jansson'
+ ret=$?
+ if [ $ret -eq 0 ]; then
+ subunit_start_test "test_smbstatus_json_profile"
+ subunit_skip_test "test_smbstatus_json_profile" <<EOF
+Test needs Jansson
+EOF
+ return 0
+ fi
+
+ out=$(cat $PREFIX/$status_json)
+ ret=$?
+ if [ $ret -ne 0 ]; then
+ echo "Failed: Could not print json profile output with error $ret"
+ echo "$out"
+ return 1
+ fi
+
+ out=$(cat $PREFIX/$status_json | jq ".")
+ echo $out | grep -c 'jq: not found'
+ ret=$?
+ if [ $ret -eq 0 ]; then
+ subunit_start_test "test_smbstatus_json_profile"
+ subunit_skip_test "test_smbstatus_json_profile" <<EOF
+Test needs jq
+EOF
+ return 0
+ fi
+
+ out=$(cat $PREFIX/$status_json | jq ".")
+ ret=$?
+ if [ $ret -ne 0 ]; then
+ echo "Failed: Could not parse json output from smbstatus -jP with error $ret"
+ echo "$out"
+ return 1
+ fi
+
+ # keys in --json --profile
+ expected='["ACL Calls","NT Transact Calls","SMB Calls","SMB2 Calls","SMBD loop","Stat Cache","System Calls","Trans2 Calls","smb_conf","timestamp","version"]'
+ out=$(cat $PREFIX/$status_json | jq keys -c)
+ if [ "$expected" != "$out" ]; then
+ echo "Failed: Unexpected keys in smbstatus -jP"
+ echo "Expected: $expected"
+ echo "Output: $out"
+ return 1
+ fi
+
+ # keys in ACL Calls
+ expected='["fget_nt_acl","fset_nt_acl","get_nt_acl","get_nt_acl_at"]'
+ out=$(cat $PREFIX/$status_json | jq -c '."ACL Calls"|keys')
+ if [ "$expected" != "$out" ]; then
+ echo "Failed: Unexpected keys in smbstatus -jP"
+ echo "Expected: $expected"
+ echo "Output: $out"
+ return 1
+ fi
+
+ # keys in ACL Calls, fget_nt_acl
+ expected='["count","time"]'
+ out=$(cat $PREFIX/$status_json | jq -c '."ACL Calls"."fget_nt_acl"|keys')
+ if [ "$expected" != "$out" ]; then
+ echo "Failed: Unexpected keys in smbstatus -jP"
+ echo "Expected: $expected"
+ echo "Output: $out"
+ return 1
+ fi
+
+ rm $PREFIX/$status_json
+
+ return 0
+}
+
testit "plain" \
test_smbstatus ||
failed=$(expr $failed + 1)
@@ -249,4 +490,12 @@ testit "test_output" \
test_smbstatus_output ||
failed=$(expr $failed + 1)
+testit "test_json" \
+ test_smbstatus_json || \
+ failed=`expr $failed + 1`
+
+testit "test_json_profile" \
+ test_smbstatus_json_profile || \
+ failed=`expr $failed + 1`
+
testok $0 $failed
diff --git a/source3/utils/conn_tdb.c b/source3/utils/conn_tdb.c
index 1d19d04f1aa..3724bd42493 100644
--- a/source3/utils/conn_tdb.c
+++ b/source3/utils/conn_tdb.c
@@ -122,12 +122,13 @@ static int traverse_tcon_fn(struct smbXsrv_tcon_global0 *global,
data.pid = global->server_id;
data.cnum = global->tcon_global_id;
+ data.sess_id = sess_id;
fstrcpy(data.servicename, global->share_name);
data.uid = sess.uid;
data.gid = sess.gid;
fstrcpy(data.addr, sess.addr);
fstrcpy(data.machine, sess.machine);
- data.start = nt_time_to_unix(global->creation_time);
+ data.start = global->creation_time;
data.encryption_flags = global->encryption_flags;
data.cipher = sess.cipher;
data.dialect = sess.dialect;
diff --git a/source3/utils/conn_tdb.h b/source3/utils/conn_tdb.h
index 2d2dd65dc8a..cbcf11d960a 100644
--- a/source3/utils/conn_tdb.h
+++ b/source3/utils/conn_tdb.h
@@ -22,12 +22,13 @@
struct connections_data {
struct server_id pid;
int cnum;
+ uint32_t sess_id;
uid_t uid;
gid_t gid;
fstring servicename;
fstring addr;
fstring machine;
- time_t start;
+ NTTIME start;
uint8_t encryption_flags;
uint16_t cipher;
uint16_t dialect;
diff --git a/source3/utils/net_status.c b/source3/utils/net_status.c
index cb3f746f64e..a22b45cc490 100644
--- a/source3/utils/net_status.c
+++ b/source3/utils/net_status.c
@@ -108,7 +108,7 @@ static int show_share(const struct connections_data *crec,
d_printf("%-10.10s %s %-12s %s",
crec->servicename, server_id_str_buf(crec->pid, &tmp),
crec->machine,
- time_to_asc(crec->start));
+ time_to_asc(nt_time_to_unix(crec->start)));
return 0;
}
@@ -166,7 +166,7 @@ static int show_share_parseable(const struct connections_data *crec,
guest ? "" : gidtoname(ids->entries[i].gid),
crec->machine,
guest ? "" : ids->entries[i].hostname,
- time_to_asc(crec->start));
+ time_to_asc(nt_time_to_unix(crec->start)));
return 0;
}
diff --git a/source3/utils/status.c b/source3/utils/status.c
index e860436d72b..e311f067c9c 100644
--- a/source3/utils/status.c
+++ b/source3/utils/status.c
@@ -48,11 +48,19 @@
#include "conn_tdb.h"
#include "serverid.h"
#include "status_profile.h"
+#include "status.h"
+#include "status_json.h"
#include "smbd/notifyd/notifyd_db.h"
#include "cmdline_contexts.h"
#include "locking/leases_db.h"
#include "lib/util/string_wrappers.h"
+#ifdef HAVE_JANSSON
+#include <jansson.h>
+#include "audit_logging.h" /* various JSON helpers */
+#include "auth/common_auth.h"
+#endif /* HAVE_JANSSON */
+
#define SMB_MAXPIDS 2048
static uid_t Ucrit_uid = 0; /* added by OH */
static struct server_id Ucrit_pid[SMB_MAXPIDS]; /* Ugly !!! */ /* added by OH */
@@ -109,7 +117,7 @@ static bool Ucrit_addPid( struct server_id pid )
return True;
if ( Ucrit_MaxPid >= SMB_MAXPIDS ) {
- d_printf("ERROR: More than %d pids for user %s!\n",
+ fprintf(stderr, "ERROR: More than %d pids for user %s!\n",
SMB_MAXPIDS, uidtoname(Ucrit_uid));
return False;
@@ -120,77 +128,150 @@ static bool Ucrit_addPid( struct server_id pid )
return True;
}
+static int print_share_mode_stdout(struct traverse_state *state,
+ const char *pid,
+ const char *user_name,
+ const char *denymode,
+ int access_mask,
+ const char *rw,
+ const char *oplock,
+ const char *servicepath,
+ const char *filename,
+ const char *timestr)
+{
+ if (state->first) {
+ d_printf("\nLocked files:\n");
+ d_printf("Pid User(ID) DenyMode Access R/W Oplock SharePath Name Time\n");
+ d_printf("--------------------------------------------------------------------------------------------------\n");
+
+ state->first = false;
+ }
+
+ d_printf("%-11s %-9s %-10s 0x%-8x %-10s %-14s %s %s %s",
+ pid, user_name, denymode, access_mask, rw, oplock,
+ servicepath, filename, timestr);
+ return 0;
+}
+
+static int prepare_share_mode(struct traverse_state *state)
+{
+ if (!state->json_output) {
+ /* only print header line if there are open files */
+ state->first = true;
+ } else {
+ add_section_to_json(state, "open_files");
+ }
+ return 0;
+}
+
static int print_share_mode(struct file_id fid,
const struct share_mode_data *d,
const struct share_mode_entry *e,
void *private_data)
{
- bool resolve_uids = *((bool *)private_data);
- static int count;
+ const char *denymode = NULL;
+ uint denymode_int;
+ const char *oplock = NULL;
+ const char *pid = NULL;
+ const char *rw = NULL;
+ const char *filename = NULL;
+ const char *timestr = NULL;
+ const char *user_str = NULL;
+ uint32_t lstate;
+ struct traverse_state *state = (struct traverse_state *)private_data;
+
+ TALLOC_CTX *tmp_ctx = talloc_stackframe();
+ if (tmp_ctx == NULL) {
+ return -1;
+ }
if (do_checks && !is_valid_share_mode_entry(e)) {
+ TALLOC_FREE(tmp_ctx);
return 0;
}
- if (count==0) {
- d_printf("Locked files:\n");
--
Samba Shared Repository
More information about the samba-cvs
mailing list