platform/core/security/cynara.git
4 months agoRelease 0.20.0 33/319333/1 accepted/tizen_9.0_unified accepted/tizen_unified accepted/tizen_unified_x accepted/tizen/9.0/unified/20250517.164438 accepted/tizen/unified/20250217.155041 accepted/tizen/unified/x/20250221.042129
Tomasz Swierczek [Fri, 7 Feb 2025 12:06:52 +0000 (13:06 +0100)]
Release 0.20.0

* Reintroduce cynara-checks (remove permissive mode in no-smack mode)
* Change some frequent logs from warning to info

Change-Id: I9b4d0b80b93d3ab49270f97053a4c755633b4012

4 months agoReintroduce cynara-checks (remove permissive mode in no-smack mode) 45/318845/1
Tomasz Swierczek [Mon, 27 Jan 2025 10:05:18 +0000 (11:05 +0100)]
Reintroduce cynara-checks (remove permissive mode in no-smack mode)

This is not a simple revert of commit 54ee135b342741b9443858ae5e2e34491039b4bc
as no-smack env. means some exceptions to smack-enabled code paths
in module's logic have to be still present, even if policy
checking should be re-enabled.

Change-Id: I8daaa6d54716bb82ceee981ae811dc4309b1b44f

4 months agoChange some frequent logs from warning to info 34/318134/3 tizen_8.0
Tomasz Swierczek [Mon, 13 Jan 2025 09:00:25 +0000 (10:00 +0100)]
Change some frequent logs from warning to info

There seem to be no difference in VD env. between warning & info,
and thanks to this change, other divisions can cut down the number
of logs displayed.

Change-Id: I28fc4d5ad6d7e7f6e03084a85c3289574c8d38b5

5 months agoRelease 0.19.7 38/316938/2 accepted/tizen_8.0_unified accepted/tizen_unified_x_asan accepted/tizen/8.0/unified/20250108.155921 accepted/tizen/9.0/unified/20250109.040116 accepted/tizen/unified/20250108.170425 accepted/tizen/unified/x/20250108.225144 accepted/tizen/unified/x/asan/20250211.003154
Krzysztof Malysa [Thu, 19 Dec 2024 16:21:30 +0000 (17:21 +0100)]
Release 0.19.7

* Fix deadlock in synchronous client

Change-Id: Ib1b5f08b9108d84ebd399e4b1ba13c4027c41f4e

5 months agoFix deadlock in synchronous client 37/316937/2
Krzysztof Malysa [Thu, 19 Dec 2024 16:08:53 +0000 (17:08 +0100)]
Fix deadlock in synchronous client

When cynara client sends request it has to send it fully before awating
the response. This commit fixes the opportunistic singleshot send call.

Change-Id: I0c64a196fb1183c765c9741b2896c1ffa07ed1a2

5 months agoRelease 0.19.6 56/316856/2 accepted/tizen/8.0/unified/20241219.161400 accepted/tizen/9.0/unified/20241219.155922 accepted/tizen/unified/20241219.102403 accepted/tizen/unified/x/20241220.014631 accepted/tizen/unified/x/asan/20250113.001935
Tomasz Swierczek [Wed, 18 Dec 2024 10:36:21 +0000 (11:36 +0100)]
Release 0.19.6

* Register as CPU inheritance destination in a separate thread
* Add startup logs in release build

Change-Id: I1dae89e5ea9a78b7b7ce73d9fcd14074e81f08aa

5 months agoRegister as CPU inheritance destination in a separate thread 46/316846/3
Krzysztof Malysa [Wed, 18 Dec 2024 10:12:39 +0000 (11:12 +0100)]
Register as CPU inheritance destination in a separate thread

This should prevent cynara from delaying its start due to the
registering delay that happens on VD systems.

Change-Id: I085f17b795de99a5addf2d7f72e337a8cba20329

5 months agoAdd startup logs in release build 75/316675/1
Krzysztof Malysa [Mon, 16 Dec 2024 12:47:33 +0000 (13:47 +0100)]
Add startup logs in release build

Change-Id: I79c1aa0a537343f95f24666c330d79602f7d6fac

6 months agoRelease 0.19.5 02/316302/5 accepted/tizen/unified/20241217.010346 accepted/tizen/unified/x/20241218.032434 accepted/tizen/unified/x/asan/20241224.004154
Tomasz Swierczek [Thu, 12 Dec 2024 10:13:55 +0000 (11:13 +0100)]
Release 0.19.5

* Make the PID-based credential helper for client work with dev_wos
* Add credential helpers for PID
* Add cynara permissive mode build option - dev_wos

Change-Id: Idf13d46db24dfbe59cfb01c2c4c22e4bd73d3c95

6 months agoMake the PID-based credential helper for client work with dev_wos 01/316301/4
Tomasz Swierczek [Thu, 12 Dec 2024 10:09:04 +0000 (11:09 +0100)]
Make the PID-based credential helper for client work with dev_wos

Change-Id: I427ac43aa5a4653454558fd39b088f1bfa401364

6 months agoAdd credential helpers for PID 71/315971/9
Zofia Abramowska [Fri, 6 Dec 2024 12:30:44 +0000 (13:30 +0100)]
Add credential helpers for PID

Change-Id: Ib2f522df40c04eb1e72a528b4a568b931f12f7cb

6 months agoAdd cynara permissive mode build option - dev_wos 35/316135/5
Tomasz Swierczek [Wed, 10 Apr 2024 07:21:09 +0000 (09:21 +0200)]
Add cynara permissive mode build option - dev_wos

Usage: gbs <your favourite flags> --define "dev_wos 1".

If not explicitly specified, the option is disabled (switched to 0).

This option is indended for development purposes only,
not for release builds.

With this option, Cynara enters "permissive mode" and can work
without Smack module enabled in Linux kernel.

In Tizen, Smack labels are used as process (application) identifiers,
and without them, there's no way to distinguish between processes,
making policy checking not easily possible.

With this option, all credentials helper functions that would
normally return client ID (= Smack label), return
same string: User::Pkg::default_app_no_Smack_mode

This mode is intended to be for bring-up development
of Tizen working in container.

This change tries its best to provide daemon still working
for policy management modules to set application policy with admin API,
however, client functionality is changed to always return with
"ALLOW" answer, without contacting the daemon, as no app
identification is possible (yet) without Smack.

Change-Id: I0e9387b1be1cf34b1fdd6c50c75bb4bf000a7d1d

6 months agoRelease 0.19.4 28/316128/1 accepted/tizen/8.0/unified/20241211.153514 accepted/tizen/9.0/unified/20241212.022104 accepted/tizen/unified/20241211.152219
Krzysztof Malysa [Tue, 10 Dec 2024 11:36:30 +0000 (12:36 +0100)]
Release 0.19.4

* Inherit async client CPU priority on connecting/sending requests
* Inherit admin client CPU priority on cynara_admin_{batch,}_check()
* Inherit client CPU priority on cynara_check()

Change-Id: Ie03775352b204ca936b7941f5a4816f58836c822

6 months agoInherit async client CPU priority on connecting/sending requests 27/316127/1
Krzysztof Malysa [Wed, 20 Nov 2024 13:04:58 +0000 (14:04 +0100)]
Inherit async client CPU priority on connecting/sending requests

Change-Id: I83587c92d544668d05f12c39c08a5e118416d0c5

6 months agoInherit admin client CPU priority on cynara_admin_{batch,}_check() 26/316126/1
Krzysztof Malysa [Tue, 10 Dec 2024 11:35:01 +0000 (12:35 +0100)]
Inherit admin client CPU priority on cynara_admin_{batch,}_check()

Change-Id: Ide2e5c6562701a291fab39638a13834892d6f8f7

6 months agoInherit client CPU priority on cynara_check() 25/316125/1
Krzysztof Malysa [Wed, 30 Oct 2024 14:19:38 +0000 (15:19 +0100)]
Inherit client CPU priority on cynara_check()

Change-Id: Ia67d9b1239f7878e89c1e32c2282f9dbfe7249a8

6 months agoRelease 0.19.3 90/315890/3 accepted/tizen/8.0/unified/20241210.170132 accepted/tizen/9.0/unified/20241210.020006 accepted/tizen/unified/20241210.041707
Krzysztof Malysa [Thu, 5 Dec 2024 16:58:21 +0000 (17:58 +0100)]
Release 0.19.3

* Fix race condition that allows writing response too early
* Fix use after free

Change-Id: I90dab22dbdc29cc09ca0aefd13bd17c4c0062bbd

6 months agoFix race condition that allows disconnecting all clients too early 59/315959/2
Krzysztof Malysa [Fri, 6 Dec 2024 12:16:28 +0000 (13:16 +0100)]
Fix race condition that allows disconnecting all clients too early

Change-Id: Id0cfd9596c20f4fb09f64172fcc4b92aacdf4e6c

6 months agoFix race condition that allows writing response too early 88/315888/3
Krzysztof Malysa [Thu, 5 Dec 2024 16:14:30 +0000 (17:14 +0100)]
Fix race condition that allows writing response too early

Change-Id: I5050178f813da5a257b8d84f2109645cba359977

6 months agoFix use after free 68/315768/2
Krzysztof Malysa [Wed, 4 Dec 2024 16:50:29 +0000 (17:50 +0100)]
Fix use after free

Change-Id: Id42e7514a0d29b91df25b28964481b4e66ad95cf

6 months agoRelease 0.19.2 59/315459/1 accepted/tizen/8.0/unified/20241203.173954 accepted/tizen/9.0/unified/20241205.174743 accepted/tizen/unified/20241203.164216
Krzysztof Malysa [Fri, 29 Nov 2024 17:45:55 +0000 (18:45 +0100)]
Release 0.19.2

* Fix cynara client sometimes getting CYNARA_API_SERVICE_NOT_AVAILABLE
* Switch from select() to epoll
* Initialize ForStats
* Remove unused function

Change-Id: I36f69b6b42ee14c3a0c2043feb0dba7a0faf319d

6 months agoFix cynara client sometimes getting CYNARA_API_SERVICE_NOT_AVAILABLE 58/315458/1
Krzysztof Malysa [Thu, 28 Nov 2024 08:07:47 +0000 (09:07 +0100)]
Fix cynara client sometimes getting CYNARA_API_SERVICE_NOT_AVAILABLE

Due to disconnecting all clients procedure upon database update, the
just connected client could have been disconnected resulting in
CYNARA_API_SERVICE_NOT_AVAILABLE error despite cynara service being up
and running.

Now this is avoided by not checking on the client side if connection is
up just after connecting.

Change-Id: If698c5b7c76e1670edbf08882e1ed813ca38e197

6 months agoSwitch from select() to epoll 57/315457/1
Krzysztof Malysa [Wed, 30 Oct 2024 19:10:28 +0000 (20:10 +0100)]
Switch from select() to epoll

This removes the limit of max 1024 listening fds.
And fixes some bogous state transitions in SocketManager that could
result in using closed file descriptors, reusing wrong file descriptors
and daemon crash.

Change-Id: I68d7a62b0a2f7114e0a0a9b3108df10291352a77

6 months agoInitialize ForStats
Krzysztof Jackiewicz [Fri, 25 Oct 2024 09:34:43 +0000 (11:34 +0200)]
Initialize ForStats

Change-Id: I70e75f5a8293637e14890d1fd26af743b1d57e0d

6 months agoRemove unused function
Krzysztof Malysa [Wed, 30 Oct 2024 18:21:17 +0000 (19:21 +0100)]
Remove unused function

Change-Id: Ibbfdc9fb27bfb98ca00ee33c127102555601b7a9

7 months agoRelease 0.19.1 08/319508/4 accepted/tizen/8.0/unified/20241111.162219 accepted/tizen/9.0/unified/20241109.041955 accepted/tizen/unified/20241030.154510
Krzysztof Malysa [Thu, 24 Oct 2024 12:48:01 +0000 (14:48 +0200)]
Release 0.19.1

* Don't accept new connections when their number is > 800
* Add logging some statistics about current connections
* Increase limit of open file descriptors to match the hard limit
* Write all responses before reading requests

Change-Id: I17b3e780e833bcdfe9dbbc61c6aed0299c93ef07

7 months agoDon't accept new connections when their number is > 800 07/319507/4
Krzysztof Malysa [Thu, 24 Oct 2024 12:43:06 +0000 (14:43 +0200)]
Don't accept new connections when their number is > 800

Change-Id: I2c83edd5216f43b3bb924193b55dd7cb4fe2092a

7 months agoAdd logging some statistics about current connections 03/319403/7
Krzysztof Malysa [Tue, 22 Oct 2024 15:32:59 +0000 (17:32 +0200)]
Add logging some statistics about current connections

Change-Id: I92ebd3c1338fa9d25e8dafcb271608fe83c666a9

7 months agoIncrease limit of open file descriptors to match the hard limit 36/319336/6
Krzysztof Malysa [Mon, 21 Oct 2024 17:19:47 +0000 (19:19 +0200)]
Increase limit of open file descriptors to match the hard limit

Change-Id: Ia72903b06b1636cad9c27faed1fb9e0dc5e7cb8f

7 months agoWrite all responses before reading requests 06/319506/1
Krzysztof Malysa [Thu, 24 Oct 2024 10:31:11 +0000 (12:31 +0200)]
Write all responses before reading requests

Change-Id: Ibf7d8e9b11c1a02c0dbf9c2ef95a1c6be9be5a5e

8 months agoRelease 0.19.0 91/318591/3 accepted/tizen_unified_toolchain accepted/tizen/8.0/unified/20241009.160100 accepted/tizen/9.0/unified/20241030.234447 accepted/tizen/unified/20241008.173924 accepted/tizen/unified/toolchain/20241022.122248 accepted/tizen/unified/toolchain/20241022.122745 accepted/tizen/unified/x/20241009.055406 accepted/tizen/unified/x/asan/20241013.235519 tizen_9.0_m2_release
Krzysztof Jackiewicz [Wed, 2 Oct 2024 13:23:54 +0000 (15:23 +0200)]
Release 0.19.0

* Add cynara_admin_check_batch() to API

Change-Id: If45836f887f63dc5d24e016341f6e5662bc10887

8 months agoAdd cynara_admin_check_batch() to API 59/317559/6
Krzysztof Malysa [Wed, 11 Sep 2024 16:48:46 +0000 (18:48 +0200)]
Add cynara_admin_check_batch() to API

Change-Id: I02b8aace1d195175799b10c83c1f74cf90039998

9 months agoRelease 0.18.4 73/316373/1 accepted/tizen_unified_dev accepted/tizen/8.0/unified/20240827.162856 accepted/tizen/unified/20240822.181337 accepted/tizen/unified/dev/20240826.221206 accepted/tizen/unified/toolchain/20241004.101237 accepted/tizen/unified/x/20240823.023219
Krzysztof Malysa [Tue, 20 Aug 2024 09:05:19 +0000 (11:05 +0200)]
Release 0.18.4

* Fix release.sh
* Handle read-only requests concurrently if possible
* Cleanup the code
* Adjust coverage script after lcov upgrade

Change-Id: Ifc3dca0fe1bd662c8a3af0f09dfafb7d3c871650

9 months agoFix release.sh 72/316372/1
Krzysztof Malysa [Tue, 20 Aug 2024 09:04:10 +0000 (11:04 +0200)]
Fix release.sh

Change-Id: I3b199c9d345147635be4001ee01c0a92848bd2fb

10 months agoHandle read-only requests concurrently if possible 06/313406/6
Krzysztof Malysa [Tue, 25 Jun 2024 11:58:45 +0000 (13:58 +0200)]
Handle read-only requests concurrently if possible

AdminCheck, List and sometimes Check and SimpleCheck as "read-only"
requests can be handled with the old policy while other requests install
a new policy.

This commit implements this logic, by creating a thread for handling
non-read-only requests and handling read-only requests in the current
thread.

This optimization makes cynara favour the read-only operations, reducing
request latency during writes to the database. In the below benchmark we can
see that although the median time did rise up due to overhead, the average time
to complete the response is 10 times lower and the max time is also reasonable.

The benchmark runs N threads that execute checks concurrently and one thread
that executes modifications to the cynara database. If either all modifications
are done or all threads are done executing checks, the benchmark ends. Number
of completed checks and modifications is shown below as well.

cynara-test tc02_concurrent_checks_and_modifications_online:
- before:
  - T1 concurrent checks = 41 and T1 modifications = 60:
      min 135.888us max 355409.247us avg 72164.196us median 51363.480us stddev 54810.217us
  - T2 concurrent checks = 4 and T1 modifications = 60:
      min 89501.124us max 2780571.441us avg 1434964.172us median 2756211.420us stddev 1321470.468us
  - T4 concurrent checks = 88 and T1 modifications = 60:
      min 172.504us max 507472.011us avg 127967.290us median 94624.078us stddev 90096.334us
  - T8 concurrent checks = 115 and T1 modifications = 60:
      min 182.550us max 643392.305us avg 201632.817us median 152837.071us stddev 114870.449us
  - T16 concurrent checks = 117 and T1 modifications = 60:
      min 251.474us max 1442323.541us avg 408241.545us median 278515.998us stddev 298364.669us
- after:
  - T1 concurrent checks = 4036 and T1 modifications = 41:
      min 27.113us max 40540.287us avg 469.489us median 122.090us stddev 3404.852us
  - T2 concurrent checks = 8072 and T1 modifications = 41:
      min 35.319us max 38290.327us avg 472.353us median 133.938us stddev 3082.039us
  - T4 concurrent checks = 16144 and T1 modifications = 42:
      min 32.213us max 36620.530us avg 467.503us median 122.385us stddev 2843.337us
  - T8 concurrent checks = 32288 and T1 modifications = 42:
      min 30.648us max 32727.901us avg 386.306us median 166.153us stddev 1972.602us
  - T16 concurrent checks = 64576 and T1 modifications = 55:
      min 34.016us max 38859.047us avg 456.097us median 315.623us stddev 1541.104us

With this change:
- Cynara does not choke when writes are happening.
- The variance of the measurements improves greatly.
- The max time the request takes is always low.

Change-Id: Ic5e8824a84ac08128a035f1e27e3013d96d12b71

10 months agoCleanup the code 94/315294/2
Krzysztof Malysa [Fri, 19 Jul 2024 16:01:26 +0000 (18:01 +0200)]
Cleanup the code

Change-Id: I7ef926f261f1362aa87551b993f0df83cc2f6715

14 months agoAdjust coverage script after lcov upgrade 93/309193/1
Dariusz Michaluk [Fri, 5 Apr 2024 10:36:34 +0000 (12:36 +0200)]
Adjust coverage script after lcov upgrade

Change-Id: I7b19431a6c445a83ed2caa10f11e2ac013ffa404

21 months agoRelease 0.18.3 83/298183/1 accepted/tizen_7.0_unified tizen_7.0 accepted/tizen/7.0/unified/20230906.023354 accepted/tizen/8.0/unified/20231005.093557 accepted/tizen/unified/20230905.085515 accepted/tizen/unified/dev/20240620.005610 tizen_8.0_m2_release
Zofia Abramowska [Fri, 1 Sep 2023 13:33:51 +0000 (15:33 +0200)]
Release 0.18.3

* Block SIG_PIPE on service send() operation
* Silence SVACE defect in tests

Change-Id: I086a4552930b093f39752de38d611083500fa31c

21 months agoBlock SIG_PIPE on service send() operation 66/298166/1
Zofia Abramowska [Fri, 1 Sep 2023 08:04:40 +0000 (10:04 +0200)]
Block SIG_PIPE on service send() operation

Change-Id: I49c3a8a4a52e8b35b5588377476551a79adc5c16

22 months agoSilence SVACE defect in tests 05/296205/1
Krzysztof Jackiewicz [Fri, 21 Jul 2023 12:37:28 +0000 (14:37 +0200)]
Silence SVACE defect in tests

WGID 500405 | ProtocolSerialization.cpp:49PROC_USE.VULNERABLE

Use of vulnerable function 'strcpy' at ProtocolSerialization.cpp:49.
This function is unsafe, use strncpy instead.

Change-Id: I6f9aa86f14fbba072adf44dc49fcc8d4be086952

23 months agoRelease 0.18.2 98/294498/4 accepted/tizen/unified/20230622.015424 accepted/tizen/unified/dev/20230726.115438
Tomasz Swierczek [Tue, 20 Jun 2023 07:55:42 +0000 (09:55 +0200)]
Release 0.18.2

* Fix new toolchain build errors

Change-Id: I20cb14d4d058ac5779e89657f31b84f76f00aee9

23 months agoFix new toolchain build errors 86/294486/7
Tomasz Swierczek [Tue, 20 Jun 2023 04:41:19 +0000 (06:41 +0200)]
Fix new toolchain build errors

Change-Id: Id6c6852c41808d6d7cf447261fc1a88b01c06d44

2 years agoRelease 0.18.1 79/287379/1 accepted/tizen_6.5_unified tizen_6.5 accepted/tizen/6.5/unified/20230222.114559 accepted/tizen/unified/20230130.165635 submit/tizen_6.5/20230220.131810
Tomasz Swierczek [Fri, 27 Jan 2023 10:21:44 +0000 (11:21 +0100)]
Release 0.18.1

* Change release mode log level to warning

Change-Id: I3fd4087d40cf0ecdf14005fda7cf61c0975367fd

2 years agoChange release mode log level to warning 78/287378/1
Tomasz Swierczek [Fri, 27 Jan 2023 09:55:09 +0000 (10:55 +0100)]
Change release mode log level to warning

Debug logs are clearly only for debug mode, but warnings
can be helpful in release mode (VD request).

Change-Id: I86b390fe2838aec3b793ca4bf9b274554a8e6d78

2 years agoRelease 0.18.0 accepted/tizen/7.0/unified/20221228.170429 accepted/tizen/unified/20221228.165958
Dariusz Michaluk [Fri, 23 Dec 2022 07:34:46 +0000 (08:34 +0100)]
Release 0.18.0

* [helpers] Fix linking with creds-commons
* Add dbus helper API to fetch all credentials in one call
* Add gdbus helper API to fetch all credentials in one call
* Change some logs into warnings

Change-Id: Ic5f161e7410e8f93b607d7bb758d17ba322f5a4b

2 years ago[helpers] Fix linking with creds-commons
Zofia Abramowska [Thu, 15 Dec 2022 21:06:09 +0000 (22:06 +0100)]
[helpers] Fix linking with creds-commons

As TARGET_LIB_CREDS_COMMONS wasn't defined on level visible
for credential helpers build, credential libraries were not
properly linked.

Change-Id: I340cb0a312a3f98e9bf11957423a57fc40a35b65

2 years agoAdd dbus helper API to fetch all credentials in one call
Zofia Abramowska [Thu, 15 Dec 2022 22:39:53 +0000 (23:39 +0100)]
Add dbus helper API to fetch all credentials in one call

Change-Id: I17653b94fe79065354bdb82c52c378d9126dab15

2 years agoAdd gdbus helper API to fetch all credentials in one call 00/285700/4
Zofia Abramowska [Thu, 15 Dec 2022 22:39:19 +0000 (23:39 +0100)]
Add gdbus helper API to fetch all credentials in one call

Change-Id: Ie3a0446b60f837bdec42c80323fa6809c7cdddc9

2 years agoChange some logs into warnings 24/285624/2
Tomasz Swierczek [Thu, 15 Dec 2022 11:46:15 +0000 (12:46 +0100)]
Change some logs into warnings

As requested explicitly by Visual Display Division.

Change-Id: I54d18b426d0fc1f65d92352036e660ed6310736d

2 years agoRelease 0.17.2 36/284836/2 accepted/tizen/7.0/unified/20221129.172448 accepted/tizen/unified/20221129.172513
Tomasz Swierczek [Mon, 28 Nov 2022 11:31:12 +0000 (12:31 +0100)]
Release 0.17.2

* Add additional logs
* Implement better tryCatch
* Put some .cpp-local entities in anon ns
* Remove unused sec_build_binary_debug_enable build macro

Change-Id: I40820f05f1ddbe5a9a7455c2796e5dbd64b56b35

2 years agoAdd additional logs 35/284835/2
Tomasz Swierczek [Mon, 28 Nov 2022 11:28:58 +0000 (12:28 +0100)]
Add additional logs

All done for explicit request of Visual Display division.

Change-Id: I7b4f6a487d1dddf5288c3ab5758249bd3e3c6b5e

2 years agoImplement better tryCatch 97/275097/9
Tomasz Swierczek [Mon, 16 May 2022 12:31:44 +0000 (14:31 +0200)]
Implement better tryCatch

     "Gotta catch them all!"
- from Pokémon

Recently it was reported that there's an issue if not-handled
std::bad_alloc in Cynara. After getting more information
(incl. decompiled version of the module), it was found that
when compiled using gcc, implementation of std::function made on-the fly
as argument to tryCatch() is being allocated BEFORE passing it to
the tryCatch() function.

When compiled using clang9, there is no new() in that place.

This patch changes tryCatch() to a template with function being
an R-value reference with std::forward, solving the issue.

Decompiled version with additional new
(thanks to Konstiantyn Melnik, k.melnik@samsung.com):

int __cdecl cynara_check(void *cynara_struct, char *client, char *client_session, char *user, char *privilege)
{
  int v5; // ebx
  char ***lambda_func_obj; // eax
  char *__loc_privilege_ptr; // [esp+1Ch] [ebp-4Ch]
  char *__loc_user_str; // [esp+20h] [ebp-48h]
  char *__loc_client_session_str; // [esp+24h] [ebp-44h]
  char *__loc_client_str; // [esp+28h] [ebp-40h]
  void *__loc_cynara_struct; // [esp+2Ch] [ebp-3Ch]
  char ***lambda_func_ptr; // [esp+3Ch] [ebp-2Ch]
  int (__cdecl *v14)(void **, void **, unsigned int); // [esp+44h] [ebp-24h]
  int (__cdecl *func_to_run)(void *); // [esp+48h] [ebp-20h]
  unsigned int guard_var; // [esp+4Ch] [ebp-1Ch]

  __loc_privilege_ptr = privilege;
  __loc_cynara_struct = cynara_struct;
  __loc_user_str = user;
  __loc_client_str = client;
  __loc_client_session_str = client_session;
  guard_var = __readgsdword(0x14u);
  if ( cynara_struct
    && *(_DWORD *)cynara_struct                 // if (!p_cynara || !p_cynara->impl)
                                                //         return CYNARA_API_INVALID_PARAM;
    && client                                   //     if (!isStringValid(client) || !isStringValid(client_session))
                                                //         return CYNARA_API_INVALID_PARAM;
    && strlen(client) <= 0x1000
    && client_session
    && strlen(client_session) <= 0x1000
    && user
    && strlen(user) <= 0x1000                   //     if (!isStringValid(user) || !isStringValid(privilege))
                                                //         return CYNARA_API_INVALID_PARAM;
    && privilege
    && strlen(privilege) <= 0x1000 )
  {
    lambda_func_obj = (char ***)operator new(0x14u);
    lambda_func_ptr = lambda_func_obj;
    *lambda_func_obj = &__loc_client_str;
    lambda_func_obj[1] = &__loc_client_session_str;
    lambda_func_obj[2] = &__loc_user_str;
    lambda_func_obj[3] = &__loc_privilege_ptr;
    lambda_func_obj[4] = (char **)&__loc_cynara_struct;
    func_to_run = (int (__cdecl *)(void *))sub_4B80;
    v14 = sub_3930;
    v5 = Cynara::tryCatch(&lambda_func_ptr);
    if ( v14 )
      v14((void **)&lambda_func_ptr, (void **)&lambda_func_ptr, 3u);
  }
  else
  {
    v5 = -4;
  }
  if ( __readgsdword(0x14u) != guard_var )
    terminate_proc();
  return v5;
}

Change-Id: I5455d03d411b03ed76a81659efb60c6474ceb99b

3 years agoPut some .cpp-local entities in anon ns 90/267590/2
Konrad Lipinski [Tue, 7 Dec 2021 12:54:40 +0000 (13:54 +0100)]
Put some .cpp-local entities in anon ns

This fixes at least one ODR violtation (FakeStreamForBucketId) which was
defined twice, in test/storage/serializer/{deserialize,serializer}.cpp.
Two unit tests would fail in some environments as a result, particularly
StorageSerializerFixture.dumpBucketsPositive, due to dynamic_cast
failing within gtest (the one from serializer.cpp was being cast to the
one from deserializer.cpp).

Change-Id: Ie0dc0191b4e45d032b68b0df9bfcdf81fca8678f

3 years agoRemove unused sec_build_binary_debug_enable build macro 97/267097/1
Dariusz Michaluk [Thu, 25 Nov 2021 10:34:30 +0000 (11:34 +0100)]
Remove unused sec_build_binary_debug_enable build macro

Change-Id: I3d8c8e4c936449ff36b7288580d90383ce64a2fe

4 years agoRelease 0.17.1 18/256818/1 accepted/tizen_7.0_unified_hotfix tizen_7.0_hotfix accepted/tizen/6.5/unified/20211028.115310 accepted/tizen/7.0/unified/20221110.062252 accepted/tizen/7.0/unified/hotfix/20221116.105528 accepted/tizen/unified/20210420.090123 submit/tizen/20210419.055354 submit/tizen_6.5/20211028.162401 tizen_6.5.m2_release tizen_7.0_m2_release
Konrad Lipinski [Tue, 13 Apr 2021 12:06:53 +0000 (14:06 +0200)]
Release 0.17.1

* Fix UB in predicate-driven PolicyBucket erasure

Change-Id: Iee7c125a927905e68e3477c0126b989951f5366c

4 years agoFix UB in predicate-driven PolicyBucket erasure 70/256770/2
Konrad Lipinski [Mon, 12 Apr 2021 14:39:25 +0000 (16:39 +0200)]
Fix UB in predicate-driven PolicyBucket erasure

Change-Id: Ic1559c79c875e503ac165c29671460ad56deaab2

4 years agoRelease 0.17.0 69/255769/2 submit/tizen/20210324.154641
Konrad Lipinski [Tue, 23 Mar 2021 11:03:56 +0000 (12:03 +0100)]
Release 0.17.0

* Automate code coverage measurement
* Add dependency warning on enabling journal logs in cynara-client
* Shrink CapacityCache keys, speed up generation
* Prevent iterator invalidation in CapacityCache
* Fix zero-initialization of class members
* Remove unused code
* Categorize existing unit tests into positive & negative cases
* Add/amend assorted unit tests to increase coverage
* Fix cyad backup command help position and message
* Redo error printing in cyad
* Remove unnecessary copies
* Force googletest to build with c++17 instead of c++11
* Move protocol serialization/deserialization to one place
* Ensure that MonitorCache capacity is of permissible size

Change-Id: I1daf23ca44ec9fb41ebb29ae1e8facd84a14ae0c

4 years agoFix debug source directory name in coverage script 52/255452/1
Dariusz Michaluk [Thu, 18 Mar 2021 11:56:31 +0000 (12:56 +0100)]
Fix debug source directory name in coverage script

Change-Id: I0789ea1b0676438e2f1be3c7e55a652074a69e4e

4 years agoFix coverage generation in rpm 4.14.1 92/254492/1
Tomasz Swierczek [Wed, 3 Mar 2021 13:59:09 +0000 (14:59 +0100)]
Fix coverage generation in rpm 4.14.1

Debug source package directories now have different names.

Change-Id: Ic84985a203189b67ce01e0db8be222756e1e2f77

4 years agoAdd dependency warning on enabling journal logs in cynara-client 24/253824/3
Tomasz Swierczek [Thu, 18 Feb 2021 08:50:52 +0000 (09:50 +0100)]
Add dependency warning on enabling journal logs in cynara-client

libdbus-policy is going to be integrated with systemd on
kdbus-aware systems. This, combined with cynara-client
which can be configured to use journal (systemd) logs,
can lead to cyclic build dependency:

systemd -> libdbus-policy -> cynara -> systemd

This patch adds a warning comment in spec file where configuration
of the logging module is done and adds a warning displayed from
CMake during build to check the cyclic dependency.

Removal of journal logging was not performend as older cynara
releases used to take advantage of it and the implementation
may be still useful.

Change-Id: I474ae7d6f2724dbaf855adb2c49cea38168d85a3

4 years agoMove CapacityCache::keyToString() to anonymous namespace 88/253688/2
Konrad Lipinski [Tue, 16 Feb 2021 10:51:30 +0000 (11:51 +0100)]
Move CapacityCache::keyToString() to anonymous namespace

Change-Id: I528688316856505b734109fa5fb6e263f9752def

4 years agoShrink CapacityCache keys, speed up generation 47/253547/1
Konrad Lipinski [Mon, 15 Feb 2021 07:05:17 +0000 (08:05 +0100)]
Shrink CapacityCache keys, speed up generation

Change-Id: Ifc8806b934e7a44a81a3e58e850755ad8baf3765

4 years agoPrevent iterator invalidation in CapacityCache 95/253495/3
Krzysztof Jackiewicz [Fri, 12 Feb 2021 09:00:35 +0000 (10:00 +0100)]
Prevent iterator invalidation in CapacityCache

If resultIt happens to point to the element that gets evicted, it will
be invalidated. Perform lookup after possible eviction.

Change-Id: I4d536c6779494f85077a247e3356374346fa35b2

4 years agoAutomate code coverage measurement 47/243047/5
Dariusz Michaluk [Wed, 2 Sep 2020 13:56:43 +0000 (15:56 +0200)]
Automate code coverage measurement

To gather unit tests coverage report:
- use COVERAGE build_type,
- instal cynara-coverage rpm,
- run cynara-coverage.sh script.

Change-Id: I96e113e2fff06e126ea20a1a2bb06dfdd98ae0db

4 years agoFix zero-initialization of class members 38/245138/2
Mateusz Cegielka [Fri, 2 Oct 2020 13:40:40 +0000 (15:40 +0200)]
Fix zero-initialization of class members

Some class members are not zero-initialized, which can cause seemingly
innocent initializations to result in uninitialized memory, which can
cause UB. While unlikely, this shows up as a critical issue in SVACE.

I have changed the constructors so that they explicitly initialize
members in order to fix the issue.

Change-Id: I16e1f253985e1c37f3b5ee67d3d9c91696706054

4 years agoRemove unused files 32/243032/1
Dariusz Michaluk [Wed, 2 Sep 2020 13:40:27 +0000 (15:40 +0200)]
Remove unused files

Change-Id: I7751179a91f0b468e67ff6ff621028bfdfbf5f13

4 years agoCategorize performance unit tests 61/240361/2
Zofia Abramowska [Wed, 5 Aug 2020 16:48:27 +0000 (18:48 +0200)]
Categorize performance unit tests

Categorize into positive/negative test cases.

Change-Id: I19e49df3f26e84f368e744aae235cc3725cdeae6

4 years agoCategorize EntriesQueue unit tests 60/240360/2
Zofia Abramowska [Wed, 5 Aug 2020 16:41:30 +0000 (18:41 +0200)]
Categorize EntriesQueue unit tests

Categorize into positive/negative test cases.

Change-Id: I296ea8d0e768eb86eacdfe986ae7e9764e33deb4

4 years agoCategorize PolicKey unit tests 59/240359/2
Zofia Abramowska [Wed, 5 Aug 2020 16:15:46 +0000 (18:15 +0200)]
Categorize PolicKey unit tests

Categorize into positive/negative test cases.

Change-Id: Ic00e9a906c50f40eb92bfede740e73ef8daa0650

4 years agoCategorize StorageDeserializer and StorageSerializer unit tests 58/240358/2
Zofia Abramowska [Wed, 5 Aug 2020 16:12:32 +0000 (18:12 +0200)]
Categorize StorageDeserializer and StorageSerializer unit tests

Categorize into positive/negative test cases.

Change-Id: I3c1c1f295993b9fa511b7401f8929df6bb93e227

4 years agoCategorize BucketDeserializer unit tests 57/240357/2
Zofia Abramowska [Wed, 5 Aug 2020 16:10:04 +0000 (18:10 +0200)]
Categorize BucketDeserializer unit tests

Categorize into positive/negative test cases.

Change-Id: I6986240e763cc1ea274415b0abaaa4496be0a446

4 years agoCategorize InMemoryStorageBackend unit tests 56/240356/2
Zofia Abramowska [Wed, 5 Aug 2020 16:06:15 +0000 (18:06 +0200)]
Categorize InMemoryStorageBackend unit tests

Categorize into positive/negative test cases.

Change-Id: Ie5212cef2761849dfbee1430293b7ea2f07215b0

4 years agoCategorize Storage unit tests 55/240355/2
Zofia Abramowska [Wed, 5 Aug 2020 15:56:43 +0000 (17:56 +0200)]
Categorize Storage unit tests

Categorize into positive/negative test cases.

Change-Id: I33b618de130e7d496848f7213ac392279e0f854a

4 years agoCategorize ChecksumValidator unit tests 54/240354/2
Zofia Abramowska [Wed, 5 Aug 2020 15:52:50 +0000 (17:52 +0200)]
Categorize ChecksumValidator unit tests

Categorize into positive/negative test cases.

Change-Id: I67e876a1b6205bf64e0261278732f95e9593274b

4 years agoCategorize EntriesManager unit tests 53/240353/2
Zofia Abramowska [Wed, 5 Aug 2020 15:48:44 +0000 (17:48 +0200)]
Categorize EntriesManager unit tests

Categorize into positive/negative test cases.

Change-Id: I24f66ec022f60434399567880659b87fca53e4df

4 years agoCategorize Cynara cmdline parser unit tests 52/240352/2
Zofia Abramowska [Wed, 5 Aug 2020 15:27:19 +0000 (17:27 +0200)]
Categorize Cynara cmdline parser unit tests

Categorize into positive/negative test cases.

Change-Id: I13a7d04717131024a151b2dd8f321800927353a7

4 years agoCategorize AdminPolicyParser unit tests 51/240351/2
Zofia Abramowska [Wed, 5 Aug 2020 15:21:25 +0000 (17:21 +0200)]
Categorize AdminPolicyParser unit tests

Categorize into positive/negative test cases.

Change-Id: Ia86512bfc7fa91ff1f941c93f4bb279cc5b5a637

4 years agoCategorize CynaraAdminPolicies unit tests 50/240350/2
Zofia Abramowska [Wed, 5 Aug 2020 15:19:43 +0000 (17:19 +0200)]
Categorize CynaraAdminPolicies unit tests

Categorize into positive/negative test cases.

Change-Id: Ied6728a02db0f05d741afbee24fad0d60e14d91e

4 years agoAdd missing test categorization in ProtocolAdmin negative unit tests 49/240349/2
Zofia Abramowska [Wed, 5 Aug 2020 14:58:40 +0000 (16:58 +0200)]
Add missing test categorization in ProtocolAdmin negative unit tests

Change-Id: I152549b18c914c5c807484caf90ee6f94b204997

4 years agoRedo cyad commands dispatcher unit tests 48/240348/2
Zofia Abramowska [Mon, 3 Aug 2020 10:41:33 +0000 (12:41 +0200)]
Redo cyad commands dispatcher unit tests

* Minor refactorin
* Categorize into positive/negative test cases

Change-Id: Ib449c1b76863d84cda543db752d965a1b5abbf05

4 years agoCategorize CmdlineOpts unit tests 32/240032/4
Zofia Abramowska [Fri, 31 Jul 2020 16:20:01 +0000 (18:20 +0200)]
Categorize CmdlineOpts unit tests

Categorize into positive/negative test cases.

Change-Id: Ifa0d505ab9fb2e678f69ea5664f15a1922e5fd5c

4 years agoRedo Cyad commandline unit tests 46/239446/6
Zofia Abramowska [Fri, 24 Jul 2020 17:45:28 +0000 (19:45 +0200)]
Redo Cyad commandline unit tests

* rename positive/negative test cases
* add more negative test cases

Change-Id: I204814abcb11cfa41904ed5f3fa45223421cade5

4 years agoFix cyad backup command help position and message 45/239445/6
Zofia Abramowska [Fri, 24 Jul 2020 17:44:33 +0000 (19:44 +0200)]
Fix cyad backup command help position and message

Change-Id: I7c8f0de363e8d3b64922ea9d3947cbf37c04b931

4 years agoRedo error printing in cyad 44/239444/6
Zofia Abramowska [Fri, 24 Jul 2020 17:01:00 +0000 (19:01 +0200)]
Redo error printing in cyad

* remove unused error message generators
* systematize unknown option, missing option and missing argument
  errors printing for all main and sub options

Change-Id: I59368ffc0402b5f07d58616468a045c47fa3596d

4 years agoRedo Credentials Config Parser unit tests 92/239092/6
Zofia Abramowska [Tue, 21 Jul 2020 16:49:17 +0000 (18:49 +0200)]
Redo Credentials Config Parser unit tests

* Categorize into positive/negative test cases
* Split mixed test cases

Change-Id: I069b535d526aad4496dc6ef2befe7c96e133b8ce

4 years agoCategorize string validation unit tests 91/239091/5
Zofia Abramowska [Tue, 21 Jul 2020 15:20:19 +0000 (17:20 +0200)]
Categorize string validation unit tests

Categorize into positive/negative test cases.

Change-Id: I4675e0a5c8d0d8f5682d3d54667a265cd6ac03f4

4 years agoCategorize PolicyBucket unit tests 59/238959/6
Zofia Abramowska [Mon, 20 Jul 2020 18:38:56 +0000 (20:38 +0200)]
Categorize PolicyBucket unit tests

Categorize into positive/negative test cases.

Change-Id: I7f289446a33303cd1e2f1845a925176b6f294aef

4 years agoRemove unnecessary copies 58/238958/6
Zofia Abramowska [Mon, 20 Jul 2020 18:56:22 +0000 (20:56 +0200)]
Remove unnecessary copies

Change-Id: Iea05840fc9366319f17ccc98919efbbf4c350a99

4 years agoCategorize PolicyBucketFixture unit tests 56/238956/7
Zofia Abramowska [Mon, 20 Jul 2020 17:33:09 +0000 (19:33 +0200)]
Categorize PolicyBucketFixture unit tests

Categorize into positive/negative test cases.

Change-Id: Ic78e793e3d9d1ffe8e969f1f2054af2f83dc41ac

4 years agoRedo unit tests for MonitorGetEntriesRequest in ProtocolMonitorGet 55/238955/7
Zofia Abramowska [Mon, 20 Jul 2020 17:21:56 +0000 (19:21 +0200)]
Redo unit tests for MonitorGetEntriesRequest in ProtocolMonitorGet

* squash positive test cases

Change-Id: Ida7226e6692548d181cff18f18633d10ce2f6f36

4 years agoFix: Add missing using for ::testing::DoAll 54/238954/7
Zofia Abramowska [Mon, 20 Jul 2020 17:01:45 +0000 (19:01 +0200)]
Fix: Add missing using for ::testing::DoAll

Change-Id: I2f1c9b822fba93de3f513854a071b8684e563499

4 years agoForce googletest to build with c++17 instead of c++11 53/238953/7
Zofia Abramowska [Mon, 20 Jul 2020 16:55:11 +0000 (18:55 +0200)]
Force googletest to build with c++17 instead of c++11

Newest googletest builds explicitly with c++11. This makes this
standard propagate to cynara-tests compile options and causes
a build break. This should be only a temporary fix, as cynara CMake
build files should be rewritten properly.

Change-Id: I8afa84921fb2eb2979afc6a7e7b072428bdb258f

4 years agoRedo unit tests for MonitorGetEntriesResponse in ProtocolMonitorGet 52/238952/7
Zofia Abramowska [Mon, 20 Jul 2020 13:45:57 +0000 (15:45 +0200)]
Redo unit tests for MonitorGetEntriesResponse in ProtocolMonitorGet

* squash positive test cases
* add invalid protocol test cases

Change-Id: I2172a1a8814a924754411704b1d166df681ba92c

4 years agoRedo unit tests for MonitorGetFlushRequest in ProtocolMonitorGet 36/238836/7
Zofia Abramowska [Fri, 17 Jul 2020 16:34:10 +0000 (18:34 +0200)]
Redo unit tests for MonitorGetFlushRequest in ProtocolMonitorGet

* squash positive test cases

Change-Id: I848f90d1e9d565ee186f2728d37951144c297900

4 years agoAdd negative test case to RemoveBucketRequest unit tests 35/238835/7
Zofia Abramowska [Fri, 17 Jul 2020 16:23:02 +0000 (18:23 +0200)]
Add negative test case to RemoveBucketRequest unit tests

Add invalid protocol test case.

Change-Id: I06ddadc7acbd57c7f2bf52746a7770f23d0ad37f

4 years agoRedo unit tests for ListResponse in ProtocolAdmin 34/238834/7
Zofia Abramowska [Fri, 17 Jul 2020 15:48:49 +0000 (17:48 +0200)]
Redo unit tests for ListResponse in ProtocolAdmin

Change-Id: Ib012cc489597013c1b1af260d1c890af17e6673e

4 years agoRedo unit tests for ListRequest in ProtocolAdmin 33/238833/7
Zofia Abramowska [Fri, 17 Jul 2020 15:25:34 +0000 (17:25 +0200)]
Redo unit tests for ListRequest in ProtocolAdmin

* squash positive test cases
* add invalid protocol test cases

Change-Id: Iff443af42933c5ca8b942844b06c259a533b7627

4 years agoAdd negative test to InsertOrUpdateBucketRequest unit tests 32/238832/7
Zofia Abramowska [Fri, 17 Jul 2020 15:02:35 +0000 (17:02 +0200)]
Add negative test to InsertOrUpdateBucketRequest unit tests

Add invalid protocol test case.

Change-Id: I40928c4db573adaba9c5cc706033c37a7423f93d

4 years agoRedo unit tests for EraseRequest in ProtocolAdmin 30/238730/7
Zofia Abramowska [Thu, 16 Jul 2020 17:06:17 +0000 (19:06 +0200)]
Redo unit tests for EraseRequest in ProtocolAdmin

* squash positive test cases
* add invalid protocol test cases

Change-Id: I4e3d65668c3bd42ce56c8b3107b631affe7afd70

4 years agoRedo unit tests for DescriptionListResponse in ProtocolAdmin 29/238729/7
Zofia Abramowska [Thu, 16 Jul 2020 16:26:40 +0000 (18:26 +0200)]
Redo unit tests for DescriptionListResponse in ProtocolAdmin

* squash positive test cases
* add invalid protocol test case

Change-Id: I798369d477bf4feefcea93e9ac54423357cf2f26