summaryrefslogtreecommitdiff
path: root/lib/audit_logging
Commit message (Collapse)AuthorAgeFilesLines
* lib:audit_logging: Fix typo in log messageJoseph Sutton2023-05-181-1/+1
| | | | | Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
* lib:audit_logging: Add function to add a formatted time value to a JSON messageJoseph Sutton2023-05-182-17/+44
| | | | | | | | | json_add_timestamp() is limited to adding a ‘timestamp’ field with the current time. The new function can add an arbitrary timestamp with an arbitrary field name. Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
* lib:audit_logging: Add function to add an optional boolean value to a JSON ↵Joseph Sutton2023-05-182-0/+47
| | | | | | | message Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
* lib:audit_logging: Add function to add flags to a JSON messageJoseph Sutton2023-05-182-0/+55
| | | | | | | | | This replaces a couple of calls to snprintf() in log_authentication_event_json() and log_successful_authz_event_json() respectively. Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
* lib:audit_logging: Fix code spellingAndreas Schneider2023-04-031-1/+1
| | | | | | | Best reviewed with: `git show --word-diff`. Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
* audit_logging: Use `json_int_t` instead of `int` for `json_add_int` value typeLi Yuxuan2023-03-092-7/+9
| | | | | | | | | | | | | | | | | Functions like `add_lock_to_json` and `add_profile_item_to_json` pass some values to `json_add_int` with `intmax_t` types. This may cause arithmetic overflow when the value grows very fast, such as the read_bytes profiling data. Use `json_add_int` instead of `int` to avoid the overflow. RN: Make json output show intmax_t value properly Signed-off-by: Li Yuxuan <liyuxuan.darfux@bytedance.com> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Autobuild-User(master): Andrew Bartlett <abartlet@samba.org> Autobuild-Date(master): Thu Mar 9 21:33:43 UTC 2023 on atb-devel-224
* audit_logging:tests: Add big_int test for `json_add_int`Li Yuxuan2023-03-091-1/+10
| | | | | | | | | | | Show that `json_add_int` can't handle value larger than int32 due to overflow. Add knownfail. Signed-off-by: Li Yuxuan <liyuxuan.darfux@bytedance.com> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
* audit_logging: add method to replace the object for a given key with a new ↵Jule Anger2022-08-082-0/+50
| | | | | | | object Signed-off-by: Jule Anger <janger@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org>
* audit_logging.c: fix compilation on macOSAlex Richardson2021-10-131-1/+1
| | | | | | | | | | On macOS tv_usec is an int so failus the build with -Werror,-Wformat. BUG: https://bugzilla.samba.org/show_bug.cgi?id=14862 Signed-off-by: Alex Richardson <Alexander.Richardson@cl.cam.ac.uk> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* lib: Fix a typoVolker Lendecke2021-06-041-1/+1
| | | | | Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* audit logging tests: Fix flapping testJoseph Sutton2021-05-111-9/+21
| | | | | | | | | | | | | | | | | | | | On Linux, gettimeofday() uses the clock's microsecond field to adjust the returned time in seconds, while time() only takes the seconds field into account. As a result, time() would occasionally return a smaller value than gettimeofday(), despite being called later. Changing the time() calls to gettimeofday() as used in audit_logging.c makes the time values consistent. https://stackoverflow.com/questions/22917318/time-and-gettimeofday-return-different-seconds Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Gary Lockyer <gary@catalyst.net.nz> Reviewed-by: Andreas Schneider <asn@samba.org> Autobuild-User(master): Andreas Schneider <asn@cryptomilk.org> Autobuild-Date(master): Tue May 11 07:03:35 UTC 2021 on sn-devel-184
* lib/audit_logging/test: fix typosPhilipp Gesang2021-04-122-27/+27
| | | | | | | | | Signed-off-by: Philipp Gesang <philipp.gesang@intra2net.com> Reviewed-by: Ralph Boehme <slow@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Autobuild-User(master): Ralph Böhme <slow@samba.org> Autobuild-Date(master): Mon Apr 12 20:07:47 UTC 2021 on sn-devel-184
* audit_logging tests: Fix timezone validationGary Lockyer2020-03-071-4/+23
| | | | | | | | | | | | test_audit_get_timestamp used the "%Z" format specifier in strptime, this is non-portable. Updated tests now explicitly set the time zone to "UTC". Signed-off-by: Gary Lockyer <gary@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Autobuild-User(master): Andrew Bartlett <abartlet@samba.org> Autobuild-Date(master): Sat Mar 7 06:37:09 UTC 2020 on sn-devel-184
* build: Do not build selftest binaries for builds without --enable-selftestAndrew Bartlett2019-11-221-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add new for_selftest option to SAMBA_BINARY() and SAMBA3_BINARY() This allows us to be much more consistent (at least in the core Samba) and documents clearly why the binary should not be installed. Not modified are - test_lp_load - notifyd-tests - gendrandperf - test* from examples/libsmbclient - dbwrap_torture - split_tokens - locktest2 - msgtest - msg_sink - msg_source - versiontest - rpc_open_tcp - test_headers As these are not tested in selftest so any change would also be untested. Of course they probably should be added in a different MR. Also not modified (because they are not tests, nor part of the build system) are: - smb2mount - notifydd - log2pacp - debug2html - smbfilter - destroy_netlogon_creds_cli - spotlight2* - tevent_glib_tracker These do however appear to be untested. For now, the source4 forked client tools are left unchanged: - smbclient4 - nmblookup4 Finally, the heimdal binaries are left as install=False as they are either part of the build system or end-user tools that we just don't want to install. These are however tested. The motivation is commit like c34ec003b7d45aa4196ff93a0ac29694b25e5309 and da87fa998ab71328f30bcdf5b41aee8675aee48a, which are both totally correct but are not needed if the selftest is not run on MacOS. There are likely other platforms or build environments where building our test binaries is more pain than valuable, see for example also https://lists.samba.org/archive/samba/2019-November/227137.html Signed-off-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Isaac Boukris <iboukris@samba.org> Autobuild-User(master): Isaac Boukris <iboukris@samba.org> Autobuild-Date(master): Fri Nov 22 11:48:59 UTC 2019 on sn-devel-184
* audit_logging: Don't spam the logs if dsdb_event is not foundAndreas Schneider2019-10-141-5/+4
| | | | | | | | | | This gets only registered by our tests. Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Gary Lockyer <gary@catalyst.net.nz> Autobuild-User(master): Andreas Schneider <asn@cryptomilk.org> Autobuild-Date(master): Mon Oct 14 07:41:52 UTC 2019 on sn-devel-184
* lib audit_logging tests: csbuild unused parmsGary Lockyer2019-06-132-29/+29
| | | | | | | | | | | | Fixes csbuild unused parameter error: warning: unused parameter ‘state’ warning: unused parameter ‘argc’ warning: unused parameter ‘argv’ By adding _UNUSED_ to paramter declaration. Signed-off-by: Gary Lockyer <gary@catalyst.net.nz> Reviewed-by: Andreas Schneider <asn@samba.org>
* lib:audit_logging: Use C99 initializer for server_id in audit_loggingAndreas Schneider2019-04-291-1/+3
| | | | | Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org>
* lib/audit_logging: actually create tallocPhilipp Gesang2018-12-201-0/+6
| | | | | | | | | | | Heal damage of 79f494e51e.. That context is being passed around and freed but is never actually allocated on that stack. Signed-off-by: Philipp Gesang <philipp.gesang@intra2net.com> Reviewed-by: Gary Lockyer <gary@catalyst.net.nz> Reviewed-by: Jeremy Allison <jra@samba.org>
* lib/audit_logging: Use talloc_stackframe() in audit_log_json()Andrew Bartlett2018-12-141-5/+5
| | | | | Signed-off-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Gary Lockyer <gary@catalyst.net.nz>
* audit_logging: Remove debug log header and JSON Authentication: prefixAndrew Bartlett2018-12-142-9/+13
| | | | | | | | | | | | | Feedback from real-world users is that they really want raw JSON strings in the log. We can not easily remove the leading " " but the other strings above and before the JSON are really annoying to strip back off BUG: https://bugzilla.samba.org/show_bug.cgi?id=13714 Signed-off-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Gary Lockyer <gary@catalyst.net.nz>
* audit_logging: Use dom_sid_str_bufVolker Lendecke2018-11-021-4/+4
| | | | | Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* turn --with-json-audit into global --with-jsonPhilipp Gesang2018-09-261-36/+0
| | | | | | | | | | Fold the build option --with-json-audit into the toplevel wscript to reflect the fact that JSON support is no longer local to the audit subsystem. Signed-off-by: Philipp Gesang <philipp.gesang@intra2net.com> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
* lib/audit_logging: make json_{is_invalid,to_string}() accept a const*Philipp Gesang2018-09-222-4/+4
| | | | | | | | | | Allow for json_is_invalid() and json_to_string() to be used on a const pointer. Neither function requires for the json object to be mutable so constraining them to non-const* is unnecessary. Reviewed-by: Gary Lockyer <gary@catalyst.net.nz> Signed-off-by: Philipp Gesang <philipp.gesang@intra2net.com> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
* lib/audit_logging: update to waf 2.0Alexander Bokovoy2018-09-051-2/+2
| | | | | Signed-off-by: Alexander Bokovoy <ab@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
* auth/wscript: import from waflibAlexander Bokovoy2018-09-051-1/+1
| | | | | Signed-off-by: Alexander Bokovoy <ab@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
* auth/wscript: fix options useAlexander Bokovoy2018-09-051-1/+1
| | | | | Signed-off-by: Alexander Bokovoy <ab@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
* lib audit_logging: add _WARN_UNUSED_RESULT_Gary Lockyer2018-07-252-47/+66
| | | | | | | | | | | | Have the compiler issue a warning when the return code from the API is ignored. Signed-off-by: Gary Lockyer <gary@catalyst.net.nz> Reviewed-by: Jeremy Allison <jra@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Autobuild-User(master): Gary Lockyer <gary@samba.org> Autobuild-Date(master): Wed Jul 25 09:28:31 CEST 2018 on sn-devel-144
* json: Add unit tests for error handlingGary Lockyer2018-07-252-0/+900
| | | | | | | | | Add cmocka unit tests to exercise the error handling in the JSON routines. Signed-off-by: Gary Lockyer <gary@catalyst.net.nz> Reviewed-by: Jeremy Allison <jra@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
* json: Modify API to use return codesGary Lockyer2018-07-253-267/+573
| | | | | | | | | Modify the auditing JSON API to return a response code, as the consensus was that the existing error handling was aesthetically displeasing. Signed-off-by: Gary Lockyer <gary@catalyst.net.nz> Reviewed-by: Jeremy Allison <jra@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
* audit_logging: Remove duplciate error printingAndrew Bartlett2018-06-261-6/+0
| | | | | | | These errors are already logged at DBG_NOTICE in get_event_server() Signed-off-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Gary Lockyer <gary@catalyst.net.nz>
* audit_logging: Initialise event_serverAndrew Bartlett2018-06-261-1/+1
| | | | | | | | It is better if this is a known zero value to start, even if we check the errors correctly. Signed-off-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Gary Lockyer <gary@catalyst.net.nz>
* audit_logging: Remove incorrect check for NT_STATUS_OBJECT_NAME_NOT_FOUNDAndrew Bartlett2018-06-261-4/+2
| | | | | | | | NT_STATUS_OBJECT_NAME_NOT_FOUND is not a case we can ignore, it would mean that event_server is not initialised. Signed-off-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Gary Lockyer <gary@catalyst.net.nz>
* audit_logging: Clarify debug messagesAndrew Bartlett2018-06-261-2/+2
| | | | | Signed-off-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Gary Lockyer <gary@catalyst.net.nz>
* lib/audit_logging: Only build audit_logging_test for --enable-selftest on ↵Andrew Bartlett2018-06-251-1/+1
| | | | | | | | | | the AD DC This allows a --without-ad-dc --enable-selftest build to compile, still testing some fileserver-only features. Signed-off-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org>
* lib/audit_logging: Require jansson JSON library for building the AD DCAndrew Bartlett2018-06-251-7/+9
| | | | | | | | | | | This combination is untested and it is reasonable to require this broadly available library for the AD DC build. Doing so keeps the combinational complexity down and ensures we test what we ship. (It was failing to compile). Signed-off-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org>
* build: Move --without-json-audit and json lib detection to lib/audit_loggingAndrew Bartlett2018-06-251-0/+34
| | | | | | | This is the common location of the audit logging code now Signed-off-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org>
* lib/audit_logging fix flapping testGary Lockyer2018-06-101-0/+4
| | | | | | | | | | | | Add an adjustment to the before and after values to cater for the occasional differences between the calculated times. The exact value of the time stamp is not important what is important is that is correctly formatted and that the value is reasonable i.e. it's close enough to the current time. Signed-off-by: Gary Lockyer <gary@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
* lib/audit_logging: Remove #ifdef HAVE_JANSSON from audit_logging_test binaryAndrew Bartlett2018-06-012-17/+14
| | | | | | | | | | Instead, we either build or do not build the entire binary. This is much more likely to raise an error in make test if the build system changes. The concern is that HAVE_JANSSON can go away and the tests just vanish. Signed-off-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Gary Lockyer <gary@catalyst.net.nz>
* lib/audit_logging: Make function prototypes look like the rest of SambaAndrew Bartlett2018-06-012-65/+55
| | | | | | | | The previous style is needed sometimes to avoid an 80-col limit, but is not how most of Samba looks. Signed-off-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Gary Lockyer <gary@catalyst.net.nz>
* lib audit_logging: re-factor and add functions.Gary Lockyer2018-06-013-11/+264
| | | | | | | | | Re-factor the common calls to json_dumps DEBUGC and audit_message_send into a separate function. Add functions to retrieve json object and json array elements Signed-off-by: Gary Lockyer <gary@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
* audit_logging: Fix CID 1435739 Dereference null return valueVolker Lendecke2018-05-241-0/+1
| | | | | Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* lib: Fix array size in audit_loggingAndreas Schneider2018-05-171-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ../lib/audit_logging/audit_logging.c: In function ‘json_add_timestamp’: ../lib/audit_logging/audit_logging.c:603:12: error: ‘%s’ directive output may be truncated writing up to 9 bytes into a region of size between 0 and 43 [-Werror=format-truncation=] "%s.%06ld%s", ^~ ../lib/audit_logging/audit_logging.c:606:3: tz); ~~ ../lib/audit_logging/audit_logging.c:600:2: note: ‘snprintf’ output between 8 and 70 bytes into a destination of size 50 snprintf( ^~~~~~~~~ timestamp, ~~~~~~~~~~ sizeof(timestamp), ~~~~~~~~~~~~~~~~~~ "%s.%06ld%s", ~~~~~~~~~~~~~ buffer, ~~~~~~~ tv.tv_usec, ~~~~~~~~~~~ tz); ~~~ BUG: https://bugzilla.samba.org/show_bug.cgi?id=13437 Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Guenther Deschner <gd@samba.org> Autobuild-User(master): Andreas Schneider <asn@cryptomilk.org> Autobuild-Date(master): Thu May 17 20:17:35 CEST 2018 on sn-devel-144
* auth logging: Extract common audit logging codeGary Lockyer2018-05-164-0/+1441
Extract the common audit logging code into a library to allow it's re-use in other logging modules. Signed-off-by: Gary Lockyer <gary@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>